Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ansible 2.7 环境下 提示 “[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated.” 问题 #334

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

klgd
Copy link
Contributor

@klgd klgd commented Oct 9, 2018

@Hello-Linux
Copy link
Contributor

你这样写的话显得playbook比较冗余了
官方实例:

  • name: Install packages
    yum:
    name: "{{ packages }}"
    state: present
    这个packages 列表可以定义到role 的default目录下面 最好放到roles变量里面不要写到name里面显得yaml很不美观 ansible2.7版本提示yum apt自身支持一次安装多个软件包 ,建议后面加一个判断ansible版本的断点以此来兼容不同版本,因为后期ansible更新频繁必然会出现一些不小的改动 @gjmzj

@gjmzj
Copy link
Collaborator

gjmzj commented Oct 9, 2018

ansible 版本确实是个问题,这个PR可能不能merge,因为大部分人可能没有升级ansible到2.7,如果merge了,那旧版本就可能出错了;

@klgd
Copy link
Contributor Author

klgd commented Oct 9, 2018

@gjmzj 我在 ansible 2.6.5 下试了,正常安装,你试试?

[root@k8s-m-100 ansible]# ansible --version
ansible 2.6.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
TASK [prepare : 删除centos默认安装] ************************************************************************************************************************************************************************************************************************************************
changed: [172.168.1.100]
changed: [172.168.1.103]
changed: [172.168.1.102]
changed: [172.168.1.101]

TASK [prepare : 添加EPEL仓库] ****************************************************************************************************************************************************************************************************************************************************
changed: [172.168.1.101]
ok: [172.168.1.100]
changed: [172.168.1.102]
changed: [172.168.1.103]

TASK [prepare : 安装基础软件包] *****************************************************************************************************************************************************************************************************************************************************
changed: [172.168.1.100]
changed: [172.168.1.103]
changed: [172.168.1.102]
changed: [172.168.1.101]

@gjmzj
Copy link
Collaborator

gjmzj commented Oct 10, 2018

@klgd 刚测试了确实2.4~2.6都没有问题,感谢PR
@Hello-Linux packages是否写在独立的配置文件,我觉得找个平衡点即可,如果包名实在太多那可以独立出去;目前包不算多,直接写在tasks里面也直观一点

@gjmzj gjmzj merged commit 333b56c into easzlab:dev Oct 10, 2018
@klgd klgd deleted the dev branch October 10, 2018 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants