From 6bea9b14a7f88ba12d084f8e3f28baadb15d0e3e Mon Sep 17 00:00:00 2001 From: Caleb Fultz Date: Fri, 12 Jul 2024 22:31:00 -0400 Subject: [PATCH] Updated README --- .../ansible.cfg | 0 .../install_apache.yml | 0 .../inventory | 0 .../remove_apache.yml | 0 .../ansible.cfg | 0 .../install_apache.yml | 0 .../inventory | 0 .../remove_apache.yml | 0 .../ansible.cfg | 0 .../install_apache.yml | 0 {refactoring => 03-refactoring}/inventory | 0 .../ansible.cfg | 0 .../install_apache.yml | 0 .../inventory | 0 .../site.yml | 0 05-adding-tags/ansible.cfg | 5 ++ 05-adding-tags/install_apache.yml | 15 ++++++ 05-adding-tags/inventory | 7 +++ 05-adding-tags/site.yml | 49 +++++++++++++++++++ README.md | 4 ++ 20 files changed, 80 insertions(+) rename {create-inventory => 01-first-playbook}/ansible.cfg (100%) rename {first-playbook => 01-first-playbook}/install_apache.yml (100%) rename {first-playbook => 01-first-playbook}/inventory (100%) rename {first-playbook => 01-first-playbook}/remove_apache.yml (100%) rename {first-playbook => 02-mixed-linux-environments}/ansible.cfg (100%) rename {mixed-linux-environments => 02-mixed-linux-environments}/install_apache.yml (100%) rename {mixed-linux-environments => 02-mixed-linux-environments}/inventory (100%) rename {mixed-linux-environments => 02-mixed-linux-environments}/remove_apache.yml (100%) rename {mixed-linux-environments => 03-refactoring}/ansible.cfg (100%) rename {create-inventory => 03-refactoring}/install_apache.yml (100%) rename {refactoring => 03-refactoring}/inventory (100%) rename {refactoring => 04-create-inventory}/ansible.cfg (100%) rename {refactoring => 04-create-inventory}/install_apache.yml (100%) rename {create-inventory => 04-create-inventory}/inventory (100%) rename {create-inventory => 04-create-inventory}/site.yml (100%) create mode 100644 05-adding-tags/ansible.cfg create mode 100644 05-adding-tags/install_apache.yml create mode 100644 05-adding-tags/inventory create mode 100644 05-adding-tags/site.yml diff --git a/create-inventory/ansible.cfg b/01-first-playbook/ansible.cfg similarity index 100% rename from create-inventory/ansible.cfg rename to 01-first-playbook/ansible.cfg diff --git a/first-playbook/install_apache.yml b/01-first-playbook/install_apache.yml similarity index 100% rename from first-playbook/install_apache.yml rename to 01-first-playbook/install_apache.yml diff --git a/first-playbook/inventory b/01-first-playbook/inventory similarity index 100% rename from first-playbook/inventory rename to 01-first-playbook/inventory diff --git a/first-playbook/remove_apache.yml b/01-first-playbook/remove_apache.yml similarity index 100% rename from first-playbook/remove_apache.yml rename to 01-first-playbook/remove_apache.yml diff --git a/first-playbook/ansible.cfg b/02-mixed-linux-environments/ansible.cfg similarity index 100% rename from first-playbook/ansible.cfg rename to 02-mixed-linux-environments/ansible.cfg diff --git a/mixed-linux-environments/install_apache.yml b/02-mixed-linux-environments/install_apache.yml similarity index 100% rename from mixed-linux-environments/install_apache.yml rename to 02-mixed-linux-environments/install_apache.yml diff --git a/mixed-linux-environments/inventory b/02-mixed-linux-environments/inventory similarity index 100% rename from mixed-linux-environments/inventory rename to 02-mixed-linux-environments/inventory diff --git a/mixed-linux-environments/remove_apache.yml b/02-mixed-linux-environments/remove_apache.yml similarity index 100% rename from mixed-linux-environments/remove_apache.yml rename to 02-mixed-linux-environments/remove_apache.yml diff --git a/mixed-linux-environments/ansible.cfg b/03-refactoring/ansible.cfg similarity index 100% rename from mixed-linux-environments/ansible.cfg rename to 03-refactoring/ansible.cfg diff --git a/create-inventory/install_apache.yml b/03-refactoring/install_apache.yml similarity index 100% rename from create-inventory/install_apache.yml rename to 03-refactoring/install_apache.yml diff --git a/refactoring/inventory b/03-refactoring/inventory similarity index 100% rename from refactoring/inventory rename to 03-refactoring/inventory diff --git a/refactoring/ansible.cfg b/04-create-inventory/ansible.cfg similarity index 100% rename from refactoring/ansible.cfg rename to 04-create-inventory/ansible.cfg diff --git a/refactoring/install_apache.yml b/04-create-inventory/install_apache.yml similarity index 100% rename from refactoring/install_apache.yml rename to 04-create-inventory/install_apache.yml diff --git a/create-inventory/inventory b/04-create-inventory/inventory similarity index 100% rename from create-inventory/inventory rename to 04-create-inventory/inventory diff --git a/create-inventory/site.yml b/04-create-inventory/site.yml similarity index 100% rename from create-inventory/site.yml rename to 04-create-inventory/site.yml diff --git a/05-adding-tags/ansible.cfg b/05-adding-tags/ansible.cfg new file mode 100644 index 0000000..0056832 --- /dev/null +++ b/05-adding-tags/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = inventory +private_key_file = ~/.ssh/hetzner + + diff --git a/05-adding-tags/install_apache.yml b/05-adding-tags/install_apache.yml new file mode 100644 index 0000000..3f7996d --- /dev/null +++ b/05-adding-tags/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/05-adding-tags/inventory b/05-adding-tags/inventory new file mode 100644 index 0000000..f42df84 --- /dev/null +++ b/05-adding-tags/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/05-adding-tags/site.yml b/05-adding-tags/site.yml new file mode 100644 index 0000000..38f6732 --- /dev/null +++ b/05-adding-tags/site.yml @@ -0,0 +1,49 @@ +--- +- 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,debian + package: + name: + - apache2 + - libapache2-mod-php + +- hosts: db_servers + tags: db,el + become: true + tasks: + + - name: install mariadb package on db servers + package: + name: mariadb + state: latest diff --git a/README.md b/README.md index e4128ff..2c34f55 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # ansible-course LearnLinuxTV Ansible Course Repository. If you're on [GitHub](https://github.com/cfultz/ansible-course), this is mirrored on my personal [Gitea](https://git.cfultz.wtf/cfultz/ansible-course) instance. + +# Changes + +I updated some of the commands i already knew in earlier playbooks to make things morr streamlined.