Clinical-Genomics / event-driven-architecture

Project tracking for event driven POC
0 stars 0 forks source link

3. [Explore] Write an Ansible playbook #15

Open seallard opened 1 month ago

seallard commented 1 month ago

Go ahead and write some other playbooks and use it to configure the container.

If you find an interesting Ansible feature, share it with the rest of the team.

We can showcase any interesting stuff during the retro.

ChrOertlin commented 1 month ago

Done!

seallard commented 1 month ago

Done!

Playbook to install Apache

---
- name: Install and start Apache HTTP server
  hosts: localhost
  become: yes

  tasks:

    - name: Ensure Apache is installed
      ansible.builtin.apt:
        name: apache2
        state: present
        update_cache: yes

    - name: Ensure Apache is running and enabled
      ansible.builtin.service:
        name: "{{ 'apache2' }}"
        state: started
        enabled: yes

Playbook to restart Apache and reinstall if restart fails

---
- name: Install and start Apache HTTP server
  hosts: localhost
  become: yes

  tasks:

    - name: Ensure Apache is installed
      ansible.builtin.apt:
        name: apache2
        state: present
        update_cache: yes

    - name: Ensure Apache is running and enabled
      ansible.builtin.service:
        name: "{{ 'apache2' }}"
        state: started
        enabled: yes