fixed some stuff in 07 and added 10-host-vars
This commit is contained in:
parent
a58b8b2a16
commit
e82679c9c8
@ -48,7 +48,13 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
register: apache
|
||||||
|
|
||||||
|
- name: Restart apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: restart
|
||||||
|
when: apache.changed
|
||||||
|
|
||||||
- hosts: db_servers
|
- hosts: db_servers
|
||||||
tags: db, el
|
tags: db, el
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
- name: Install apache on web servers
|
- name: Install apache on web servers
|
||||||
tags: apache
|
tags: apache
|
||||||
package:
|
package:
|
5
10-host-vars/ansible.cfg
Normal file
5
10-host-vars/ansible.cfg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory
|
||||||
|
private_key_file = ~/.ssh/hetzner
|
||||||
|
|
||||||
|
|
5
10-host-vars/host_vars/10.0.0.11.yml
Normal file
5
10-host-vars/host_vars/10.0.0.11.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
webserver_package: httpd
|
||||||
|
webserver_service: httpd
|
||||||
|
php_package: php
|
||||||
|
database_package: mariadb
|
||||||
|
database_service: mariadb
|
5
10-host-vars/host_vars/10.0.0.5.yml
Normal file
5
10-host-vars/host_vars/10.0.0.5.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
webserver_package: httpd
|
||||||
|
webserver_service: httpd
|
||||||
|
php_package: php
|
||||||
|
database_package: mariadb
|
||||||
|
database_service: mariadb
|
5
10-host-vars/host_vars/10.0.0.7.yml
Normal file
5
10-host-vars/host_vars/10.0.0.7.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
webserver_package: apache2
|
||||||
|
webserver_service: apache2
|
||||||
|
php_package: libapache2-mod-php
|
||||||
|
database_package: mariadb-server
|
||||||
|
database_service: mariadb-server
|
5
10-host-vars/host_vars/10.0.0.8.yml
Normal file
5
10-host-vars/host_vars/10.0.0.8.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
webserver_package: apache2
|
||||||
|
webserver_service: apache2
|
||||||
|
php_package: libapache2-mod-php
|
||||||
|
database_package: mariadb-server
|
||||||
|
database_service: mariadb-server
|
8
10-host-vars/inventory
Normal file
8
10-host-vars/inventory
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[web_servers]
|
||||||
|
10.0.0.7
|
||||||
|
10.0.0.8
|
||||||
|
|
||||||
|
|
||||||
|
[db_servers]
|
||||||
|
10.0.0.5
|
||||||
|
10.0.0.11
|
25
10-host-vars/roles/base/tasks/main.yml
Normal file
25
10-host-vars/roles/base/tasks/main.yml
Normal file
@ -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
|
5
10-host-vars/roles/db_servers/tasks/main.yml
Normal file
5
10-host-vars/roles/db_servers/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: install mariadb package on db servers
|
||||||
|
package:
|
||||||
|
name: "{{ database_package }}"
|
||||||
|
state: latest
|
11
10-host-vars/roles/web_servers/files/default_site.html
Normal file
11
10-host-vars/roles/web_servers/files/default_site.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Ansible Course</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p> Good evening, Caleb! </p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
4
10-host-vars/roles/web_servers/handlers/main.yml
Normal file
4
10-host-vars/roles/web_servers/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: restart_apache
|
||||||
|
service:
|
||||||
|
name: "{{ webserver_package}}"
|
||||||
|
state: restarted
|
17
10-host-vars/roles/web_servers/tasks/main.yml
Normal file
17
10-host-vars/roles/web_servers/tasks/main.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
- name: Install apache on web servers
|
||||||
|
tags: apache
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- "{{ webserver_package }}"
|
||||||
|
- "{{ php_package }}"
|
||||||
|
|
||||||
|
- name: Copy html file
|
||||||
|
tags: website
|
||||||
|
copy:
|
||||||
|
src: default_site.html
|
||||||
|
dest: /var/www/html/index.html
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart_apache
|
39
10-host-vars/site.yml
Normal file
39
10-host-vars/site.yml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user