diff --git a/08-adding-users/site.yml b/08-adding-users/site.yml index 333f862..eae18be 100644 --- a/08-adding-users/site.yml +++ b/08-adding-users/site.yml @@ -27,11 +27,10 @@ - htop - neofetch - + - hosts: web_servers become: true - tags: debian tasks: - name: Install apache on web servers @@ -50,19 +49,6 @@ group: root mode: 0644 - - name: Add lfultz account - tags: debian - user: - name: lfultz - comment: Logan Fultz - uid: 1040 - gid: 1040 - group: sudo - shell: /bin/bash - generate_ssh_key: yes - ssh_key_bits: 2048 - ssh_key_file: .ssh/id_rsa - - hosts: db_servers tags: db, el @@ -73,16 +59,3 @@ package: name: mariadb state: latest - - - name: Add lfultz account - tags: el - user: - name: lfultz - comment: Logan Fultz - uid: 1040 - gid: 1040 - group: wheel - shell: /bin/bash - generate_ssh_key: yes - ssh_key_bits: 2048 - ssh_key_file: .ssh/id_rsa \ No newline at end of file diff --git a/09-roles/ansible.cfg b/09-roles/ansible.cfg new file mode 100644 index 0000000..0056832 --- /dev/null +++ b/09-roles/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = inventory +private_key_file = ~/.ssh/hetzner + + diff --git a/09-roles/install_apache.yml b/09-roles/install_apache.yml new file mode 100644 index 0000000..3f7996d --- /dev/null +++ b/09-roles/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/09-roles/inventory b/09-roles/inventory new file mode 100644 index 0000000..f42df84 --- /dev/null +++ b/09-roles/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/09-roles/roles/base/main.yml b/09-roles/roles/base/main.yml new file mode 100644 index 0000000..41f6511 --- /dev/null +++ b/09-roles/roles/base/main.yml @@ -0,0 +1,25 @@ +- name: Install common packages + package: + name: + - htop + - neofetch + +- name: Add lfultz account + tags: lfultz + user: + name: lfultz + comment: Logan Fultz + uid: 1040 + groups: root + append: yes + shell: /bin/bash + generate_ssh_key: yes + ssh_key_bits: 2048 + ssh_key_file: .ssh/id_rsa + +- name: Add lfultz group + tags: group + group: + name: lfultz + state: present + gid: 1040 \ No newline at end of file diff --git a/09-roles/roles/db_servers/main.yml b/09-roles/roles/db_servers/main.yml new file mode 100644 index 0000000..34ba640 --- /dev/null +++ b/09-roles/roles/db_servers/main.yml @@ -0,0 +1,5 @@ +--- +- name: install mariadb package on db servers + package: + name: mariadb + state: latest \ No newline at end of file diff --git a/09-roles/roles/web_servers/files/default_site.html b/09-roles/roles/web_servers/files/default_site.html new file mode 100644 index 0000000..b14f198 --- /dev/null +++ b/09-roles/roles/web_servers/files/default_site.html @@ -0,0 +1,11 @@ + + + + Website test + + + +

Goodevening Caleb

+ + + diff --git a/09-roles/roles/web_servers/main.yml b/09-roles/roles/web_servers/main.yml new file mode 100644 index 0000000..3ab3065 --- /dev/null +++ b/09-roles/roles/web_servers/main.yml @@ -0,0 +1,16 @@ +--- +- 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 \ No newline at end of file diff --git a/09-roles/site.yml b/09-roles/site.yml new file mode 100644 index 0000000..19d28b2 --- /dev/null +++ b/09-roles/site.yml @@ -0,0 +1,39 @@ +--- +- 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 + roles: + - base + + + +- hosts: web_servers + become: true + tags: web + roles: + - web_servers + + + +- hosts: db_servers + tags: db, + become: true + roles: + - db_servers