This Ansible playbook automates the setup of a standard environment on Red Hat Enterprise Linux (RHEL) servers. It is designed to run within Ansible Automation Platform (AAP) or AWX and includes roles for configuring common system settings, time synchronization, networking, package installation, firewall configuration, authentication, and user management.
- Hostname Configuration: Sets the server's hostname to its fully qualified domain name (FQDN).
- Time Synchronization: Configures the system timezone and synchronizes time using NTP servers.
- Networking Configuration: Sets up
dnsmasqfor DNS caching and local DNS resolution. - Package Installation: Installs essential packages, including Cockpit for web-based system management.
- Firewall Configuration: Manages firewall settings using RHEL System Roles.
- Authentication: Supports both indirect and direct Active Directory (AD) integration.
- Indirect AD Integration: Configures Kerberos and SSSD for AD authentication without domain joining.
- Direct AD Integration: Joins the server to the AD domain using realm and configures SSSD.
- User Management: Manages local and AD users, including sudo privileges.
- Ansible Automation Platform (AAP) or AWX: The playbook is intended to run within AAP or AWX.
- Ansible Version: Compatible with Ansible 2.9 or later.
- Collections: Ensure the required Ansible collections are installed:
community.generalredhat.rhel_system_rolesansible.posixansible.controllerredhat.insightsfedora.linux_system_roles
- Variables: Ensure that variables are filled out within playbook.
- Hosts: Define target hosts in your inventory.
- Group Names: Use group names to control role execution:
tag_application_bind: Skips thenetworkingrole when present.tag_application_satellite: Skips thepackagesrole when present.tag_environment_dev,tag_environment_test,tag_environment_prod: Sets environment-specific variables.tag_resourceowner_*: Specifies which team owns the server.config_redhat_environment_standard_adjoin: Determines direct AD integration method.config_redhat_environment_standard_samba: Enables Samba configurations.
- Customize Variables:
- Update
vars/aap_prod.ymlandvars/aap_test.ymlwith your controller credentials. - Edit
roles/auth/defaults/main.ymlwith AD integration credentials. - Modify any other variables in
defaults/main.ymlas needed.
- Update
- Run the Playbook:
- From AAP/AWX:
- Create a project and sync it with your repository.
- Create an inventory and define your hosts and groups.
- Create a job template using the
site.ymlplaybook. - Configure surveys if needed for variables like
survey_hostname. - Launch the job template to run the playbook.
- From AAP/AWX:
- Tasks:
- Sets the hostname to the server's FQDN.
- Adds the server to the
config_redhat_environment_standardgroup in the Ansible Controller inventory.
- Tasks:
- Sets the system timezone.
- Configures NTP servers using the
timesyncRHEL system role.
- Condition: Skipped if
tag_application_bindis in group names. - Tasks:
- Installs and configures
dnsmasq. - Modifies
/etc/resolv.confand disables NetworkManager's DNS plugin.
- Installs and configures
- Condition: Skipped if
tag_application_satelliteis in group names. - Tasks:
- Registers the server with Red Hat Satellite.
- Installs Cockpit and other specified packages.
- Registers the server with Red Hat Insights.
- Tasks:
- Configures firewall settings using the
firewallRHEL system role. - Firewall rules should be defined in
roles/firewall/defaults/main.yml.
- Configures firewall settings using the
- Tasks:
- Indirect AD Integration:
- Installs Kerberos and SSSD packages.
- Configures Kerberos (
krb5.conf) and SSSD (sssd.conf). - Sets SSH configurations.
- Direct AD Integration:
- Joins the server to the AD domain.
- Configures SSSD with custom settings.
- Manages realm permitted logins and sudoers files.
- Indirect AD Integration:
- Tasks:
- Manages user accounts based on the AD integration method.
- Configures sudo privileges for infrastructure and resource owner teams.
- Environment Variables:
aap_environment: Determines whether to useaap_prod.ymloraap_test.yml.
- Controller Variables (in
vars/aap_prod.ymlandvars/aap_test.yml):controller_hostcontroller_usernamecontroller_passwordvalidate_certs
- Auth Role (in
roles/auth/defaults/main.yml):auth_ad_integration_user: AD user for domain joining.auth_ad_integration_password_devauth_ad_integration_password_testauth_ad_integration_password_prod
- Packages Role (in
roles/packages/defaults/main.yml):cockpit_packages: List of Cockpit packages to install.cockpit_enabledcockpit_startedcockpit_portcockpit_manage_firewall
- Firewall Role (in
roles/firewall/defaults/main.yml):firewall: Define firewall rules as per RHEL System Roles documentation.
- Users Role (in
roles/users/defaults/main.yml):domain_suffix_dev,domain_suffix_test,domain_suffix_prod: AD domain suffixes.infra_accounts: List of infrastructure accounts to manage.teamxyz_accounts: Accounts for specific resource owner teams.
- Playbook:
site.yml: The main playbook file.
- Variables:
vars/aap_prod.ymlandvars/aap_test.yml: Environment-specific variables.
- Roles:
- Each role is located under
roles/and contains tasks, handlers, defaults, and files specific to its function.
- Each role is located under
- Collections Requirements:
collections/requirements.yml: Specifies the Ansible collections required.
- Templates and Files:
- Configuration files and templates are located under each role's
files/directory.
- Configuration files and templates are located under each role's
- Restart Services:
Restart sshd: Restarts the SSH daemon when configuration changes.Restart sssd: Restarts the SSSD service after configuration changes.Restart dnsmasq: Restarts the dnsmasq service when networking configurations change.Restart NetworkManager: Restarts NetworkManager after modifying its configuration.
- Adjust Variables: Modify variables in
defaults/main.ymlandvars/to suit your environment. - Modify Roles: You can add or remove tasks within roles as needed.
- Add Custom Roles: Incorporate additional roles if required for your setup.
- Firewall Rules: Define custom firewall rules in
roles/firewall/defaults/main.ymlfollowing the RHEL System Roles documentation.
- Sensitive Data: Do not hardcode sensitive information like passwords. Use Ansible Vault or AAP/AWX credentials.
- Testing: Always test the playbook in a non-production environment before deploying to production.
- Group Names: Properly assign group names in your inventory to control task execution flow.
- Documentation: Refer to the RHEL System Roles and Ansible documentation for advanced configurations.
- Ansible Documentation: https://docs.ansible.com/
- Ansible Collections: https://galaxy.ansible.com/
- RHEL System Roles: https://access.redhat.com/articles/3050101
- Ansible Automation Platform: https://www.ansible.com/products/automation-platform