
Ansible
debug - to print a message or value
file - to create a folder/file
copy - to copy a file from local and remote host
fetch - to fetch a folder or file from remote to host
slurp - to fetch only the contents of a file
service - to run a service
remote_user - to become/login as a remote user
become: yes - is for getting the privilleges.
become_method - to switch the admin/privillege mode, by default it is sudo.
with_items - when u have to perform same task multiple times
get_url - to download from a url
unarchive - to extract a file
archive - to archive a file or folder
lineinfile - to add a custom line to the end of the file
register - to register a value or an output to file
when - conditional checking. to perform a task based on a condition.
fail - to make the playbook fail based on condition
set_fact - to set a variable on a particular task
block and rescue
- to execute a set of tasks inside a block and if any one of the task
fails, it should call a task inside rescue(like for sending mail wen it
fails)
local_action: to run the task locally (have to give
module name as module: ur module name, run_once : true will make sure
that task is executed only once)
delegate to: is an alternative of local action . you can say the task to be executed in that particular server.
template - is to copy and edit the file at the same time.
loop - to execute the same task multiple times, also to pass multiple arguments
notify - to notify the task in handler ( mainly when a task is completed execute the other)
handler - module like block , can define a set of actions or tasks which needs to be run as a part of notification
find -
Return a list of files based on specific criteria. Multiple criteria
are AND’d together, For Windows targets, use the win_find module
instead.
tags- ansible-playbook example.yml --tags "configuration,packages"
mail- for sending the notification
ping - to ping the server
setup - to collect all the host information
gather_facts - can also be used for the same(setup module)
Commands:
shell-
systemd - to Manage system services
stat - Retrieves facts for a file similar to the linux/unix ‘stat’ command, For Windows targets, use the win_stat module instead.