Initial import
This commit is contained in:
commit
c28551bb63
22 changed files with 357 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
ansible.cfg
|
||||||
|
collections/
|
||||||
36
README.adoc
Normal file
36
README.adoc
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
= Ansible Demo "Retwis"
|
||||||
|
|
||||||
|
|
||||||
|
== Aufbau des Inventars
|
||||||
|
|
||||||
|
.Dateien im Inventar
|
||||||
|
[source]
|
||||||
|
----
|
||||||
|
inventory/
|
||||||
|
├── hosts
|
||||||
|
└── host_vars
|
||||||
|
├── demo-db01
|
||||||
|
│ └── ansible.yml
|
||||||
|
└── demo-web01
|
||||||
|
└── ansible.yml
|
||||||
|
----
|
||||||
|
|
||||||
|
.inventory/hosts
|
||||||
|
[source]
|
||||||
|
----
|
||||||
|
[webserver]
|
||||||
|
demo-web01
|
||||||
|
|
||||||
|
[redis]
|
||||||
|
demo-db01
|
||||||
|
----
|
||||||
|
|
||||||
|
.ansible.yml für einzelne Hosts
|
||||||
|
[source]
|
||||||
|
----
|
||||||
|
---
|
||||||
|
ansible_user: <ssh-username>
|
||||||
|
ansible_host: <ip>
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
29
ansible.cfg.dist
Normal file
29
ansible.cfg.dist
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[defaults]
|
||||||
|
|
||||||
|
inventory = ./inventory/
|
||||||
|
|
||||||
|
#log_path = ansible.log
|
||||||
|
roles_path = ./roles
|
||||||
|
collections_paths = ./collections
|
||||||
|
|
||||||
|
forks = 20
|
||||||
|
|
||||||
|
#callback_whitelist = profile_roles, profile_tasks, timer
|
||||||
|
|
||||||
|
deprecation_warnings=False
|
||||||
|
|
||||||
|
[inventory]
|
||||||
|
# fail more helpfully when the inventory file does not parse (Ansible 2.4+)
|
||||||
|
unparsed_is_failed=true
|
||||||
|
|
||||||
|
enable_plugins = host_list, auto, yaml, ini
|
||||||
|
|
||||||
|
# Additional ssh options for OpenShift Ansible
|
||||||
|
[ssh_connection]
|
||||||
|
pipelining = True
|
||||||
|
ssh_args = -o ControlMaster=auto -o ControlPersist=600s -o StrictHostKeyChecking=no
|
||||||
|
timeout = 10
|
||||||
|
# shorten the ControlPath which is often too long; when it is,
|
||||||
|
# ssh connection reuse silently fails, making everything slower.
|
||||||
|
control_path = %(directory)s/%%h-%%r
|
||||||
|
|
||||||
14
os_update_etc_hosts.yml
Normal file
14
os_update_etc_hosts.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
- name: Static DNS Lookup
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Add all hosts to /etc/hosts
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
regexp: "^{{ hostvars[item]['ansible_facts']['default_ipv4']['address'] }}.+{{ hostvars[item].ansible_facts.fqdn }}.*$"
|
||||||
|
line: "{{ hostvars[item]['ansible_facts']['default_ipv4']['address'] }} {{ hostvars[item].ansible_facts.fqdn }} {{ hostvars[item].ansible_facts.hostname }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ groups.all }}"
|
||||||
|
|
||||||
7
ping_all.yml
Normal file
7
ping_all.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: Ping all hosts
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Ping host
|
||||||
|
ansible.builtin.ping: {}
|
||||||
8
redis_installation.yml
Normal file
8
redis_installation.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
- name: Database configuration
|
||||||
|
hosts: redis
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- role: redis
|
||||||
|
vars:
|
||||||
|
redis_clients_group: webserver
|
||||||
4
requirements.yml
Normal file
4
requirements.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: ansible.posix
|
||||||
|
version: ">=1.5.0"
|
||||||
6
retwis_installation.yml
Normal file
6
retwis_installation.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Webserver configuration
|
||||||
|
hosts: webserver
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- retwis
|
||||||
2
roles/redis/defaults/main.yml
Normal file
2
roles/redis/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
redis_clients_group: all
|
||||||
21
roles/redis/meta/main.yml
Normal file
21
roles/redis/meta/main.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
galaxy_info:
|
||||||
|
author: Frank Agerholm
|
||||||
|
description: Redis installation and Configuration
|
||||||
|
company: serverWG.de
|
||||||
|
|
||||||
|
issue_tracker_url: "https://git.serverwg.de/fager/ansible-demo-retwis/issues/new"
|
||||||
|
|
||||||
|
license: "GPL"
|
||||||
|
|
||||||
|
min_ansible_version: "2.11"
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- "7"
|
||||||
|
- "8"
|
||||||
|
- "9"
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
37
roles/redis/tasks/main.yml
Normal file
37
roles/redis/tasks/main.yml
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
---
|
||||||
|
- name: Install Redis Database
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: redis
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Configure Redis to listen on all IPs
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/redis/redis.conf
|
||||||
|
regexp: '^bind '
|
||||||
|
line: 'bind 0.0.0.0'
|
||||||
|
|
||||||
|
- name: Enable and start the redis service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: redis
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Gather facts from client systems
|
||||||
|
ansible.builtin.setup:
|
||||||
|
delegate_to: "{{ item }}"
|
||||||
|
delegate_facts: true
|
||||||
|
loop: "{{ groups[redis_clients_group] }}"
|
||||||
|
|
||||||
|
- name: Ensure Firewall is enabled
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: firewalld.service
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Open the Firewall
|
||||||
|
ansible.posix.firewalld:
|
||||||
|
rich_rule: 'rule family="ipv4" source address="{{ item }}/32" port protocol="tcp" port="6379" accept'
|
||||||
|
permanent: true
|
||||||
|
state: enabled
|
||||||
|
immediate: true
|
||||||
|
loop: "{{ groups[redis_clients_group] | map('extract', hostvars, ['ansible_facts', 'default_ipv4', 'address']) | list }}"
|
||||||
4
roles/retwis/defaults/main.yml
Normal file
4
roles/retwis/defaults/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
retwis_download_tgz_url: "https://git.serverwg.de/fager/retwis/archive/1.0.tar.gz"
|
||||||
|
retwis_version: 1.0
|
||||||
|
redis_server_group: redis
|
||||||
21
roles/retwis/meta/main.yml
Normal file
21
roles/retwis/meta/main.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
galaxy_info:
|
||||||
|
author: Frank Agerholm
|
||||||
|
description: Retwis installation and Configuration
|
||||||
|
company: serverWg.de
|
||||||
|
|
||||||
|
issue_tracker_url: "https://git.serverwg.de/fager/ansible-demo-retwis/issues/new"
|
||||||
|
|
||||||
|
license: "GPL"
|
||||||
|
|
||||||
|
min_ansible_version: "2.11"
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- "7"
|
||||||
|
- "8"
|
||||||
|
- "9"
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
53
roles/retwis/tasks/main.yml
Normal file
53
roles/retwis/tasks/main.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
- name: Download Retwis Application
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ retwis_download_tgz_url }}"
|
||||||
|
dest: "/tmp/retwis-{{ retwis_version }}.tar.gz"
|
||||||
|
validate_certs: false
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
|
||||||
|
- name: Clean up document root
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/var/www/html/app"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
loop:
|
||||||
|
- absent
|
||||||
|
- directory
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
|
||||||
|
- name: Extract retwis software archive to documentroot
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "/tmp/retwis-{{ retwis_version }}.tar.gz"
|
||||||
|
dest: /var/www/html/app
|
||||||
|
remote_src: true
|
||||||
|
extra_opts:
|
||||||
|
- --strip-components=1
|
||||||
|
- --directory=/var/www/html/app
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
|
||||||
|
- name: Gather facts from redis server systems
|
||||||
|
ansible.builtin.setup:
|
||||||
|
delegate_to: "{{ item }}"
|
||||||
|
delegate_facts: true
|
||||||
|
loop: "{{ groups[redis_server_group] }}"
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
- configure
|
||||||
|
|
||||||
|
- name: Deploy .htconfig template for Retwis Webapp configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: dot-htconfig.php
|
||||||
|
dest: /var/www/html/app/.htconfig.php
|
||||||
|
mode: "0644"
|
||||||
|
owner: apache
|
||||||
|
group: apache
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
- configure
|
||||||
6
roles/retwis/templates/dot-htconfig.php
Normal file
6
roles/retwis/templates/dot-htconfig.php
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
$redis_options["schema"] = "tcp";
|
||||||
|
$redis_options["host"] = "{{ groups[redis_server_group] | first }}";
|
||||||
|
$redis_options["port"] = 6379;
|
||||||
|
$retwis_title = "{{retwis_title|default('')}}";
|
||||||
|
?>
|
||||||
11
roles/webserver/defaults/main.yml
Normal file
11
roles/webserver/defaults/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
webserver_packages:
|
||||||
|
- httpd
|
||||||
|
- httpd-tools
|
||||||
|
- php
|
||||||
|
- php-fpm
|
||||||
|
- python3-libselinux
|
||||||
|
- python3-libsemanage
|
||||||
|
- tar
|
||||||
|
- zip
|
||||||
3
roles/webserver/files/phpinfo.php
Normal file
3
roles/webserver/files/phpinfo.php
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
phpinfo();
|
||||||
|
?>
|
||||||
6
roles/webserver/handlers/main.yml
Normal file
6
roles/webserver/handlers/main.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Restart webserver
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: httpd.service
|
||||||
|
state: restarted
|
||||||
21
roles/webserver/meta/main.yml
Normal file
21
roles/webserver/meta/main.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
galaxy_info:
|
||||||
|
author: Frank Agerholm
|
||||||
|
description: Webserver installation and Configuration
|
||||||
|
company: serverWg.de
|
||||||
|
|
||||||
|
issue_tracker_url: "https://git.serverwg.de/fager/ansible-demo-retwis/issues/new"
|
||||||
|
|
||||||
|
license: "GPL"
|
||||||
|
|
||||||
|
min_ansible_version: "2.11"
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- "7"
|
||||||
|
- "8"
|
||||||
|
- "9"
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
53
roles/webserver/tasks/main.yml
Normal file
53
roles/webserver/tasks/main.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
- name: Install all required Packages
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: "{{ webserver_packages }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure httpd is running
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: httpd.service
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Ensure php-fpm is running
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: php-fpm.service
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Set SELinux boolean httpd_can_network_connect to true
|
||||||
|
ansible.posix.seboolean:
|
||||||
|
name: httpd_can_network_connect
|
||||||
|
state: true
|
||||||
|
persistent: true
|
||||||
|
notify: Restart webserver
|
||||||
|
|
||||||
|
- name: Create start page
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: index.html
|
||||||
|
dest: /var/www/html/index.html
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Ensure Firewalld is running
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: firewalld.service
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Open Port 80/tcp in Firewall
|
||||||
|
ansible.posix.firewalld:
|
||||||
|
service: http
|
||||||
|
permanent: true
|
||||||
|
immediate: true
|
||||||
|
state: enabled
|
||||||
|
|
||||||
|
- name: Copy phpinfo.php to DocumentRoot
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: phpinfo.php
|
||||||
|
dest: /var/www/html/phpinfo.php
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
7
templates/index.html
Normal file
7
templates/index.html
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ ansible_hostname }}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ ansible_hostname }}
|
||||||
|
</body>
|
||||||
6
webserver_installation.yml
Normal file
6
webserver_installation.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Webserver configuration
|
||||||
|
hosts: webserver
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- webserver
|
||||||
Loading…
Add table
Add a link
Reference in a new issue