Ansible Installing Nginx

Source: Internet
Author: User
Tags gz file

Ansible installation nginx for rolling back the publishing function

First, the preparatory work

1. Prepare two machines

sai:192.168.131.132--"Ansible's service side

luojy:192.168.131.133--"Ansible's client

2, 132 machine installed Ansible

(1) Yum install-y epel-release (2) Yum install-y ansible 3, 132,133 turn off firewall 4 on the machine, set hostname,/etc/sysconfig/network Definition 132 Machine: hostname=web1.luojy.com133 machine: hostname=web3.luojy.com 5, edit Hosts file 192.168.131.132 web1.luojy.com192.168.131.133 web3.luojy.com 6, Ansible configuration key (because Ansible is via sshd To implement client and server-side communication) Note: If you want to use ansible on this machine or 132, you need to save the public key on the machine (1) 132 to generate the key pair: ssh-keygen-t RSA (2) id_rsa.pub copy to 131 (. ssh/ Authorized_keys, set 600 read-only permission) 7,/etc/ansible/hosts add

This web2.luojy.com I used to do other things, and WEB2 is already installed Nginx, web3 No, so web3 ~ ~

Yue Heyue, please look at web3!!!.

Second, the installation of Nginx (i) Idea: Web1 machine on the installation of Nginx, packaging, and then use Ansible to send to each client machine to the Nginx directory packaging, put the configuration file in the specified directory to pack the TAR package, Put on other machine install because Nginx will depend on the library file, so on the other side of the machine to install dependent packages/libraries-"Yum (ii) installation process WEB11, WEB1 originally installed Nginx packaging work (1) cd/usr/local (2) Tar ZCVF     Nginx.tar.gz 2, cd/etc/ansible;   mkdir Nginx_install 3, CD Nginx_install;              mkdir roles4, CD roles; mkdir Common Install

Catalogue Description:

(1) Common: Some preparation operations (2) Install: Installation Nginx operation 5, the creation of common under the Tasks directory, which is WEB3 machine needs to install the dependent package CD common/; mkdir tasks; (1) Vim main.yml

6. Enter the install directory and create four directories (1) CD install/(2) mkdir tasks vars Files Templates Description: (a) tasks: Inside is the core configuration file (b) VARs: Variables defined (c) files: Some of the documents used in the installation (d) Templates: Save some configuration files, launch scripts and other template files 7, copy the package files, configuration files, launch scripts into the corresponding directory (1) cp/usr/ Local/nginx/tar.gz files/(2) cp/usr/local/nginx/conf/nginx.conf templates/(3) Cp/etc/init.d/nginx TEMPLATES/8, Defining variables (line 2nd not required) Vim VAR/MAIN.YML

9, Vim tasks/copy.yml--"as the name implies, is to specify a copy of some things to the other machine, the specific look at the name commentary

Description

(a) copy:src=nginx.tar.gz is written directly because the. gz file is under files

(b) template:src=nginx.conf will also be found directly under the templates. conf file

(c) Nginx_basedir in the Var directory 10, Vim tasks/install.yml--"installation (very understood Yes), run user, open the service, join the System Services list

The aftermath was buried. (Delete. gz)

11, Vim tasks/main.yml--"is a string of copy.yml and Install.yml

The structure is like this

12, the definition of the big boss--"The total entrance configuration file

(1) cd/etc/ansible/nginx_install/

(2) Vim install.yml

(iii) EXECUTE COMMAND + test

1, web1 execution: Ansible-playbook install.yml

Warning Harmless ~ ~ ~

I remember running this command out of a little problem

as follows----------------------------------------------------------------------------------------

Workaround

WEB3 installation: Yum install-y Libselinux-python

--------------------------------------------------------------------------------------------

2, WEB3 (LUOJY) test

(1) Test dependency package: Rpm-qa |egrep ' Pcre|openssl|zlib '

(2) Test copy Decompression

(3) Test process start: PS aux |grep nginx

(4) Test system service: Chkconfig--list nginx 345 Boot

Okay, ~ ~ ~ ~~~~~ ^___^

Ansible Installing Nginx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.