--- - hosts: all sudo: yes tasks: - name: add a new user user: name=hpscript state=absent
Whether the account should exist or not, taking action if the state is different from what is stated.
[vagrant@host ~]$ ansible-playbook pbook.yml
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and
make sure become_method is ‘sudo’ (default).
This feature will be removed in a
future release. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [192.168.43.52]
ok: [192.168.43.53]
TASK [add a new user] **********************************************************
changed: [192.168.43.53]
changed: [192.168.43.52]
PLAY RECAP *********************************************************************
192.168.43.52 : ok=2 changed=1 unreachable=0 failed=0
192.168.43.53 : ok=2 changed=1 unreachable=0 failed=0
ssh接続する
[vagrant@host ~]$ ssh web
Last login: Tue Oct 2 18:17:56 2018 from 192.168.43.51
[vagrant@web ~]$ cat /etc/passwd
ぬお、hpscriptが居なくなっている! すげーーーーーーーー