Posts

Ansible Core Modules and Aliases

  Ansible's core modules are the built-in modules that come with Ansible, providing essential functionality for configuration management, deployment, and orchestration tasks. These modules cover a wide range of tasks, such as managing files, packages, services, and users, as well as handling system configuration and network settings. Core Modules Here are some commonly used core modules in Ansible: File and Directory Management ansible.builtin.copy : Copies files to remote locations. ansible.builtin.file : Manages files and directory properties. ansible.builtin.fetch : Fetches files from remote nodes. ansible.builtin.template : Processes and deploys Jinja2 templates. Package Management ansible.builtin.package : Generic package manager (handles apt , yum , dnf , etc.). ansible.builtin.apt : Manages packages with the apt package manager. ansible.builtin.yum : Manages packages with the yum package manager. ansible.builtin.dnf : Manages packages with the dnf package manager. Service...

Ansible Playbook

Image
  the state : ensure each time we run the playbook the packages are of the latest version. Absent  The absent : does the un-installation or removes the package for the above ansible all -m gather_facts --limit <ip_address_of_host_machine> | grep ansible_distribution we can run this as this one if this is centos host we copy the complete content above and copy paste it below and rewrite the code to install it for centosmachine dnf  | CentOs The package names on Centos is also different that needs to be changed You can improve your ansible script by consolidating multiple packages inside one play. we instead use variable for this one. Now edit the inventory file. host file. There is a small change that we will make in the yaml file. we change apt to package: - Package is a generic package manager which handles all kinds of package