centos 如何使此ansible chkconfig任务等幂?

7gyucuyw  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(71)

在我的剧本中,我有一个类似于这样的ansible任务,要在centos服务器上运行:

- name: Enable services for automatic start
     action: command /sbin/chkconfig {{ item }} on
     with_items:
       - nginx
       - postgresql

字符串
每次运行此任务时都会更改。如何使此任务通过幂等性测试?

wrrgggsh

wrrgggsh1#

最好的选择是将enabled=true与服务模块一起使用:

- name: Enable services for automatic start
  service:
    name: "{{ item }}"
    enabled: true
  loop:
    - nginx
    - postgresql

字符串
希望对你有帮助。

相关问题