From 23cd031851ad5a287226a41be1c400fe42784e12 Mon Sep 17 00:00:00 2001 From: Caleb Fultz Date: Fri, 12 Jul 2024 16:39:02 -0400 Subject: [PATCH] creating inventories --- create-inventory/ansible.cfg | 5 ++++ create-inventory/install_apache.yml | 15 ++++++++++ create-inventory/inventory | 7 +++++ create-inventory/site.yml | 45 +++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 create-inventory/ansible.cfg create mode 100644 create-inventory/install_apache.yml create mode 100644 create-inventory/inventory create mode 100644 create-inventory/site.yml diff --git a/create-inventory/ansible.cfg b/create-inventory/ansible.cfg new file mode 100644 index 0000000..0056832 --- /dev/null +++ b/create-inventory/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = inventory +private_key_file = ~/.ssh/hetzner + + diff --git a/create-inventory/install_apache.yml b/create-inventory/install_apache.yml new file mode 100644 index 0000000..3f7996d --- /dev/null +++ b/create-inventory/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/create-inventory/inventory b/create-inventory/inventory new file mode 100644 index 0000000..f42df84 --- /dev/null +++ b/create-inventory/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/create-inventory/site.yml b/create-inventory/site.yml new file mode 100644 index 0000000..f776d9d --- /dev/null +++ b/create-inventory/site.yml @@ -0,0 +1,45 @@ +--- +- hosts: all + become: true + pre_tasks: + + - name: install updates for RHEL distros + package: + update_only: yes + update_cache: yes + when: ansible_os_family == "RedHat" + + - name: install updates for Debian distros + 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 + package: + name: + - apache2 + - libapache2-mod-php + +- hosts: db_servers + become: true + tasks: + + - name: install mariadb package on db servers + package: + name: mariadb + state: latest