* Define MAIN.YML and call copy and install. Any directory must have a total entry profile main.yml
Vim/etc/ansible/nginx_install/roles/install/tasks/main.yml #内容如下
-Include:copy.yml
-Include:install.yml
To this two roles:common and install the definition is complete, next to define a program total Portal configuration file
* Define INSTALL/INSTALL.YML Master Entry profile to invoke the secondary total configuration file
Vim/etc/ansible/nginx_install/install.yml #内容如下
---
-Hosts:testhost
Remote_user:root
Gather_facts:true
Roles
-Common
-Install
Description: Define the client hosts remote user identity to open the client information collection via the Roles module to invoke the general profile main.yml under the common and install folders to execute the command.
Finally, the server executes the command: ANSIBLE-PLAYBOOK/ETC/ANSIBLE/NGINX_INSTALL/INSTALL.YML
After execution completes, the client checks whether the success
1.rpm-qa |egrep ' Pcre|openssl|zlib ' #是否安装了指定依赖包
2.ls/usr/local/nginx/#是否复制了文件
3.ps aux |grep nginx #是否启动nginx
4.chkconfig--list Nginx #是否开机启动
Summary:/ETC/ANSIBLE/NGINX_INSTALL/INSTALL.YML defines the total installation profile, calls the Main.yml installation dependency package under Roles/common/tasks, and calls roles/install/ Tasks under the MAIN.YML to create users, copy files and other operations. The variables referenced during the execution of the file are defined from the ROLES/INSTALL/VARS/MAIN.YML.
/etc/ansible/nginx_install/is the main directory, the roles is a first-level directory, under the two-level directory, such as common and install the difference in order and functional purposes. Under the three level directory, the core task is tasks, files are required for file, define variable VARs, etc.
4.2-ansible Instance-install under Nginx