반응형
ANSIBLE 계정 생성 및 삭제
ansible -m command -a "cat /etc/passwd" mongodb | grep devops5
1. 계정 생성
ansible-playbook --ask-pass -u root a_useradd.yml
$ ansible-playbook --ask-pass -u root a_useradd.yml
SSH password:
Output---
PLAY [192.168.56.111,192.168.56.112,192.168.56.113] ****************************
TASK [setup] *******************************************************************
ok: [192.168.56.111]
ok: [192.168.56.112]
ok: [192.168.56.113]
TASK [new account] *************************************************************
changed: [192.168.56.112]
changed: [192.168.56.113]
changed: [192.168.56.111]
PLAY RECAP *********************************************************************
192.168.56.111 : ok=2 changed=1 unreachable=0 failed=0
192.168.56.112 : ok=2 changed=1 unreachable=0 failed=0
192.168.56.113 : ok=2 changed=1 unreachable=0 failed=0
ansible -m command -a "cat /etc/passwd" mongodb | grep devops5
$ ansible -m command -a "cat /etc/passwd" mongodb | grep devops5
...
devops5:x:501:501::/home/devops5:/bin/bash
devops5:x:501:501::/home/devops5:/bin/bash
devops5:x:501:501::/home/devops5:/bin/bash
2. 계정 삭제
ansible-playbook --ask-pass -u root a_userdel.yml
$ ansible-playbook --ask-pass -u root a_userdel.yml
SSH password:
...
PLAY [192.168.56.111,192.168.56.112,192.168.56.113] ****************************
TASK [setup] *******************************************************************
ok: [192.168.56.111]
ok: [192.168.56.113]
ok: [192.168.56.112]
TASK [new account] *************************************************************
changed: [192.168.56.113]
changed: [192.168.56.112]
changed: [192.168.56.111]
PLAY RECAP *********************************************************************
192.168.56.111 : ok=2 changed=1 unreachable=0 failed=0
192.168.56.112 : ok=2 changed=1 unreachable=0 failed=0
192.168.56.113 : ok=2 changed=1 unreachable=0 failed=0
ansible -m command -a "cat /etc/passwd" mongodb | grep devops5
vi a_useradd.yml
---
- hosts: 192.168.56.111,192.168.56.112,192.168.56.113
remote_user: root
vars:
USER_NAME: 'devops5'
tasks:
- name: "new account"
user: name={{ USER_NAME }}
password='$6$r8QrZkp/$nyrCAy3TQVrnHOO7wn0cAhqpgsJUnOOo1r9OLwhjPSaUzEP6yvYNXVC/QR.lLPMZc3bcf3A1Az2QjUsXpWIv41'
#password : P@ssw0rd
vi a_userdel.yml
---
- hosts: 192.168.56.111,192.168.56.112,192.168.56.113
remote_user: root
vars:
USER_NAME: 'devops5'
tasks:
- name: "new account"
user: name={{ USER_NAME }}
state=absent
remove=yes
force=yes
728x90
반응형
'리눅스' 카테고리의 다른 글
[리눅스] Proxy 서버 구축(squid) (0) | 2017.05.26 |
---|---|
리눅스에서 HTTP Proxy Server 설정하기 (0) | 2017.05.26 |
[Ansible ] 일반 계정 생성 (0) | 2017.04.25 |
[리눅스] mongoDB 소스 설치 (0) | 2017.04.24 |
[리눅스] Install MongoDB on CentOS6 or Linux (1) | 2017.04.24 |