Automation with Power

 View Only
Expand all | Collapse all

What's the difference between modules and roles?

  • 1.  What's the difference between modules and roles?

    Posted Tue January 30, 2024 10:28 AM
    Edited by Linda Alkire Fri February 02, 2024 09:12 AM

    Could someone help me understand the difference between a module and a role in the context of Ansible Automation Platform?


    #ansible-on-power


    ------------------------------
    Linda Alkire
    IBM
    Minneapolis MN
    ------------------------------



  • 2.  RE: What's the difference between modules and roles?

    Posted Tue February 13, 2024 09:10 AM

    Modules: Ansible tasks contain a name, a module and parameters for the module. In the following example, the "ansible.builtin.debug" module is used and this is documented here. In the background, Ansible executes Python code to execute the defined task.

    - name: Display message                 # Name
      ansible.builtin.debug:                # Module
        msg: "This is a test message."      # Parameter

    Roles: Useful to bundle Ansible tasks and with many functions like handlers (special form of ansible tasks that are executed towards the end of a role in certain conditions) to structure tasks.

    Playbook: Top-level structure which is executed by Ansible and executes roles on defined hosts.



    ------------------------------
    Niklas
    System Engineer UNIX and Linux on Power
    ------------------------------