nvoking "yum" only once while using a loop via squash_actions is  deprecated.

运行剧本报错:

[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is 
deprecated. Instead of using a loop to supply multiple items and specifying `name: "{{ item
 }}"`, please use `name: ['epel-release', 'nginx']` and remove the loop. This feature will 
be removed in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
failed: [192.168.154.130] (item=[u'epel-release', u'nginx']) => {"changed": false, "item": ["epel-release", "nginx"], "msg": "No package matching 'nginx' found available, installed or updated", "rc": 126, "results": ["No package matching 'nginx' found available, installed or updated"]}
    to retry, use: --limit @/etc/ansible/nginx_install/roles/site.retry

PLAY RECAP *********************************************************************************
192.168.154.130            : ok=1    changed=0    unreachable=0    failed=1 

    从报错的提示信息看出,就 只运行到tasks的nginx的安装就出错了,估摸着是yum仓库的问题,因为想到之前yum安装也是报了类似的错(https://blog.csdn.net/zhou_438/article/details/89554438),于是对被控制的主机执行:

sudo yum install epel-release
yum update

在ansible的机器上继续试一下剧本文件

果然成功啦

changed: [192.168.154.130] => (item=[u'epel-release', u'nginx'])

TASK [nginx : copy index.html] *************************************************************
changed: [192.168.154.130]

TASK [nginx : copy nginx.conf template] ****************************************************
changed: [192.168.154.130]

TASK [nginx : make sure nginx service running] *********************************************
changed: [192.168.154.130]

RUNNING HANDLER [nginx : restart nginx] ****************************************************
changed: [192.168.154.130]

PLAY RECAP *********************************************************************************
192.168.154.130            : ok=6    changed=5    unreachable=0    failed=0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值