티스토리 뷰

반응형

엔서블 사용할 전용 유저를 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  -> 체크 모드는 확인만 하고 적용은 하지 않는다

 

command : ansible-playbook sudoadd.yml -u fendys -k -K

* 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"
반응형

'ansible' 카테고리의 다른 글

ansible key copy  (0) 2021.08.05
[ansible] file 내용 변경하기  (0) 2020.02.22
[Ansible] How to ansible install  (0) 2019.11.22
[Ansible] file modify  (0) 2019.08.01
[Ansible] userdel on linux  (0) 2019.07.19