Ansible Ad-Hoc Commands – 1

# ansible all -i hosts –list-hosts (To see all hosts in inventory file named hosts) # ansible rl6 -i hosts –list-hosts (To see hosts of host group named rl6 created in inventory) # ansible ungrouped -i hosts –list-hosts (To see ungrouped hosts) # ansible rhel -i hosts –list-hosts (To see group parent to contains children […]

Ansible playbook to delete the user after taking backup of home directory of user

If you have user on multiple servers and want to delete them by taking backup of home directory. You can use below Ansible playbook. This playbook is running by root user. # cat delete_user.yml ## Delete user "test_user" from servers — – hosts: db-hosts remote_user: root gather_facts: no tasks: – name: Take backup of home […]