In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1.1 build directory structure
This operation is the directory structure of installing nginx+mysql+tomcat+db, you can refer to it, not bad.
Mkdir-p / ansible/roles/ {nginx,mysql,tomcat,db} / {defaults,files,handlers,meta,tasks,templates,vars} defaults default search path tasks storage playbooks path files storage files and script packages, copy module file search path templates template storage path handlers notify call partial playbook storage path vars roles internal variable storage path
1.2 File directory structure
[root@qtbackup ~] # tree / ansible//ansible/ ├── playbook │ └── playbook.yml ├── roles │ ├── db │ │ ├── defaults │ │ ├── files │ │ ├── handlers │ │ ├── meta │ tasks en23# templates vars ─ handlers │ │ ├── meta │ │ ├── tasks │ │ ├── templates │ │ └── vars │ ├── nginx │ │ ├── defaults │ files handlers meta tasks templates vars tomcat defaults files ├── apache-tomcat-8.0.29.tar.gz │ │ ├── jdk-8u73-linux-x64.gz │ │ ├── tomcat-initscript.sh │ │ └── tomcat-users.xml │ ├── handlers │ │ └── main.yml │ ├── meta │ ├── tasks main.yml templates tomcat- Users.xml │ └── vars ├── ssh_key.sh # automatically distribute sshkey scripts (fully posted below) ├── web.retry └── web.yml # Total call file 34 directories 11 files
[root@qtbackup ~] #
1.3 create a total call file in the ansible directory
-hosts: bgo # this is the name of the host group defined by hosts. If it is a single host, you can directly write the address remote_user: root # execute the user roles: # explain the configuration file directory, because we install tomcat this time, so comment the other #-nginx #-mysql-tomcat #-db
1.4 create a tomcat installation playbook file
Vim / ansible/roles/tomcat/tasks/main.yml# this is to install jdk with the yum module If necessary, you can use #-name: install java# yum: name=java-1.8.0-openjdk.x86_64 state=present===# to create users-name: group group: name=tomcat- name: user user: name=tomcat group=tomcat home=/usr/tomcat sudo: True## this source code package to install JDK#### # copy jdk to the tmp directory-name: copy jdk-8u73-linux-x64.gz copy: src=jdk-8u73-linux-x64.gz dest=/tmp/jdk-8u73-linux-x64.gz# extract the jdk package to / application- name: Extract archive jdk command: / bin/tar xf / tmp/jdk-8u73-linux-x64.gz-C / application# rename-name: java shell: mv / application/jdk1.8.0_73 / application/java# add environment variables -name: add / etc/profile lineinfile: dest=/etc/profile regexp= "^ JAVA_HOME=" line= "JAVA_HOME=/application/java/"-name: add / etc/profile lineinfile: dest=/etc/profile regexp= "^ CLASS_PATH=" line= "CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib"-name: add / etc/profile lineinfile: dest=/etc/profile regexp= "^ PATH=\ $PATH:\ $JAVA_HOME" line= "PATH=$PATH:$JAVA_HOME/bin"-name: add / etc/profile lineinfile: dest=/etc / profile regexp= "^ export JAVA_HOME" line= "export JAVA_HOME" # # install tomcat###- name: copy tomcat_tar_gz copy: src=apache-tomcat-8.0.29.tar.gz dest=/tmp/apache-tomcat- 8.0.29.tar.gz# decompress tomcat to opt directory-name: Extract archive command: / bin/tar xf / tmp/apache-tomcat-8.0.29.tar.gz-C / opt# create soft connection-name: Symlink install directory file: src=/opt/apache-tomcat-8.0.29/ dest=/application/tomcat state=link# gives directory permissions-name: Change ownership of Tomcat installation file: path=/application/tomcat/ owner=tomcat group=tomcat state=directory recurse=yes# push configuration file-name : Configure Tomcat users template: src=tomcat-users.xml dest=/application/tomcat/conf/ notify: restart tomcat# installs tomcat. Init startup script-name: Install Tomcat initscript copy: src=tomcat-initscript.sh dest=/etc/init.d/tomcat mode=0755# enable tomcat- name: Start Tomcat service: name=tomcat state=started enabled=yes
1.5 call handlers through notify
-name: restart tomcat service: name=tomcat state=restarted
1.6 Syntax detection = = perform installation
Cd / ansibleansible-playbook web.yml-- syntax-check # check syntax ansible-playbook web.yml # execution
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.