diff --git a/06-copying-files/site.yml b/06-copying-files/site.yml index eae18be..2dbe066 100644 --- a/06-copying-files/site.yml +++ b/06-copying-files/site.yml @@ -39,6 +39,27 @@ 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 @@ -51,11 +72,11 @@ - hosts: db_servers - tags: db, el become: true tasks: - name: install mariadb package on db servers + tags: db, el package: name: mariadb state: latest diff --git a/07-managing-services/ansible.cfg b/07-managing-services/ansible.cfg new file mode 100644 index 0000000..0056832 --- /dev/null +++ b/07-managing-services/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = inventory +private_key_file = ~/.ssh/hetzner + + diff --git a/07-managing-services/files/default_site.html b/07-managing-services/files/default_site.html new file mode 100644 index 0000000..b14f198 --- /dev/null +++ b/07-managing-services/files/default_site.html @@ -0,0 +1,11 @@ + + + + Website test + + + +

Goodevening Caleb

+ + + diff --git a/07-managing-services/install_apache.yml b/07-managing-services/install_apache.yml new file mode 100644 index 0000000..3f7996d --- /dev/null +++ b/07-managing-services/install_apache.yml @@ -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 + diff --git a/07-managing-services/inventory b/07-managing-services/inventory new file mode 100644 index 0000000..f42df84 --- /dev/null +++ b/07-managing-services/inventory @@ -0,0 +1,7 @@ +[web_servers] +10.0.0.7 +10.0.0.8 + +[db_servers] +10.0.0.5 +10.0.0.11 diff --git a/07-managing-services/site.yml b/07-managing-services/site.yml new file mode 100644 index 0000000..eae18be --- /dev/null +++ b/07-managing-services/site.yml @@ -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