Ansible Roles

From rbachwiki
Revision as of 16:02, 30 June 2022 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Create Roles to organize playbooks

=This Playbook has some tasks to be done

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

- name: Start httpd
 service:
  name: httpd
  state: started

- name: Open port for http
 firewalld:
  service: http
  permanent: true
  state: enabled

- name: Restart firewalld 
 service:
  name: firewalld
  state: reloaded

Another Playbook with some more tasks

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

 - name: Start httpd
   service:
    name: httpd
    state: started

Role that incorporate the other 2 playbooks

---
- name: Full install
 hosts: all
 roles:
 - fullinstall

- name: Basic install

 hosts: localhosts
 roles:
 - basicinstall