Cheat Sheets of Ansible commands
Cheat Sheets of Ansible commands
The following commands are utilized in Ansible, which helps you to achieve the required output, for example,
- To install EPEL repo on Centos/RHEL frameworks.
[root@ansible-server ~]# sudo yum introduce epel-release
- For installing the Ansible bundle on Centos/RHEL frameworks.
[root@ansible-server ~]# sudo yum install - y ansible
- For updating the bundles or packages on Debian/Ubuntu frameworks. Use the following command.
$ sudo apt update
- To install the product properties-basic bundle on Debian/Ubuntu frameworks.
$ sudo apt install software-properties-common
- On Debian/Ubuntu frameworks, if you want to install Ansible individual package chronicle. You must follow the given command.
$ sudo apt-add-repository ppa:ansible/ansible
- For installing Ansible on Debian/Ubuntu frameworks.
$ sudo apt update $ sudo apt install ansible
- For providing a ping command on each server characterized in the inventory file named hosts.
[root@ansible-server test_ansible]# ansible - i hosts all - m ping
- To give the ping command only on hostB.
[root@ansible-server test_ansible]# ansible - i hosts all - m ping - limit hostB
- For duplicating a document named "testhellofile" on every host in the inventory record.
[root@ansible-server test_ansible]# ansible - i hosts all - m copy - a "src=/root/test_ansible/testhellofile dest=/tmp/testhellofile"
- For installing the ncdu bundle on each host.
[root@ansible-server test_ansible]# ansible - i hosts all - m yum - a 'name=ncdu state=present'
- For eliminating the ncdu bundle from each host.
[root@ansible-server test_ansible]# ansible - i hosts all - m yum - a 'name=ncdu state=absent'
- For manufacturing the structure of a directory for the role named roleA.
[root@ansible-server test2]# ansible-galaxy system init roleA
- For executing the pl1.yml playbook.
[root@ansible-server test_ansible]# ansible-playbook - i hosts pl1.yml - check
- For executing a pl1.yml playbook with pass key verification for each host.
[root@ansible-server test_ansible]# ansible-playbook - i hosts pl1.yml – k
- Includes the host key for the repo url if not included yet
-- accept-host-key
- Request su pass key (deplored, use become)
-- ask-su-pass
- Request sudo pass key (deplored, use become)
-- ask-su-pass
- Request vault pass key
-- ask-vault-pass
- Try not to roll out any improvements; instead, attempt to anticipate a portion of the progressions that may happen.
-- check
- Altered records in the working repository will be disposed of
-- clean
- Do a full clone, rather than a shallow one.
-- full
- Yields a list of communicating hosts that do not execute anything.
-- list-hosts
- Utilize this record to confirm the association
-- private-key, -- key-file
- Purge checkout after playbook run
-- purge
- Determine additional contentions to pass to SCP just (for example -I)
-- scp-extra-args <SCP_EXTRA_ARGS>
- Determine additional contentions to pass to SFTP just (for example - f, - l)
-- sftp-extra-args <SFTP_EXTRA_ARGS>
- It focuses on the execution of plays and tasks whose tags do not coordinate with these features.
-- skip-tags
- Indicate normal contentions to pass to sftp/scp/ssh (for example ProxyCommand)
-- ssh-regular args <SSH_COMMON_ARGS>
- Indicate additional contentions to pass to ssh just (for example - R)
-- ssh-extra-args <SSH_EXTRA_ARGS>
- Submodules will follow the most recent changes. This is comparable to determining the – remote flag to git submodule update.
-- track-subs
- The vault character to utilize
-- vault-id
- Vault password file
-- vault-password-file
- Confirm GPG mark of checked out to commit if it crashes while executing the playbook. This needs the relating VCS module to help with such kind of activity.
-- verify-commit
- Show the program's rendition number and exit
-- version
- Branch/tag/focus on checkout. Defaults to conduct of archive module.
- C <CHECKOUT>, -- checkout <CHECKOUT>
- Request benefit enhancing password
- K, -- ask-become-pass
- Prepend colon-isolated path(s) to module library (default=[u'/root/.ansible/plugins/modules',u'/usr/share/ansible/plugins/modules'])
- M, -- module-way
- Supersede the association timeout in a flash (default=10)
- T <TIMEOUT>, -- timeout <TIMEOUT>
- URL of the playbook repository
- U <URL>, -- url <URL>
- Connection type to utilize (default=smart)
- c <CONNECTION>, -- connection <CONNECTION>
- Catalog to checkout repository to
- d <DEST>, -- directory <DEST>
- Set extra factors as key=value or YAML/JSON, if the filename starts with @
- e, -- extra-vars
- Run the playbook regardless of whether the storehouse couldn't be refreshed
- f, -- force
- Show this assistance message and exit.
- h, -- help
- Determine the inventory host way or comma isolated host list. - inventory-file is belittled
- I, -- inventory, -- inventory-file
- Request association password
- k, -- ask-pass
- Further cutoff chose hosts to an extra example.
- l <SUBSET>, -- limit <SUBSET>
- Ansible will use the repository module name to look at the repo. The default is git.
- m <MODULE_NAME>, -- module-name <MODULE_NAME>
- Possibly run the playbook if the vault has been refreshed.
- o, -- only-if-changed
- Sleep for irregular span (among 0 and n number of seconds) before beginning. Sleep is a helpful method to scatter git demands.
- s <SLEEP>, -- sleep <SLEEP>