Git initial commit
This commit is contained in:
commit
fa681953f9
9
LICENSE
Executable file
9
LICENSE
Executable file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
3
README.md
Executable file
3
README.md
Executable file
@ -0,0 +1,3 @@
|
||||
# cloud-wordpress
|
||||
|
||||
Ansible role to provide a clean wordpress instance or multiple instances.
|
||||
24
defaults/main.yml
Executable file
24
defaults/main.yml
Executable file
@ -0,0 +1,24 @@
|
||||
---
|
||||
cloud_apps: /opt
|
||||
cloud_storage: /opt/storage
|
||||
cloud_stage: prod
|
||||
cloud_update: false
|
||||
download_folder: "{{ cloud_apps }}/download-tmp"
|
||||
shared_group: "cloud"
|
||||
|
||||
|
||||
www_root: /var/www
|
||||
www_group: www-data
|
||||
|
||||
web_sites:
|
||||
- domain: my-domain.tld
|
||||
state: present
|
||||
owner: user
|
||||
root: "{{ www_root }}/my-domain.tld"
|
||||
version: latest
|
||||
worpress: true
|
||||
db:
|
||||
type: mariadb
|
||||
name: db_name
|
||||
user: db_user
|
||||
pass: db_pass
|
||||
1
handlers/main.yml
Executable file
1
handlers/main.yml
Executable file
@ -0,0 +1 @@
|
||||
---
|
||||
19
meta/main.yml
Executable file
19
meta/main.yml
Executable file
@ -0,0 +1,19 @@
|
||||
---
|
||||
galaxy_info:
|
||||
role_name: wordpress
|
||||
namespace: hahn-cloud
|
||||
author: Lars Hahn
|
||||
company: OpenDevChain
|
||||
license: MIT
|
||||
description: Role to setup wordpress; shoudld be used in combination with an DB-, HTTP-Server and letsencrypt.
|
||||
min_ansible_version: 2.7
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- 10
|
||||
galaxy_tags:
|
||||
- wordpress
|
||||
dependencies:
|
||||
- mariadb
|
||||
- php
|
||||
- nginx
|
||||
25
tasks/main.yml
Executable file
25
tasks/main.yml
Executable file
@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: setup download folder
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ download_folder }}"
|
||||
|
||||
- name: setup wordpress folder
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ cloud_apps }}/wordpress"
|
||||
mode: 0770
|
||||
owner: "{{ www_group }}"
|
||||
group: "{{ shared_group }}"
|
||||
|
||||
- name: download latest wordpress version
|
||||
get_url:
|
||||
url: https://wordpress.org/latest.tar.gz
|
||||
dest: "{{ wordpress_latest_target }}"
|
||||
|
||||
- name: setup WordPress websites
|
||||
include_tasks: setup-wp.yml
|
||||
loop: "{{ web_sites | json_query('[?wordpress==`true`&&state==`present`]') }}"
|
||||
loop_control:
|
||||
loop_var: wp
|
||||
label: "{{ wp.domain }}"
|
||||
70
tasks/setup-wp.yml
Executable file
70
tasks/setup-wp.yml
Executable file
@ -0,0 +1,70 @@
|
||||
---
|
||||
- name: set WP related config options
|
||||
set_fact:
|
||||
local_wp_root: "{{ wp.root | default(www_root + '/' + wp.domain) }}"
|
||||
local_wp_owner: "{{ wp.owner | default('root') }}"
|
||||
local_wp_version: "{{ wp.version | default('latest') }}"
|
||||
|
||||
- name: "extract wordpress version {{ local_wp_version }} "
|
||||
unarchive:
|
||||
src: "{{ 'https://wordpress.org/wordpress-' + local_wp_version + '.tar.gz' if local_wp_version != 'latest' else wordpress_latest_target }}"
|
||||
dest: "/tmp"
|
||||
|
||||
- name: "extract wordpress archive to {{ local_wp_root }}"
|
||||
copy:
|
||||
remote_src: yes
|
||||
src: "/tmp/wordpress/"
|
||||
dest: "{{ local_wp_root }}"
|
||||
force: no
|
||||
mode: 770
|
||||
group: "{{ local_wp_owner }}"
|
||||
owner: "{{ www_group }}"
|
||||
|
||||
|
||||
- name: "adjust permissions for {{ local_wp_owner }}"
|
||||
file:
|
||||
path: "{{ local_wp_root }}"
|
||||
group: "{{ local_wp_owner }}"
|
||||
owner: "{{ www_group }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
|
||||
|
||||
- name: generate example config
|
||||
copy:
|
||||
remote_src: yes
|
||||
src: "{{ local_wp_root }}/wp-config-sample.php"
|
||||
dest: "{{ local_wp_root }}/wp-config.php"
|
||||
force: no
|
||||
group: "{{ local_wp_owner }}"
|
||||
owner: "{{ www_group }}"
|
||||
|
||||
- name: adjust WP-config
|
||||
lineinfile:
|
||||
path: "{{ local_wp_root }}/wp-config.php"
|
||||
regexp: "^define\\( '{{ item.conf }}'"
|
||||
line: "define( '{{ item.conf }}', '{{ item.data }}' );"
|
||||
loop:
|
||||
- conf: "DB_NAME"
|
||||
data: "{{ wp.db.name }}"
|
||||
- conf: "DB_USER"
|
||||
data: "{{ wp.db.user }}"
|
||||
- conf: "DB_PASSWORD"
|
||||
data: "{{ wp.db.pass }}"
|
||||
loop_control:
|
||||
label: "{{ item.conf }}"
|
||||
|
||||
- name: adjust permissions in WP root for directories
|
||||
changed_when: false
|
||||
command: 'find {{ local_wp_root }} -type d -exec chmod 770 {} \;'
|
||||
|
||||
- name: adjust permissions in WP root for files
|
||||
changed_when: false
|
||||
command: 'find {{ local_wp_root }} -type f -exec chmod 660 {} \;'
|
||||
|
||||
- name: link wordpress folder to non-root user
|
||||
file:
|
||||
src: "{{ local_wp_root }}"
|
||||
dest: "/home/{{ local_wp_owner }}/{{ wp.domain }}"
|
||||
state: link
|
||||
when: local_wp_owner != 'root'
|
||||
2
vars/main.yml
Executable file
2
vars/main.yml
Executable file
@ -0,0 +1,2 @@
|
||||
---
|
||||
wordpress_latest_target: "{{ download_folder }}/wordpress-latest.tar.gz"
|
||||
Loading…
Reference in New Issue
Block a user