Ansible Step2
How to search modules?
ansible-doc -l | more
Grep modules which are in the name of 'users'
ansible-doc -l |grep -i users
Among all listed users releated modules, if i want to list the available options on any one of the module eg: 'user'
ansible-doc user
Sample execution of user creation command using ansible:
ansible all -m user -a "name=mani password=Rhel1234"
Here -m is moduel and -a is an Argument
Installing httpd (apache) service using ad-hoc command mode in ansible
ansible all -a "yum -y install httpd"
Here -a is an argument
Removing httpd (apache) service using ad-hoc command mode in ansible
ansible all -a "yum -y remove httpd"
Here -a is an argument
Above install & remove commands are performed using '-a' argument but same can be done using '-m' module and '-a' argument, below the example
Install httpd:
ansible all -m yum -a "name=httpd state=present"
note state=present means if not exist then install
Remove httpd:
ansible all -m yum -a "name=httpd state=absent"
note state=absent means if it exist then uninstall
Comments
Post a Comment