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:

  1. 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.
  2. 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.
  3. Service Management

    • ansible.builtin.service: Manages services (start, stop, restart, enable, disable).
    • ansible.builtin.systemd: Manages systemd services.
  4. User and Group Management

    • ansible.builtin.user: Manages user accounts.
    • ansible.builtin.group: Manages groups.
  5. System and Network Configuration

    • ansible.builtin.command: Executes commands on remote nodes.
    • ansible.builtin.shell: Executes shell commands on remote nodes.
    • ansible.builtin.sysctl: Manages sysctl parameters.
  6. File System and Storage

    • ansible.builtin.mount: Manages file system mount points.
    • ansible.builtin.parted: Manages disk partitions.

Aliases

In Ansible, an alias is a way to reference a module by a different name. The ansible.builtin namespace is the standard namespace for built-in modules in Ansible. This makes it clear that the module is a built-in, core module rather than one from a collection or third-party source.

Examples of Core Modules and Their Aliases

  • package and ansible.builtin.package

    • Both refer to the same generic package management module.

      - name: Install a package
        package:
          name: httpd
          state: present

             - name: Install a package
               ansible.builtin.package:
                name: httpd
                state: present


    - name: Copy a file
      copy:
        src: /path/to/local/file
        dest: /path/to/remote/file

    - name: Copy a file
      ansible.builtin.copy:
        src: /path/to/local/file
        dest: /path/to/remote/file


Comments

Popular posts from this blog

Learn -Ansible - Tutorial

Ansible Versions