-
Notifications
You must be signed in to change notification settings - Fork 9
/
site.yml
89 lines (79 loc) · 2.69 KB
/
site.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
- name: check that hosts meet the basic requirements
gather_facts: false
hosts: all
pre_tasks:
- name: check if some version of Python is installed and accessible
raw: >-
command -v python3 || command -v python
changed_when: false
- name: Gather facts for later tasks
setup:
tasks:
- name: check if host OS is supported
fail:
msg: >-
{{ ansible_distribution }} {{ ansible_distribution_version }}
is not supported.
changed_when: false
failed_when: >-
ansible_distribution not in targets.keys()
or (ansible_distribution_release not in target_versions
and ansible_distribution_version not in target_versions
and ansible_distribution_major_version not in target_versions)
vars:
targets:
CentOS: ["7.6", "7.7", "7.8", "7.9", "8"]
Debian: ["stretch", "buster"]
Ubuntu: ["bionic", "focal"]
target_versions: "{{ targets[ansible_distribution] }}"
- name: check if this host is managed by Ansible
command: >-
ls /etc/ansible/wordpress-ultrastack
changed_when: ansible_deployed.rc > 0
failed_when: false
register: ansible_deployed
- name: check if core LAMP services are present
command: >-
command -v {{ item }}
changed_when: lamp_installed.rc < 1
failed_when: false
register: lamp_installed
when: ansible_deployed.changed
with_items:
- apachectl
- mysql
- php
- php-fpm
- name: fail if Ansible isn't managing this host
fail:
msg: >-
Core LAMP services are installed, but this host isn't
managed by Ansible! This playbook is intended to be run on
hosts that are not already configured. Please remove the
following packages: Apache, PHP, PHP-FPM, MySQL
when:
- ansible_deployed.changed
- lamp_installed.changed
- name: Deploy WordPress to defined hosts in the 'wordpress' group
hosts: wordpress
pre_tasks:
- name: Create /etc/ansible
file:
path: /etc/ansible
state: directory
- name: Add file confirming this host is managed by Ansible
file:
path: /etc/ansible/wordpress-ultrastack
access_time: preserve
modification_time: preserve
state: touch
roles:
- role: inmotionhosting.apache
- role: inmotionhosting.mysql
- role: inmotionhosting.php_fpm
- role: inmotionhosting.letsencrypt
when: use_letsencrypt is defined and use_letsencrypt
- role: inmotionhosting.wordpress
- role: inmotionhosting.wordpress_ultrastack
when: use_ultrastack is defined and use_ultrastack