Skip to content

Commit

Permalink
Merge pull request #34 from Oefenweb/consistency-changes
Browse files Browse the repository at this point in the history
Consistency changes
  • Loading branch information
tersmitten committed Sep 17, 2015
2 parents 0295d62 + 7089c2f commit 484c037
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 90 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:

env:
- ANSIBLE_VERSION=latest
- ANSIBLE_VERSION=1.9.3
- ANSIBLE_VERSION=1.9.2
- ANSIBLE_VERSION=1.9.1
- ANSIBLE_VERSION=1.9.0.1
- ANSIBLE_VERSION=1.8.4
Expand Down Expand Up @@ -75,9 +77,6 @@ install:
# Install Ansible.
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi

# Add ansible.cfg to pick up roles path.
- printf "[defaults]\nroles_path = ../" > ansible.cfg

script:
# Check the role/playbook's syntax.
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check
Expand Down
10 changes: 8 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

role = File.basename(File.expand_path(File.dirname(__FILE__)))

File.open(File.dirname(__FILE__) + '/ansible.cfg', 'w') { |f| f.write("[defaults]\nroles_path = ../") }

boxes = [
{
:name => "ubuntu-1004",
Expand Down Expand Up @@ -46,6 +44,14 @@ boxes = [
:cpu => "50",
:ram => "256"
},
{
:name => "debian-81",
:box => "opscode-debian-8.1",
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.1_chef-provisionerless.box",
:ip => '10.0.0.15',
:cpu => "50",
:ram => "256"
},
]

Vagrant.configure("2") do |config|
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ galaxy_info:
versions:
- squeeze
- wheezy
- jessie
categories:
- web
dependencies: []
1 change: 0 additions & 1 deletion tasks/chown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
group: "{{ item.group | default(item.owner) | default('www-data') }}"
recurse: true
with_items: wordpress_installs
tags: [configuration, wordpress, wordpress-chown]
50 changes: 28 additions & 22 deletions tasks/core.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
# tasks file for wordpress, core
---
- name: check download
- name: core | check download
shell: "ls {{ item.path }} | grep -q 'wp-'"
register: check_download
failed_when: False
changed_when: False
failed_when: false
changed_when: false
with_items: wordpress_installs
tags: [configuration, wordpress, wordpress-core, wordpress-is-downloaded]
tags:
- wordpress-core-is-downloaded

- name: download
shell: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' core download"
- name: core | download
command: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' core download"
with_items: check_download.results
when: item.rc != 0
tags: [configuration, wordpress, wordpress-core, wordpress-downloaded]
tags:
- wordpress-core-downloaded

- name: configure
shell: "wp-cli --allow-root --no-color --path='{{ item.path }}' core config --dbname='{{ item.dbname }}' --dbuser='{{ item.dbuser }}' --dbpass='{{ item.dbpass }}' --dbhost='{{ item.dbhost | default('localhost') }}'"
- name: core | configure
command: "wp-cli --allow-root --no-color --path='{{ item.path }}' core config --dbname='{{ item.dbname }}' --dbuser='{{ item.dbuser }}' --dbpass='{{ item.dbpass }}' --dbhost='{{ item.dbhost | default('localhost') }}'"
args:
creates: "{{ item.path }}/wp-config.php"
with_items: wordpress_installs
tags: [configuration, wordpress, wordpress-core, wordpress-configure]
tags:
- wordpress-core-configure

- name: identify installation
shell: "wp-cli --allow-root --no-color --path='{{ item.path }}' core is-installed"
- name: core | identify installation
command: "wp-cli --allow-root --no-color --path='{{ item.path }}' core is-installed"
register: check_installation
failed_when: False
changed_when: False
failed_when: false
changed_when: false
with_items: wordpress_installs
tags: [configuration, wordpress, wordpress-core, wordpress-is-installed]
tags:
- wordpress-core-is-installed

- name: install
shell: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' core install --url='{{ item.item.url }}' --title='{{ item.item.title }}' --admin_name='{{ item.item.admin_name | default('admin') }}' --admin_email='{{ item.item.admin_email }}' --admin_password='{{ item.item.admin_password }}'"
- name: core | install
command: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' core install --url='{{ item.item.url }}' --title='{{ item.item.title }}' --admin_name='{{ item.item.admin_name | default('admin') }}' --admin_email='{{ item.item.admin_email }}' --admin_password='{{ item.item.admin_password }}'"
with_items: check_installation.results
when: item.rc != 0
tags: [configuration, wordpress, wordpress-core, wordpress-install]
tags:
- wordpress-core-install

- name: check install
shell: "wp-cli --allow-root --no-color --path='{{ item.path }}' core is-installed"
changed_when: False
- name: core | check install
command: "wp-cli --allow-root --no-color --path='{{ item.path }}' core is-installed"
changed_when: false
with_items: wordpress_installs
tags: [configuration, wordpress, wordpress-core, wordpress-install-check]
tags:
- wordpress-core-install-check
34 changes: 34 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
# tasks file for wordpress
---
- include: wp-cli.yml
tags:
- configuration
- wordpress
- wordpress-wp-cli

- include: core.yml
tags:
- configuration
- wordpress
- wordpress-core

- include: themes.yml
tags:
- configuration
- wordpress
- wordpress-themes

- include: plugins.yml
tags:
- configuration
- wordpress
- wordpress-plugins

- include: users.yml
tags:
- configuration
- wordpress
- wordpress-users

- include: options.yml
tags:
- configuration
- wordpress
- wordpress-options

- include: chown.yml
tags:
- configuration
- wordpress
- wordpress-chown
32 changes: 8 additions & 24 deletions tasks/options.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# tasks file for wordpress, options
---
- name: disable w3c's object cache
lineinfile:
dest: "{{ item.path }}/wp-config.php"
line: "/** ansible-wordpress */ define('DONOTCACHCEOBJECT', true);"
validate: "php -l %s"
with_items: wordpress_installs
changed_when: false
tags: [configuration, wordpress, wordpress-options]

- name: add options
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' option {{ item.1.command }} '{{ item.1.name }}' '{{ item.1.value }}'"
register: check_installation_options
failed_when: False
failed_when: false
changed_when: "'Added' in check_installation_options.stdout"
with_subelements:
- wordpress_installs
- options
when: item.1.command == 'add'
tags: [configuration, wordpress, wordpress-options]
tags:
- wordpress-options-add

- name: update options
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' option {{ item.1.command }} '{{ item.1.name }}' '{{ item.1.value }}'"
Expand All @@ -28,25 +20,17 @@
- wordpress_installs
- options
when: item.1.command == 'update'
tags: [configuration, wordpress, wordpress-options]
tags:
- wordpress-options-update

- name: delete options
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' option {{ item.1.command }} '{{ item.1.name }}'"
register: check_installation_options
failed_when: False
failed_when: false
changed_when: "'Could not delete' not in check_installation_options.stderr"
with_subelements:
- wordpress_installs
- options
when: item.1.command == 'delete'
tags: [configuration, wordpress, wordpress-options]

- name: enable w3c's object cache
lineinfile:
dest: "{{ item.path }}/wp-config.php"
line: "/** ansible-wordpress */ define('DONOTCACHCEOBJECT', true);"
validate: "php -l %s"
state: absent
with_items: wordpress_installs
changed_when: false
tags: [configuration, wordpress, wordpress-options]
tags:
- wordpress-options-delete
31 changes: 18 additions & 13 deletions tasks/plugins.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
# tasks file for wordpress, plugins
---
- name: identify installation (plugin)
- name: plugins | identify installation
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' plugin is-installed {{ item.1.name }}"
register: check_installation_plugins
failed_when: False
changed_when: False
failed_when: false
changed_when: false
with_subelements:
- wordpress_installs
- plugins
when: item.1
tags: [configuration, wordpress, wordpress-plugins, wordpress-is-installed-plugin]
tags:
- wordpress-plugins-is-installed-plugin

- name: install (plugin)
- name: plugins | install
command: "wp-cli --allow-root --no-color --path='{{ item.item.0.path }}' plugin install {{ item.item.1.name }}"
with_items: check_installation_plugins.results
when: check_installation_plugins is defined and item.item.1.name and item.rc != 0
tags: [configuration, wordpress, wordpress-plugins, wordpress-install-plugin]
tags:
- wordpress-plugins-install-plugin

- name: check install (plugin)
- name: plugins | check install
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' plugin is-installed {{ item.1.name }}"
changed_when: False
changed_when: false
with_subelements:
- wordpress_installs
- plugins
when: item.1.name
tags: [configuration, wordpress, wordpress-plugins, wordpress-install-plugin-check]
tags:
- wordpress-plugins-check-install-plugin

- name: activate (plugin)
- name: plugins | activate
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' plugin activate {{ item.1.name }}"
register: check_activate_plugin
changed_when: "'Success: Plugin' in check_activate_plugin.stdout"
with_subelements:
- wordpress_installs
- plugins
when: item.1.name and item.1.activate | default(true)
tags: [configuration, wordpress, wordpress-plugins, wordpress-activate-plugin]
tags:
- wordpress-plugins-activate-plugin

- name: deactivate (plugin)
- name: plugins | deactivate
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' plugin deactivate {{ item.1.name }}"
register: check_activate_plugin
changed_when: "'Success: Plugin' in check_activate_plugin.stdout"
with_subelements:
- wordpress_installs
- plugins
when: item.1.name and not item.1.activate | default(true)
tags: [configuration, wordpress, wordpress-plugins, wordpress-deactivate-plugin]
tags:
- wordpress-plugins-deactivate-plugin
26 changes: 15 additions & 11 deletions tasks/themes.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# tasks file for wordpress, themes
---
- name: identify installation (theme)
- name: themes | identify installation
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' theme is-installed {{ item.1.name }}"
register: check_installation_themes
failed_when: False
changed_when: False
failed_when: false
changed_when: false
with_subelements:
- wordpress_installs
- themes
when: item.1.name
tags: [configuration, wordpress, wordpress-themes, wordpress-is-installed-theme]
tags:
- wordpress-themes-is-installed-theme

- name: install (theme)
- name: themes | install
command: "wp-cli --allow-root --no-color --path='{{ item.item.0.path }}' theme install {{ item.item.1.name }}"
with_items: check_installation_themes.results
when: check_installation_themes is defined and item.item.1.name and item.rc != 0
tags: [configuration, wordpress, wordpress-themes, wordpress-install-theme]
tags:
- wordpress-themes-install-theme

- name: check install (theme)
- name: themes | check install
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' theme is-installed {{ item.1.name }}"
changed_when: False
changed_when: false
with_subelements:
- wordpress_installs
- themes
when: item.1.name
tags: [configuration, wordpress, wordpress-themes, wordpress-install-theme-check]
tags:
- wordpress-themes-install-theme-check

- name: activate (theme)
- name: themes | activate
command: "wp-cli --allow-root --no-color --path='{{ item.0.path }}' theme activate {{ item.1.name }}"
register: check_activate_theme
changed_when: "'Success: Switched to' in check_activate_theme.stdout"
with_subelements:
- wordpress_installs
- themes
when: item.1.name and item.1.activate | default(false)
tags: [configuration, wordpress, wordpress-themes, wordpress-activate-theme]
tags:
- wordpress-themes-activate-theme
17 changes: 10 additions & 7 deletions tasks/users.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# tasks file for wordpress, users
---
- name: create (data) directory
- name: users | create (data) directory
file:
path: "{{ wordpress_data_path }}"
state: directory
owner: root
group: root
mode: 0755
tags: [configuration, wordpress, wordpress-users]
tags:
- wordpress-users-create-data-directory

- name: copy file (users)
- name: users | copy file
copy:
src: "{{ item.users.src }}"
dest: "{{ wordpress_data_path }}/{{ item.dbname }}.csv"
Expand All @@ -19,12 +20,14 @@
register: check_copy_users
with_items: wordpress_installs
when: item.users.src is defined
tags: [configuration, wordpress, wordpress-users]
tags:
- wordpress-users-copy-file

- name: install (users)
shell: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' user import-csv {{ wordpress_data_path }}/{{ item.item.dbname }}.csv {{ '--skip-update' if item.item.users.skip_update | default(true) else '' }} --send-email"
- name: users | install
command: "wp-cli --allow-root --no-color --path='{{ item.item.path }}' user import-csv {{ wordpress_data_path }}/{{ item.item.dbname }}.csv {{ '--skip-update' if item.item.users.skip_update | default(true) else '' }} --send-email"
register: check_installation_users
changed_when: "'Success' in check_installation_users.stdout"
with_items: check_copy_users.results
when: check_copy_users is defined and item.changed
tags: [configuration, wordpress, wordpress-users]
tags:
- wordpress-users-import-file
Loading

0 comments on commit 484c037

Please sign in to comment.