Ansible Modules
Copy
Command
Ansible-doc
setup module : This module is automatically called by the playbooks to gather useful variables about remote hosts that can be used on playbooks .
it can also be executed directly by /usr/bin/ansible to check what variables are available to the host.
ansible centos1 -m setup
ansible centos1 -m setup | more
File Module
This allows you to used for files, symlinks links and directory manupulation
ansible all -m file -a 'path=/tmp/test.txt state=touch'
ansible all -m file -a 'path=/tmp/test.txt state=touch mode=600'
COPY Module
touch /temp/x
ansible all -m copy -a 'src=tmp/x dest=/tmp/x'
we can also use copy to copy files from the remote to the remote
ansible all -m copy -a 'remote_src=yes src=/temp/x dest=/temp/x'
COMMAND Module
ansible all -m command -a 'hostname' -o
command module is the default modules in ansible commands the same command can be achieved with mentioning it is command - because it the default command
ansible all -a 'hostname' -o
ansible all -m command -a 'id' // unix command of id
or
ansible all -a 'id'
features of the command module it creates and removes variable
ansible all -a 'touch /tmp/test_copy_module creates=/tmp/test_copy_module'
creates=/tmp/test_copy_module' This command tells it what is it creating and it this run again it identifies that the file already exist and skips the action.
For removing
ansible all -a 'rm /tmp/test_copy_module removes= /tmp/test_copy_module'
ansible all -m file -a '/tmp/ansible_modules.txt state=touch mode=600'
Fetching
ansible centos1 -m fetch -a 'src=/tmp/ansible_module.txt dest=/tmp/ansible_module.txt'
ansible-doc file -- online docs


Comments
Post a Comment