ansible
[Ansible] ansible /etc/sudoers line 추가하기
fendys
2020. 2. 21. 23:56
반응형
엔서블 사용할 전용 유저를 sudoers에 nopasswd유저로 등록 하면 "become: true"를 사용하면 root로 실행이 불가능 할 시에 일반 유저를 사용 주체로 만들고 sudo를 사용하게 하면 일반유저로도 엔서블을 이용한 제어가 가능하다.
---
- hosts: all
become: true
tasks:
- name: ansible user nopassword sudo set
lineinfile:
path: /etc/sudoers
line: "fendys ALL=(ALL) NOPASSWD: ALL"
state: present
backup: yes
# check_mode: yes -> 체크 모드는 확인만 하고 적용은 하지 않는다
* hostallow 추가 내역
---
- name: add hosts.allow BIDC NEW Chakra
lineinfile:
path: /etc/hosts.allow
state: present
line: '{{ item }}'
backup: yes
with_items:
- "#### add new line ###"
- "sshd : 192.168.0.1,192.168.0.2"
반응형