Is it safe to edit /etc/sudoers with the Ansible “lineinfile” module?

前端 未结 5 2370
长情又很酷
长情又很酷 2021-02-20 04:08

I want to change sudo session timeout according to this answer. I can edit ordinary file:

lineinfile:
  path: /etc/sudoers
  regexp: ^Defaults  env_reset
  line:         


        
5条回答
  •  醉话见心
    2021-02-20 04:50

    I think what you are missing is that in order to edit /etc/sudoers you need sudo-access. To do this in Ansible, you just need to add the become flag.

    name: Change Sudo Timeout
    become: yes
    lineinfile:
      path: /etc/sudoers
      regexp: ^Defaults  env_reset
      line: Defaults  env_reset,timestamp_timeout=60
    

提交回复
热议问题