Difference between revisions of "Ansible modules"

From wikieduonline
Jump to navigation Jump to search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Ansible]] modules<ref>https://docs.ansible.com/ansible/latest/modules/modules_by_category.html</ref> add new capabilities to Ansible and is a core component of the software, as of September 2019 there are more than 2.800 modules available: <code>ansible-doc --list</code>. For example you can [[manage AWS infrastructure using Ansible]], execute commands with <code>shell</code> module or collect information using <code>setup</code><ref>https://docs.ansible.com/ansible/latest/modules/setup_module.html</ref> module.
+
[[Ansible]] modules<ref>https://docs.ansible.com/ansible/latest/modules/modules_by_category.html</ref> add new capabilities to Ansible and is a core component of the software, as of September 2019 there are more than 2.800 modules available: <code>[[ansible-doc --list]]</code>. For example you can [[manage AWS infrastructure using Ansible]], execute commands with <code>shell</code> module or collect information using <code>setup</code><ref>https://docs.ansible.com/ansible/latest/modules/setup_module.html</ref> module.
 
* <code>ansible -m setup SERVER_NAME</code> will collect information from your system
 
* <code>ansible -m setup SERVER_NAME</code> will collect information from your system
 
* <code>ansible -m setup SERVER_NAME -a 'filter=ansible_distribution'</code>. Collect just OS.
 
* <code>ansible -m setup SERVER_NAME -a 'filter=ansible_distribution'</code>. Collect just OS.
  
  
==Modules==
+
== Modules ==
 
* <code>apt_repository</code>: [[Ansible playbook: Add a repository]]
 
* <code>apt_repository</code>: [[Ansible playbook: Add a repository]]
 
* <code>[[docker compose]]</code>: New in version 2.1 and was call docker_service before [[Ansible 2.8]]
 
* <code>[[docker compose]]</code>: New in version 2.1 and was call docker_service before [[Ansible 2.8]]
Line 15: Line 15:
 
** <code>[[shell:]]</code>, allow to use shell functionalities such as redirection.
 
** <code>[[shell:]]</code>, allow to use shell functionalities such as redirection.
 
** <code>[[raw:]]</code>, do not require python on remote system<ref>https://www.unixarena.com/2018/07/ansible-command-vs-shell-vs-raw-modules.html/</ref>
 
** <code>[[raw:]]</code>, do not require python on remote system<ref>https://www.unixarena.com/2018/07/ansible-command-vs-shell-vs-raw-modules.html/</ref>
 +
 
* <code>[[gather_facts]]</code>, <code>[[lineinfile]]</code>, <code>[[package]]</code>, <code>[[user:]]</code>, <code>group</code>, <code>mount</code>, <code>git</code>, <code>[[docker]]</code><ref>https://docs.ansible.com/ansible/2.6/modules/docker_module.html</ref>, <code>[[docker_compose]]</code> <ref>https://docs.ansible.com/ansible/latest/modules/docker_compose_module.html</ref> and <code>mail</code> modules, <ref>https://medium.com/@tcij1013/ten-useful-ansible-modules-83fb6fb2d45e</ref> see all of them by category: https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
 
* <code>[[gather_facts]]</code>, <code>[[lineinfile]]</code>, <code>[[package]]</code>, <code>[[user:]]</code>, <code>group</code>, <code>mount</code>, <code>git</code>, <code>[[docker]]</code><ref>https://docs.ansible.com/ansible/2.6/modules/docker_module.html</ref>, <code>[[docker_compose]]</code> <ref>https://docs.ansible.com/ansible/latest/modules/docker_compose_module.html</ref> and <code>mail</code> modules, <ref>https://medium.com/@tcij1013/ten-useful-ansible-modules-83fb6fb2d45e</ref> see all of them by category: https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
  
Line 23: Line 24:
 
* <code>[[community.general.filesystem]]</code>
 
* <code>[[community.general.filesystem]]</code>
 
* <code>[[community.general.postgresql_db_module]]</code>
 
* <code>[[community.general.postgresql_db_module]]</code>
 +
 +
* [[copy]]
  
 
== [[Examples of Ansible execution modules]] ==
 
== [[Examples of Ansible execution modules]] ==
Line 33: Line 36:
 
* [[Ansible plugins]]
 
* [[Ansible plugins]]
 
* <code>[[ansible-galaxy collection install]]</code>
 
* <code>[[ansible-galaxy collection install]]</code>
[[boto3 required for this module]]
+
* <code>[[boto3 required for this module]]</code>
 +
* <code>[[copy (Windows)]]</code>
 +
* <code>[[amazon.aws]]</code>
  
 
== See also ==
 
== See also ==

Latest revision as of 13:39, 18 April 2023

Ansible modules[1] add new capabilities to Ansible and is a core component of the software, as of September 2019 there are more than 2.800 modules available: ansible-doc --list. For example you can manage AWS infrastructure using Ansible, execute commands with shell module or collect information using setup[2] module.

  • ansible -m setup SERVER_NAME will collect information from your system
  • ansible -m setup SERVER_NAME -a 'filter=ansible_distribution'. Collect just OS.


Modules[edit]

  • Execution modules:
    • command:, default for ad-hoc commands, bypasses the shell so won’t be impacted by local shell variables.
    • shell:, allow to use shell functionalities such as redirection.
    • raw:, do not require python on remote system[3]

Examples of Ansible execution modules[edit]

Related terms[edit]

See also[edit]

  • https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
  • https://docs.ansible.com/ansible/latest/modules/setup_module.html
  • https://www.unixarena.com/2018/07/ansible-command-vs-shell-vs-raw-modules.html/
  • https://docs.ansible.com/ansible/2.6/modules/docker_module.html
  • https://docs.ansible.com/ansible/latest/modules/docker_compose_module.html
  • https://medium.com/@tcij1013/ten-useful-ansible-modules-83fb6fb2d45e
  • Advertising: