Some Usable Adhoc commands:
================================
Creating a file on all remote clients
# ansible all –m file –a “path=/home/vishnu/vishnu1 state=touch mode=700”
Deleting a file on all remote clients
# ansible all –m file –a “path=/home/vishnu/vishnu1 state=absent”
Copying a file to remote clients
# ansible all –m copy –a “src=/tmp/vishnu2 dest=/home/vishnu/vishnu2”
Installing package (telnet and httpd-manual)
# ansible all –m yum –a “name=telnet state=present”
# ansible all –m yum –a “name=httpd-manual state=present”.
Starting httpd package service
# ansible all –m service –a “name=httpd state=started”
Start httpd and enable at boot time
# ansible all –m service –a “name=httpd state=started enabled=yes”
Checking httpd service status on remote client
# ansible all –m shell -a “systemctl status httpd”
Remove httpd package
# ansible all –m yum –a “name=httpd state=absent”
OR
# ansible all –m shell -a “yum remove httpd”.
Creating a user on remote clients
# ansible all –m user –a “name=appu home=/home/appu shell=/bin/bash state=present”
To add a user to a different group
# ansible all –m user –a “name=appu group=vishnu”
Deleting a user on remote clients
# ansible all –m user –a “name=appu home=/home/appu shell=/bin/bash state=absent”
OR
# ansible all –m shell –a “userdel appu”
Getting system information from remote clients
# ansible all –m setup
You can run commands on the remote host without a shell module e.g. reboot client1
# ansible client1 –a “/sbin/reboot”
No comments:
Post a Comment