### Configure Mail Aliases with Ansible Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt Deploys a list of mail aliases to `/etc/aliases` and rebuilds the alias database. This example shows how to define aliases for different users, including forwarding to external email addresses. ```yaml --- - hosts: mail_servers become: true roles: - role: MichaelRigart.aliases vars: aliases_list: - user: postmaster alias: root - user: webmaster alias: admin@example.com - user: abuse alias: security-team@example.com - user: support alias: helpdesk@example.com ``` -------------------------------- ### Ansible Test Playbook for Role Validation Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt An example test playbook designed for validating the functionality of the Ansible aliases role in development or testing environments. ```yaml # tests/test.yml - hosts: all roles: - { role: ../../ansible-role-aliases, become: true } ``` -------------------------------- ### Apply Aliases Role in Ansible Playbook Source: https://github.com/michaelrigart/ansible-role-aliases/blob/master/README.md This example playbook demonstrates how to integrate and apply the MichaelRigart.aliases Ansible role. It targets 'servers' and requires elevated privileges ('become: true') for alias management. ```yaml - hosts: servers roles: - { role: MichaelRigart.aliases, become: true } ``` -------------------------------- ### Ansible Playbook for Multi-Environment Alias Deployment Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt Demonstrates deploying mail aliases across different environments (production, staging, development) using environment-specific variable mappings. The target environment is selected via the `target_env` variable. ```yaml --- - name: Configure mail aliases hosts: "{{ target_env }}" become: true vars: aliases_list: "{{ aliases_by_env[target_env] }}" aliases_by_env: production: - user: postmaster alias: ops-team@company.com - user: root alias: sysadmin@company.com - user: monitoring alias: alerts@company.com staging: - user: postmaster alias: dev-team@company.com - user: root alias: dev-ops@company.com development: - user: postmaster alias: developer@localhost - user: root alias: developer@localhost roles: - MichaelRigart.aliases # Usage: # ansible-playbook playbook.yml -e "target_env=production" ``` -------------------------------- ### Ansible Playbook for Mail Aliases with Custom Variables Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt A comprehensive Ansible playbook demonstrating how to integrate the aliases role with custom alias mappings. It includes tasks to verify the `/etc/aliases` file content after applying the role. ```yaml --- - name: Configure mail aliases on all servers hosts: all become: true vars: aliases_list: - user: postmaster alias: root - user: root alias: admin@company.com - user: mailer-daemon alias: postmaster - user: nobody alias: /dev/null roles: - MichaelRigart.aliases post_tasks: - name: Verify aliases file command: cat /etc/aliases register: aliases_content changed_when: false - name: Display aliases debug: var: aliases_content.stdout_lines ``` -------------------------------- ### Ansible Task for Deploying Aliases Template Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt The main task in the Ansible role that deploys the Jinja2 template for the `/etc/aliases` file. It ensures the file has the correct ownership and permissions. ```yaml # tasks/main.yml --- - name: configure /etc/aliases template: src: aliases.j2 dest: /etc/aliases owner: root group: root mode: 0644 notify: aliases_update ``` -------------------------------- ### Jinja2 Template for Aliases File Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt The Jinja2 template used by the Ansible role to generate the content of the `/etc/aliases` file. It iterates through the `aliases_list` variable to create alias entries. ```jinja2 {% for item in aliases_list %} {{ item.user }}: {{ item.alias }} {% endfor %} ``` -------------------------------- ### Define Mail Aliases List in YAML Source: https://github.com/michaelrigart/ansible-role-aliases/blob/master/README.md This snippet shows the structure for defining mail aliases using a list of dictionaries in YAML format. Each dictionary specifies a 'user' and their corresponding 'alias'. This is a core configuration for the Ansible role. ```yaml aliases_list: a list of dictionaries holding the user and the alias - user: postmaster alias: root ``` -------------------------------- ### Ansible Handler for Alias Database Update Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt The handler responsible for executing the `newaliases` command to rebuild the mail alias database. It ensures the command exists before attempting to run it, providing graceful failure. ```yaml # handlers/main.yml --- - name: aliases_update shell: which newaliases && newaliases || true ``` -------------------------------- ### Default Alias Configuration in Ansible Source: https://context7.com/michaelrigart/ansible-role-aliases/llms.txt Defines the default mail alias configuration for the Ansible role. This default can be overridden by providing a custom `aliases_list` variable in your playbook. ```yaml # defaults/main.yml --- alias_list: - user: postmaster alias: root ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.