This commit is contained in:
Caleb Fultz 2024-07-13 21:50:13 -04:00
parent 0c7024cec3
commit 44959405f8
6 changed files with 121 additions and 1 deletions

View File

@ -39,6 +39,27 @@
name: name:
- apache2 - apache2
- libapache2-mod-php - 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 - name: Copy html file
tags: website tags: website
@ -51,11 +72,11 @@
- hosts: db_servers - hosts: db_servers
tags: db, el
become: true become: true
tasks: tasks:
- name: install mariadb package on db servers - name: install mariadb package on db servers
tags: db, el
package: package:
name: mariadb name: mariadb
state: latest state: latest

View File

@ -0,0 +1,5 @@
[defaults]
inventory = inventory
private_key_file = ~/.ssh/hetzner

View File

@ -0,0 +1,11 @@
<html>
<head>
<title>Website test</title>
</head>
<body>
<p> Goodevening Caleb </p>
</body>
</html>

View File

@ -0,0 +1,15 @@
---
- hosts: all
become: true
tasks:
#### Ubuntu/Debian Section ####
- name: Install apache2 package with php support
package:
name:
- "{{ apache_package }}"
- "{{ php_package }}"
state: latest
update_cache: yes

View File

@ -0,0 +1,7 @@
[web_servers]
10.0.0.7
10.0.0.8
[db_servers]
10.0.0.5
10.0.0.11

View File

@ -0,0 +1,61 @@
---
- 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: 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
tags: db, el
become: true
tasks:
- name: install mariadb package on db servers
package:
name: mariadb
state: latest