반응형
linux ssh를 통해 user를 생성 하고 sudo 권한을 추가
---
- name: "user add"
hosts: all
# sudo 권한 획득
become: true
tasks:
- name: "user add"
user:
name: "{{ add_user_name }}"
password: "{{ upassword | password_hash('sha512') }}"
shell: "/bin/bash"
- name: "Add user to sudoers"
lineinfile:
dest: /etc/sudoers
regexp: "{{ add_user_name }} ALL"
line: "{{ add_user_name }} ALL=(ALL) NOPASSWD: ALL"
state: present
#vars:
# add_user_name: test3
# upassword: test1212
반응형
'Automation Tools > Ansible' 카테고리의 다른 글
8.3 ansible | [playbook] centos6 yum repository 변경 (0) | 2021.03.16 |
---|---|
8.2 ansible | [playbook] Linux service 상태 변경 (0) | 2021.03.16 |
7. ansible inventory 설정 과 playbook 실행 (0) | 2021.03.16 |
6. ansible | Docker jenkins 설치 (0) | 2021.03.16 |
5. ansible 예약 변수(ansible_facts) (0) | 2021.03.16 |