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.