ansible-course/06-copying-files/site.yml
2024-07-13 21:50:13 -04:00

83 lines
1.5 KiB
YAML

---
- hosts: all
become: true
pre_tasks:
- name: install updates for RHEL distros
tags: always
package:
update_only: yes
update_cache: yes
when: ansible_os_family == "RedHat"
- name: install updates for Debian distros
tags: always
package:
upgrade: dist
update_cache: yes
when: ansible_os_family == "Debian"
- hosts: all
become: true
tasks:
- name: Install common packages
package:
name:
- htop
- neofetch
- hosts: web_servers
become: true
tasks:
- name: Install apache on web servers
tags: apache
package:
name:
- apache2
- libapache2-mod-php
- name: Make sure apache is running
tags: apache
service:
name: apache2
state: started
- name: Change admin email for website
tags: apache
lineinfile:
path: /etc/apache2/sites-available/000-default.conf
regexp: '^ServerAdmin'
line: ServerAdmin caleb@cfultz.wtf
register: apache2
- name: Restart apache2
tags: apache
service:
name: apache2
state: restarted
when: apache2.changed
- name: Copy html file
tags: website
copy:
src: default_site.html
dest: /var/www/html/index.html
owner: root
group: root
mode: 0644
- hosts: db_servers
become: true
tasks:
- name: install mariadb package on db servers
tags: db, el
package:
name: mariadb
state: latest