Ansible ad-hoc commands will do a quick task but do not want to save that command for later. In below commands “-a” indicates the ad-hoc command.
To see the list of nodes from the master ad-hoc commands.
ansible ubnt –m command –a ls/
To create a demo file in node2 from the server using ad-hoc commands.
#ansible cent –m raw –a ‘touch /tmp/demo.txt’
To install Java in node2 from the server using ad-hoc commands.
# ansible cent –m raw -a ‘yum install –y java’ #ansible cent -m yum -a ‘name=java state=latest’
To start/manage services by using ad-hoc commands
#ansible cent -m service -a ‘name=httpd state=started/restarted’
To copy a file from ansible server to nodes by using ad-hoc commands.
#ansible all –m copy -a “src= ‘/root/devops.txt’ dest=’/tmp/devops.txt’”
To create a file by using ad-hoc commands
#ansible all –m file -a “name=/opt/sample.txt state=touch”
To remove a file by using ad-hoc commands
#ansible all –m file -a “name=/opt/sample.txt state=absent”
To create a directory by using ad-hoc commands
#ansible all –m file -a “name=/opt/devops state=directory”
Latest posts by admin (see all)
- Install and Running Supervisord in virtualenv python 2.7 - January 24, 2019
- Urgent fix: Briefly unavailable for scheduled maintenance. Check back in a minute. - January 22, 2019
- Change WordPress post date format to time ago - January 21, 2019