# Modules Ansible ## Objectifs de certification ### RHCE EX294 (RHEL8) Si vous poursuivez des objectifs de certification voici ceux qui sont suggérés ici : - **2. Maîtrise des composants de base d’Ansible** - 2.2. Modules - 2.3. Variables - 2.4. Facts - 2.8. Utiliser la documentation fournie pour trouver des informations spécifiques aux modules et commandes Ansible - **5. Écriture de scripts pour les tâches d’administration** - 5.2. Créer des scripts shell simples qui exécutent les commandes Ansible ad hoc - **7. Utilisation des modules Ansible** ## 1. Introduction Les modules Ansible sont des “bouts de codes” écrits principalement en Python (mais tout langage supportant les retours JSON est autorisé) pour modifier l’état d’une propriété d’un hôte. Les modules sont invoqués par **l’exécution de tâches** soit directement dans la ligne de commande `ansible` ou dans des livres de jeu avec la commande `ansible-playbook`. ## 2. Documentation des modules Certains d’entre nous trouveront la documentation des modules plus agréable à lire en ligne : [https://docs.ansible.com/ansible/latest/modules/modules\_by\_category.html](https://docs.ansible.com/ansible/latest/modules/modules_by_category.html). Mais on obtient exactement le même résultat hors-ligne, sur la machine de contrôle avec la commande `ansible-doc` : Pour lister les modules :
``` ansible-doc -l ```
Pour appeler directement la documentation d’un module.
``` ansible-doc ```
``` ansible-doc -s ```
Veuillez vous informer sur les modules suivants : - `ansible-doc setup` - `ansible-doc ping` - `ansible-doc lineinfile` - `ansible-doc uri` ## 3. Exécutions de tâches Ad-Hoc La commande `ansible` offre la possibilité d’exécuter des modules ansible de manière “ad-hoc”, c’est à dire tâche par tâche sur un groupe d’hôtes, une sorte de livre de jeux à tâche unique. L’intérêt est de pouvoir exécuter la même tâche en parallèle sur un inventaire (constitué d’un certain nombre de cibles) en tout ou en partie.
``` ansible --help ```
La commande offre ce résultat sur la sortie :
``` Usage: ansible [options] Define and run a single task 'playbook' against a set of hosts ```
En général, la commande s’écrit `ansible` suivie d’un hôte ou d’un groupe d’inventaire suivie `-m nom_de_module` suivie l’option d’argument `-a "clé=valeur clé=valeur clé=valeur"`, par exemple de manière formelle :
``` ansible -m nom_de_module -a "clé=valeur clé=valeur clé=valeur" ```
Trois autres exemples fonctionnels :
``` ansible localhost -m debug -a "msg='Hello World!'" ```
``` ansible localhost -m file -a "path=/tmp/test state=touch" ```
``` ansible localhost -m file -a "path=/tmp/test state=absent" ```
> Attention, l’inventaire doit exister et doit être nourri des hôtes à gérer ! On trouvera aussi des options utiles de la ligne de commande comme celles-ci : - `-b`, `--become` active l’élévation de privilèges (`sudo`) - `-e` qui permet de placer des variables ponctuelles ou un fichier de variables, - `-o` qui offre la sortie standard en une seule ligne, - ou encore `-l`, `--limit` qui permet de limiter la tâche à certains hôtes seulement de l’inventaire, - ou encore `-v` ou `-vvv` pour la verbosité, - `-i` précise le chemin du fichier d’inventaire. Dans les exemples qui précèdent les tâches portent sur l’hôte spécial “localhost” qui n’a pas besoin d’être référencé dans un inventaire. ## 4. Valeurs de retour de l’exécution des tâches et des modules Comme constaté, Ansible génère des valeurs de retour à la suite de l’exécution des tâches et des modules. [Valeurs de retour, Return Values](https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html)
Valeurs de retourSignication de la valeurs de retour
`backup_file` (fichier\_de\_sauvegarde)Pour les modules qui implémentent backup=noyes lors de la manipulation de fichiers, un chemin vers le fichier de sauvegarde créé.
`changed` (modifié)Un *booléen* indiquant si la tâche a dû effectuer des modifications.
`failed` (échoué)Un *booléen* qui indique si la tâche a échoué ou non.
`invocation`Informations sur la manière dont le module a été invoqué.
`msg`Une chaîne avec un message générique relayé à l’utilisateur.
`rc`Certains modules exécutent des utilitaires en ligne de commande ou sont conçus pour exécuter des commandes directement (raw, shell, commande, etc), ce champ contient le ‘code de retour’ de ces utilitaires.
`results`Si cette clé existe, elle indique qu’une boucle était présente pour la tâche et qu’elle contient une liste du module normal’résultat’ par élément.
`skipped` (évité)Un *booléen* qui indique si la tâche a été ignorée ou non.
`stderr`Certains modules exécutent des utilitaires en ligne de commande ou sont conçus pour exécuter des commandes directement (raw, shell, commande, etc), ce champ contient la sortie d’erreur de ces utilitaires.
`stderr_lines`Lorsque `stderr` est retourné, nous fournissons aussi toujours ce champ qui est une liste de chaînes de caractères, un élément par ligne de l’original.
`stdout`Certains modules exécutent des utilitaires en ligne de commande ou sont conçus pour exécuter directement des commandes (raw, shell, commande, etc). Cette zone contient l’édition normale de ces utilitaires.
`stdout_lines`Lorsque `stdout` est retourné, Ansible fournit toujours une liste de chaînes de caractères, chacune contenant un élément par ligne de la sortie originale.
## 5. Modules Linux Les modules Ansible sont donc des “morceaux de code” pour modifier l’état d’une propriété d’un hôte. On recense ici 240 modules utiles pour l’administration d’un système Linux. ### 5.1. Paquets logiciels et repos - [`ansible.builtin.dnf`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dnf_module.html) – Manages packages with the *dnf* package manager - [`ansible.builtin.package`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_module.html) – Generic OS package manager - [`ansible.builtin.package_facts`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_facts_module.html) – package information as facts - [`ansible.builtin.pip`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/pip_module.html) – Manages Python library dependencies - [`ansible.builtin.rpm_key`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/rpm_key_module.html) – Adds or removes a gpg key from the rpm db - [`ansible.builtin.ansible.builtin.yum`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html) – Manages packages with the *yum* package manager - [`ansible.builtin.yum_repository`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_repository_module.html) – Add or remove YUM repositories - [`community.general.alternatives`](https://docs.ansible.com/ansible/latest/collections/community/general/alternatives_module.html) – Manages alternative programs for common commands - [`community.general.apt_rpm`](https://docs.ansible.com/ansible/latest/collections/community/general/apt_rpm_module.html) – apt\_rpm package manager - [`community.general.urpmi`](https://docs.ansible.com/ansible/latest/collections/community/general/urpmi_module.html) – Urpmi manager ### 5.2. Services - [`ansible.builtin.service`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/service_module.html) – Manage services - [`ansible.builtin.service_facts`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/service_facts_module.html) – Return service state information as fact data - [`ansible.builtin.systemd`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html) – Manage services - [`ansible.builtin.sysvinit`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/sysvinit_module.html) – Manage SysV services. ### 5.3. Règles de pare-feu - [`ansible.builtin.iptables`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/iptables_module.html) – Modify iptables rules - [`ansible.posix.firewalld`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/firewalld_module.html) – Manage arbitrary ports/services with firewalld - [`community.general.iptables_state`](https://docs.ansible.com/ansible/latest/collections/community/general/iptables_state_module.html) – Save iptables state into a file or restore it from a file ### 5.4. Systèmes de fichiers - [`ansible.builtin.fetch`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/fetch_module.html) – Fetch files from remote nodes - [`ansible.builtin.file`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html) – Manage files and file properties - [`ansible.builtin.find`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/find_module.html) – Return a list of files based on specific criteria - [`ansible.builtin.stat`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html) – Retrieve file or file system status - [`ansible.posix.acl`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/acl_module.html) – Set and retrieve file ACL information. - [`community.general.xattr`](https://docs.ansible.com/ansible/latest/collections/community/general/xattr_module.html) – Manage user defined extended attributes - [`ansible.builtin.get_url`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html) – Downloads files from HTTP, HTTPS, or FTP to node - [`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html) from git checkouts - [`ansible.builtin.subversion`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/subversion_module.html) – Deploys a subversion repository - [`ansible.builtin.slurp`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/slurp_module.html) – Slurps a file from remote nodes - [`ansible.builtin.uri`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html) – Interacts with webservices - [`ansible.posix.synchronize`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html) – A wrapper around rsync to make common tasks in your playbooks quick and easy ### 5.5. Périphériques de stockage - [`ansible.posix.mount`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html) – Control active and configured mount points - [`community.general.crypttab`](https://docs.ansible.com/ansible/latest/collections/community/general/crypttab_module.html) – Encrypted Linux block devices - [`community.crypto.luks_device`](https://docs.ansible.com/ansible/latest/collections/community/crypto/luks_device_module.html) – Manage encrypted (LUKS) devices - [`community.general.filesystem`](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html) – Makes a filesystem - [`community.general.iso_create`](https://docs.ansible.com/ansible/latest/collections/community/general/iso_create_module.html) – Generate ISO file with specified files or folders - [`community.general.iso_extract`](https://docs.ansible.com/ansible/latest/collections/community/general/iso_extract_module.html) – Extract files from an ISO image - [`community.general.lvg`](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html) – Configure LVM volume groups - [`community.general.lvol`](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html) – Configure LVM logical volumes - [`community.general.open_iscsi`](https://docs.ansible.com/ansible/latest/collections/community/general/open_iscsi_module.html) – Manage iSCSI targets with Open-iSCSI - [`community.general.parted`](https://docs.ansible.com/ansible/latest/collections/community/general/parted_module.html) – Configure block device partitions ### 5.6. Contenus de fichiers - [`ansible.builtin.assemble`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assemble_module.html) – Assemble configuration files from fragments - [`ansible.builtin.blockinfile`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/blockinfile_module.html) – Insert/update/remove a text block surrounded by marker lines - [`ansible.builtin.lineinfile`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html) – Manage lines in text files - [`ansible.builtin.replace`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html) – Replace all instances of a particular string in a file using a back-referenced regular expression - [`ansible.builtin.copy`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html) – Copy files to remote locations - [`ansible.builtin.tempfile`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/tempfile_module.html) – Creates temporary files and directories - [`ansible.builtin.template`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html) – Template a file out to a remote server - [`ansible.posix.patch`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/patch_module.html) – Apply patch files using the GNU patch tool ### 5.7. Archives - [`community.general.archive`](https://docs.ansible.com/ansible/latest/collections/community/general/archive_module.html) – Creates a compressed archive of one or more files or trees - [`ansible.builtin.unarchive`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/unarchive_module.html) copying it from the local machine. ### 5.8. Tâches planifiées - [`ansible.builtin.cron`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html) – Manage cron.d and crontab entries - [`ansible.posix.at`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/at_module.html) – Schedule the execution of a command or script file via the at command - [`community.general.cronvar`](http://docs.ansible.com/ansible/latest/collections/community/general/cronvar_module.html) – Manage variables in crontabs ### 5.9. SSH - [`ansible.builtin.known_hosts`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/known_hosts_module.html) – Add or remove a host from the `known_hosts` file - [`ansible.posix.authorized_key`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html) – Adds or removes an SSH authorized key - [`community.crypto.openssh_cert`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssh_cert_module.html) – Generate OpenSSH host or user certificates. - [`community.crypto.openssh_keypair`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssh_keypair_module.html) – Generate OpenSSH private and public keys. ### 5.10. SELINUX - [`ansible.posix.seboolean`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/seboolean_module.html) – Toggles SELinux booleans - [`ansible.posix.selinux`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/selinux_module.html) – Change policy and state of SELinux - [`community.general.sefcontext`](https://docs.ansible.com/ansible/latest/collections/community/general/sefcontext_module.html) – Manages SELinux file context mapping definitions - [`community.general.selinux_permissive`](https://docs.ansible.com/ansible/latest/collections/community/general/selinux_permissive_module.html) – Change permissive domain in SELinux policy - [`community.general.selogin`](https://docs.ansible.com/ansible/latest/collections/community/general/selogin_module.html) – Manages linux user to SELinux user mapping - [`community.general.seport`](https://docs.ansible.com/ansible/latest/collections/community/general/seport_module.html) – Manages SELinux network port type definitions ### 5.11. Utilisateurs et groupes - [`ansible.builtin.user`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html) – Manage user accounts - [`ansible.builtin.group`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/group_module.html) – Add or remove groups - [`community.general.pam_limits`](https://docs.ansible.com/ansible/latest/collections/community/general/pam_limits_module.html) – Modify Linux PAM limits - [`community.general.pamd`](https://docs.ansible.com/ansible/latest/collections/community/general/pamd_module.html) – Manage PAM Modules ### 5.12. Administration divers - [`ansible.builtin.hostname`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/hostname_module.html) – Manage hostname - [`ansible.builtin.ping`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ping_module.html) – Try to connect to host, verify a usable python and return `pong` on success - [`ansible.builtin.reboot`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/reboot_module.html) – Reboot a machine - [`community.general.shutdown`](https://docs.ansible.com/ansible/latest/collections/community/general/shutdown_module.html) – Shut down a machine - [`ansible.posix.sysctl`](https://docs.ansible.com/ansible/latest/collections/ansible/posix/sysctl_module.html) – Manage entries in sysctl.conf. - [`community.general.locale_gen`](https://docs.ansible.com/ansible/latest/collections/community/general/locale_gen_module.html) – Creates or removes locales ### 5.13. Commandes - [`ansible.builtin.script`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/script_module.html) – Runs a local script on a remote node after transferring it - [`ansible.builtin.command`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html) – Execute commands on targets - [`ansible.builtin.expect`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/expect_module.html) – Executes a command and responds to prompts. - [`ansible.builtin.raw`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/raw_module.html) – Executes a low-down and dirty command - [`ansible.builtin.shell`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html) – Execute shell commands on targets - [`ansible.builtin.pause`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/pause_module.html) – Pause playbook execution - [`ansible.builtin.wait_for`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html) – Waits for a condition before continuing - [`ansible.builtin.wait_for_connection`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_connection_module.html) – Waits until remote system is reachable/usable ### 5.14. Réseau - [`community.general.nmcli`](https://docs.ansible.com/ansible/latest/collections/community/general/nmcli_module.html) – Manage Networking - [`community.general.listen_ports_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/listen_ports_facts_module.html) – Gather facts on processes listening on TCP and UDP ports. - [`community.general.nsupdate`](https://docs.ansible.com/ansible/latest/collections/community/general/nsupdate_module.html) – Manage DNS records. - [`community.general.ipify_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/ipify_facts_module.html) – Retrieve the public IP of your internet gateway - [`community.general.ipinfoio_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/ipinfoio_facts_module.html) – Retrieve IP geolocation facts of a host’s IP address ### 5.15. Informations - [`ansible.builtin.debug`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html) – Print statements during execution - [`ansible.builtin.gather_facts`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/gather_facts_module.html) – Gathers facts about remote hosts - [`ansible.builtin.set_fact`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/set_fact_module.html) – Set host facts from a task - [`ansible.builtin.setup`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/setup_module.html) – Gathers facts about remote hosts - [`ansible.builtin.fail`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/fail_module.html) – Fail with custom message ### 5.16. Modules internes - [`ansible.builtin.add_host`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/add_host_module.html) to the ansible-playbook in-memory inventory - [`ansible.builtin.assert`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assert_module.html) – Asserts given expressions are true - [`ansible.builtin.async_status`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/async_status_module.html) – Obtain status of asynchronous task - [`ansible.builtin.getent`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/getent_module.html) – A wrapper to the unix getent utility - [`ansible.builtin.group_by`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/group_by_module.html) – Create Ansible groups based on facts - [`ansible.builtin.meta`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/meta_module.html) – Execute Ansible ‘actions’ - [`ansible.builtin.set_stats`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/set_stats_module.html) – Set stats for the current ansible run ### 5.17. Include/Import - [`ansible.builtin.import_playbook`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_playbook_module.html) – Import a playbook - [`ansible.builtin.import_role`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_role_module.html) – Import a role into a play - [`ansible.builtin.import_tasks`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_tasks_module.html) – Import a task list - [`ansible.builtin.include`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_module.html) – Include a play or task list - [`ansible.builtin.include_role`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_role_module.html) – Load and execute a role - [`ansible.builtin.include_tasks`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_tasks_module.html) – Dynamically include a task list - [`ansible.builtin.include_vars`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_vars_module.html) – Load variables from files, dynamically within a task ### 5.18. Autres Packagers et gestionnaires de dépendances - [`community.general.bundler`](https://docs.ansible.com/ansible/latest/collections/community/general/bundler_module.html) – Manage Ruby Gem dependencies with Bundler - [`community.general.composer`](https://docs.ansible.com/ansible/latest/collections/community/general/composer_module.html) – Dependency Manager for PHP - [`community.general.cpanm`](https://docs.ansible.com/ansible/latest/collections/community/general/cpanm_module.html) – Manages Perl library dependencies. - [`community.general.django_manage`](https://docs.ansible.com/ansible/latest/collections/community/general/django_manage_module.html) – Manages a Django application. - [`community.general.pear`](https://docs.ansible.com/ansible/latest/collections/community/general/pear_module.html) – Manage pear/pecl packages - [`community.general.easy_install`](https://docs.ansible.com/ansible/latest/collections/community/general/easy_install_module.html) – Installs Python libraries - [`community.general.gem`](https://docs.ansible.com/ansible/latest/collections/community/general/gem_module.html) – Manage Ruby gems - [`community.general.snap`](https://docs.ansible.com/ansible/latest/collections/community/general/snap_module.html) – Manages snaps - [`community.general.make`](https://docs.ansible.com/ansible/latest/collections/community/general/make_module.html) – Run targets in a Makefile - [`community.general.npm`](https://docs.ansible.com/ansible/latest/collections/community/general/npm_module.html) – Manage node.js packages with npm - [`community.general.pip_package_info`](https://docs.ansible.com/ansible/latest/collections/community/general/pip_package_info_module.html) – pip package information - [`community.general.python_requirements_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/python_requirements_facts_module.html) – Show python path and assert dependency versions - [`community.general.python_requirements_info`](https://docs.ansible.com/ansible/latest/collections/community/general/python_requirements_info_module.html) – Show python path and assert dependency versions - [`community.general.yarn`](https://docs.ansible.com/ansible/latest/collections/community/general/yarn_module.html) – Manage node.js packages with Yarn ### 5.19. MySQL - [`community.mysql.mysql_db`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html) – Add or remove MySQL databases from a remote host - [`community.mysql.mysql_info`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_info_module.html) – Gather information about MySQL servers - [`community.mysql.mysql_query`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_query_module.html) – Run MySQL queries - [`community.mysql.mysql_replication`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_replication_module.html) – Manage MySQL replication - [`community.mysql.mysql_user`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_user_module.html) – Adds or removes a user from a MySQL database - [`community.mysql.mysql_variables`](https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_variables_module.html) – Manage MySQL global variables ### 5.20. Docker Containers - [`community.general.docker_compose`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_compose_module.html) – Manage multi-container Docker applications with Docker Compose. - [`community.general.docker_config`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_config_module.html) – Manage docker configs. - [`community.general.docker_container`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_container_module.html) – manage docker containers - [`community.general.docker_container_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_container_info_module.html) – Retrieves facts about docker container - [`community.general.docker_host_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_host_info_module.html) – Retrieves facts about docker host and lists of objects of the services. - [`community.general.docker_image`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_image_module.html) – Manage docker images. - [`community.general.docker_image_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_image_facts_module.html) – Inspect docker images - [`community.general.docker_image_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_image_info_module.html) – Inspect docker images - [`community.general.docker_login`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_login_module.html) – Log into a Docker registry. - [`community.general.docker_network`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_network_module.html) – Manage Docker networks - [`community.general.docker_network_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_network_info_module.html) – Retrieves facts about docker network - [`community.general.docker_node`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_node_module.html) – Manage Docker Swarm node - [`community.general.docker_node_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_node_info_module.html) – Retrieves facts about docker swarm node from Swarm Manager - [`community.general.docker_prune`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_prune_module.html) – Allows to prune various docker objects - [`community.general.docker_secret`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_secret_module.html) – Manage docker secrets. - [`community.general.docker_service`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_service_module.html) – Manage multi-container Docker applications with Docker Compose. - [`community.general.docker_stack`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_stack_module.html) – docker stack module - [`community.general.docker_stack_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_stack_info_module.html) – Return information on a docker stack - [`community.general.docker_stack_task_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_stack_task_info_module.html) – Return information of the tasks on a docker stack - [`community.general.docker_swarm`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_swarm_module.html) – Manage Swarm cluster - [`community.general.docker_swarm_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_swarm_info_module.html) – Retrieves facts about Docker Swarm cluster. - [`community.general.docker_swarm_service`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_swarm_service_module.html) – docker swarm service - [`community.general.docker_swarm_service_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_swarm_service_info_module.html) – Retrieves information about docker services from a Swarm Manager - [`community.general.docker_volume`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_volume_module.html) – Manage Docker volumes - [`community.general.docker_volume_info`](https://docs.ansible.com/ansible/latest/collections/community/general/docker_volume_info_module.html) – Retrieve facts about Docker volumes ### 5.20. LXC/LXD - [`community.general.lxc_container`](https://docs.ansible.com/ansible/latest/collections/community/general/lxc_container_module.html) – Manage LXC Containers - [`community.general.lxca_cmms`](https://docs.ansible.com/ansible/latest/collections/community/general/lxca_cmms_module.html) – Custom module for lxca cmms inventory utility - [`community.general.lxca_nodes`](https://docs.ansible.com/ansible/latest/collections/community/general/lxca_nodes_module.html) – Custom module for lxca nodes inventory utility - [`community.general.lxd_container`](https://docs.ansible.com/ansible/latest/collections/community/general/lxd_container_module.html) – Manage LXD Containers - [`community.general.lxd_profile`](https://docs.ansible.com/ansible/latest/collections/community/general/lxd_profile_module.html) – Manage LXD profiles ### 5.21. LDAP - [`community.general.ldap_attr`](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_attr_module.html) – Add or remove LDAP attribute values - [`community.general.ldap_attrs`](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_attrs_module.html) – Add or remove multiple LDAP attribute values - [`community.general.ldap_entry`](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_entry_module.html) – Add or remove LDAP entries. - [`community.general.ldap_passwd`](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_passwd_module.html) – Set passwords in LDAP. - [`community.general.ldap_search`](https://docs.ansible.com/ansible/latest/collections/community/general/ldap_search_module.html) – Search for entries in a LDAP server ### 5.22. Web Servers - [`community.general.htpasswd`](https://docs.ansible.com/ansible/latest/collections/community/general/htpasswd_module.html) – manage user files for basic authentication - [`community.general.apache2_mod_proxy`](https://docs.ansible.com/ansible/latest/collections/community/general/apache2_mod_proxy_module.html) – Set and/or get members’ attributes of an Apache httpd 2.4 mod\_proxy balancer pool - [`community.general.apache2_module`](https://docs.ansible.com/ansible/latest/collections/community/general/apache2_module_module.html) – Enables/disables a module of the Apache2 webserver. - [`community.general.nginx_status_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/nginx_status_facts_module.html) – Retrieve nginx status facts. - [`community.general.nginx_status_info`](https://docs.ansible.com/ansible/latest/collections/community/general/nginx_status_info_module.html) – Retrieve information on nginx status. ### 5.23. PostgreSQL - [`community.general.postgresql_copy`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_copy_module.html) – Copy data between a file/program and a table - [`community.general.postgresql_db`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_db_module.html) – Add or remove PostgreSQL databases from a remote host. - [`community.general.postgresql_ext`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_ext_module.html) – Add or remove PostgreSQL extensions from a database - [`community.general.postgresql_idx`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_idx_module.html) – Create or drop indexes from a PostgreSQL database - [`community.general.postgresql_info`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_info_module.html) – Gather information about PostgreSQL servers - [`community.general.postgresql_lang`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_lang_module.html) – Adds, removes or changes procedural languages with a PostgreSQL database - [`community.general.postgresql_membership`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_membership_module.html) – Add or remove PostgreSQL roles from groups - [`community.general.postgresql_owner`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_owner_module.html) – Change an owner of PostgreSQL database object - [`community.general.postgresql_pg_hba`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_pg_hba_module.html) – Add, remove or modify a rule in a pg\_hba file - [`community.general.postgresql_ping`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_ping_module.html) – Check remote PostgreSQL server availability - [`community.general.postgresql_privs`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_privs_module.html) – Grant or revoke privileges on PostgreSQL database objects - [`community.general.postgresql_publication`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_publication_module.html) – Add, update, or remove PostgreSQL publication - [`community.general.postgresql_query`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_query_module.html) – Run PostgreSQL queries - [`community.general.postgresql_schema`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_schema_module.html) – Add or remove PostgreSQL schema - [`community.general.postgresql_sequence`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_sequence_module.html) – Create, drop, or alter a PostgreSQL sequence - [`community.general.postgresql_set`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_set_module.html) – Change a PostgreSQL server configuration parameter - [`community.general.postgresql_slot`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_slot_module.html) – Add or remove replication slots from a PostgreSQL database - [`community.general.postgresql_subscription`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_subscription_module.html) – Add, update, or remove PostgreSQL subscription - [`community.general.postgresql_table`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_table_module.html) – Create, drop, or modify a PostgreSQL table - [`community.general.postgresql_tablespace`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_tablespace_module.html) – Add or remove PostgreSQL tablespaces from remote hosts - [`community.general.postgresql_user`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_user_module.html) from a PostgreSQL server instance - [`community.general.postgresql_user_obj_stat_info`](https://docs.ansible.com/ansible/latest/collections/community/general/postgresql_user_obj_stat_info_module.html) – Gather statistics about PostgreSQL user objects ### 5.24. RHSM Red Hat software channels - [`community.general.redhat_subscription`](https://docs.ansible.com/ansible/latest/collections/community/general/redhat_subscription_module.html) – Manage registration and subscriptions to RHSM using the `subscription-manager` command - [`community.general.rhn_channel`](https://docs.ansible.com/ansible/latest/collections/community/general/rhn_channel_module.html) – Adds or removes Red Hat software channels - [`community.general.rhn_register`](https://docs.ansible.com/ansible/latest/collections/community/general/rhn_register_module.html) – Manage Red Hat Network registration using the `rhnreg_ks` command - [`community.general.rhsm_release`](https://docs.ansible.com/ansible/latest/collections/community/general/rhsm_release_module.html) – Set or Unset RHSM Release version - [`community.general.rhsm_repository`](https://docs.ansible.com/ansible/latest/collections/community/general/rhsm_repository_module.html) – Manage RHSM repositories using the subscription-manager command ### 5.25. Fichiers ini, csv, xml - [`community.general.read_csv`](https://docs.ansible.com/ansible/latest/collections/community/general/read_csv_module.html) – Read a CSV file - [`community.general.git_config`](https://docs.ansible.com/ansible/latest/collections/community/general/git_config_module.html) – Read and write git configuration - [`community.general.ini_file`](https://docs.ansible.com/ansible/latest/collections/community/general/ini_file_module.html) – Tweak settings in INI files - [`community.general.xml`](https://docs.ansible.com/ansible/latest/collections/community/general/xml_module.html) – Manage bits and pieces of XML files or strings ### 5.26. Gestion des processus et du noyau - [`community.general.capabilities`](https://docs.ansible.com/ansible/latest/collections/community/general/capabilities_module.html) – Manage Linux capabilities - [`community.general.modprobe`](https://docs.ansible.com/ansible/latest/collections/community/general/modprobe_module.html) – Load or unload kernel modules - [`community.general.pids`](https://docs.ansible.com/ansible/latest/collections/community/general/pids_module.html) – Retrieves process IDs list if the process is running otherwise return empty list ### 5.27. Surveillance - [`community.general.snmp_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/snmp_facts_module.html) – Retrieve facts for a device using SNMP - [`community.general.syslogger`](https://docs.ansible.com/ansible/latest/collections/community/general/syslogger_module.html) – Log messages in the syslog - [`community.general.mail`](https://docs.ansible.com/ansible/latest/collections/community/general/mail_module.html) – Send an email ### 5.28. XFS / ZFS - [`community.general.xfs_quota`](https://docs.ansible.com/ansible/latest/collections/community/general/xfs_quota_module.html) – Manage quotas on XFS filesystems - [`community.general.zfs`](https://docs.ansible.com/ansible/latest/collections/community/general/zfs_module.html) – Manage zfs - [`community.general.zfs_delegate_admin`](https://docs.ansible.com/ansible/latest/collections/community/general/zfs_delegate_admin_module.html) - [`community.general.zfs_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/zfs_facts_module.html) – Gather facts about ZFS datasets. - [`community.general.zpool_facts`](https://docs.ansible.com/ansible/latest/collections/community/general/zpool_facts_module.html) – Gather facts about ZFS pools. ### 5.29. Debian/Ubuntu - [`ansible.builtin.apt`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html) – Manages apt-packages - [`ansible.builtin.apt_key`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_key_module.html) – Add or remove an apt key - [`ansible.builtin.apt_repository`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_repository_module.html) – Add and remove APT repositories - [`ansible.builtin.dpkg_selections`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dpkg_selections_module.html) – Dpkg package selection selections - [`ansible.builtin.debconf`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debconf_module.html) – Configure a .deb package - [`community.general.apt_repo`](https://docs.ansible.com/ansible/latest/collections/community/general/apt_repo_module.html) – Manage APT repositories via apt-repo - [`community.general.apt_rpm`](https://docs.ansible.com/ansible/latest/collections/community/general/apt_rpm_module.html) – apt\_rpm package manager - [`community.general.dpkg_divert`](https://docs.ansible.com/ansible/latest/collections/community/general/dpkg_divert_module.html) – Override a debian package’s version of a file - [`community.general.interfaces_file`](https://docs.ansible.com/ansible/latest/collections/community/general/interfaces_file_module.html) – Tweak settings in /etc/network/interfaces files - [`community.general.ufw`](https://docs.ansible.com/ansible/latest/collections/community/general/ufw_module.html) – Manage firewall with UFW ### 5.30. Crypto TLS - [`community.crypto.acme_account`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_account_module.html#ansible-collections-community-crypto-acme-account-module) – Create, modify or delete ACME accounts - [`community.crypto.acme_account_facts`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_account_facts_module.html#ansible-collections-community-crypto-acme-account-facts-module) – Retrieves information on ACME accounts - [`community.crypto.acme_account_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_account_info_module.html#ansible-collections-community-crypto-acme-account-info-module) – Retrieves information on ACME accounts - [`community.crypto.acme_certificate`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_certificate_module.html#ansible-collections-community-crypto-acme-certificate-module) – Create SSL/TLS certificates with the ACME protocol - [`community.crypto.acme_certificate_revoke`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_certificate_revoke_module.html#ansible-collections-community-crypto-acme-certificate-revoke-module) – Revoke certificates with the ACME protocol - [`community.crypto.acme_challenge_cert_helper`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_challenge_cert_helper_module.html#ansible-collections-community-crypto-acme-challenge-cert-helper-module) – Prepare certificates required for ACME challenges such as `tls-alpn-01` - [`community.crypto.acme_inspect`](https://docs.ansible.com/ansible/latest/collections/community/crypto/acme_inspect_module.html#ansible-collections-community-crypto-acme-inspect-module) – Send direct requests to an ACME server - [`community.crypto.certificate_complete_chain`](https://docs.ansible.com/ansible/latest/collections/community/crypto/certificate_complete_chain_module.html#ansible-collections-community-crypto-certificate-complete-chain-module) – Complete certificate chain given a set of untrusted and root certificates - [`community.crypto.get_certificate`](https://docs.ansible.com/ansible/latest/collections/community/crypto/get_certificate_module.html#ansible-collections-community-crypto-get-certificate-module) – Get a certificate from a host:port - [`community.crypto.openssl_certificate`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_certificate_module.html#ansible-collections-community-crypto-openssl-certificate-module) – Generate and/or check OpenSSL certificates - [`community.crypto.openssl_certificate_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_certificate_info_module.html#ansible-collections-community-crypto-openssl-certificate-info-module) – Provide information of OpenSSL X.509 certificates - [`community.crypto.openssl_csr`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_csr_module.html#ansible-collections-community-crypto-openssl-csr-module) – Generate OpenSSL Certificate Signing Request (CSR) - [`community.crypto.openssl_csr_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_csr_info_module.html#ansible-collections-community-crypto-openssl-csr-info-module) – Provide information of OpenSSL Certificate Signing Requests (CSR) - [`community.crypto.openssl_dhparam`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_dhparam_module.html#ansible-collections-community-crypto-openssl-dhparam-module) – Generate OpenSSL Diffie-Hellman Parameters - [`community.crypto.openssl_pkcs12`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_pkcs12_module.html#ansible-collections-community-crypto-openssl-pkcs12-module) – Generate OpenSSL PKCS#12 archive - [`community.crypto.openssl_privatekey`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_privatekey_module.html#ansible-collections-community-crypto-openssl-privatekey-module) – Generate OpenSSL private keys - [`community.crypto.openssl_privatekey_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_privatekey_info_module.html#ansible-collections-community-crypto-openssl-privatekey-info-module) – Provide information for OpenSSL private keys - [`community.crypto.openssl_publickey`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_publickey_module.html#ansible-collections-community-crypto-openssl-publickey-module) – Generate an OpenSSL public key from its private key. - [`community.crypto.openssl_signature`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_signature_module.html#ansible-collections-community-crypto-openssl-signature-module) – Sign data with openssl - [`community.crypto.openssl_signature_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/openssl_signature_info_module.html#ansible-collections-community-crypto-openssl-signature-info-module) – Verify signatures with openssl - [`community.crypto.x509_certificate`](https://docs.ansible.com/ansible/latest/collections/community/crypto/x509_certificate_module.html#ansible-collections-community-crypto-x509-certificate-module) – Generate and/or check OpenSSL certificates - [`community.crypto.x509_certificate_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/x509_certificate_info_module.html#ansible-collections-community-crypto-x509-certificate-info-module) – Provide information of OpenSSL X.509 certificates - [`community.crypto.x509_crl`](https://docs.ansible.com/ansible/latest/collections/community/crypto/x509_crl_module.html#ansible-collections-community-crypto-x509-crl-module) – Generate Certificate Revocation Lists (CRLs) - [`community.crypto.x509_crl_info`](https://docs.ansible.com/ansible/latest/collections/community/crypto/x509_crl_info_module.html#ansible-collections-community-crypto-x509-crl-info-module) – Retrieve information on Certificate Revocation Lists (CRLs) ## 6. Modules Réseau Les modules Ansible pour l’automation du réseau sont désignés par le constructeur de l’OS suivi d’un nom de module : - `*_facts` : récupère des facts - `*_command` : exécute des commandes en mode privilège - `*_config` : exécute des commandes en mode de configuration Selon le nom des plateformes : - Arista EOS = `eos_*` - Cisco IOS/IOS-XE = `ios_*` - Cisco NX-OS = `nxos_*` - Cisco IOS-XR = `iosxr_*` - Juniper Junos = `junos_*` - VyOS = `vyos_*` Mais on trouve aussi un grand nombre des modules spécialisés. ## 7. Modules Windows … ## 8. Modules VMWare … ## 9. Développement de modules [Développement de modules](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#developing-modules-general) Exemple de développement d’un module simple.