ansible实战与配置
# vim /etc/ansible/nginx_install/install.yml---
- hosts: chy02
remote_user: root
gather_facts: True
roles:
- common
- install
# ansible-playbook /etc/ansible/nginx_install/install.yml
: The use of 'include' for tasks has been deprecated. Use 'import_tasks' for static inclusions or
'include_tasks' for dynamic inclusions. This feature will be removed in a future release. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
: include is kept for backwards compatibility but usage is discouraged. The module documentation details
page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
PLAY *********************************************************************************************************************
TASK ***********************************************************************************************************
ok:
TASK ***************************************************************************
failed: (item=) => {"changed": false, "failed": true, "item": ["zlib-devel", "pcre-devel"], "msg": "No Package matching '['zlib-devel'' found available, installed or updated", "rc": 0, "results": []}
to retry, use: --limit @/etc/ansible/nginx_install/install.retry
PLAY RECAP ***********************************************************************************************************************
chy02 : ok=1 changed=0 unreachable=0 failed=1
在执行的时候会报一个错误,这时初步感觉是因为不支持循环,解决方法需要修改一下main.yml的配置文件
# vi tasks/main.yml
- name: Install initializtion require software
yum: name="pcre-devel,zlib-devel" state=installed
# ansible-playbook /etc/ansible/nginx_install/install.yml
再次启动就正常了
# ps aux |grep nginx
root 55660.00.0454841284 ? Ss 03:05 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/localnginx/conf/nginx.conf
nobody 55680.00.2479723920 ? S 03:05 0:00 nginx: worker process
nobody 55690.00.2479723920 ? S 03:05 0:00 nginx: worker process
root 56830.00.0 112664 976 pts/0 R+ 03:05 0:00 grep --color=auto nginx
//在客户机测试成功
如上需要注意一个问题:需要释放80端口,还需要保证客户机上没有安装nginx(包括用yum安装的)
页:
[1]