Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Added variable to disable the installation of WordPress
Browse files Browse the repository at this point in the history
Fixes #59
  • Loading branch information
tobeycodes authored and carlalexander committed Apr 11, 2016
1 parent ca44e5e commit a9018c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ v0.2.0

*Unreleased*

- Added ``wordpress_install_enabled`` variable so that you can disable
the installation of WordPress. [schrapel]

- Added ``wordpress_fail2ban_enabled`` variable so that you can disable
the installation and configuration of fail2ban. [carlalexander]

Expand Down
5 changes: 5 additions & 0 deletions roles/wordpress/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# Should the ``carlalexander.wordpress`` role manage it's own dependencies (database, web server)?
wordpress_dependencies: True

# .. envvar:: wordpress_install_enabled
#
# Should the ``carlalexander.wordpress`` role install WordPress?
wordpress_install_enabled: True

# .. envvar:: wordpress_password_length
#
# Length of randomly generated passwords (it's a string).
Expand Down
12 changes: 8 additions & 4 deletions roles/wordpress/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
owner: '{{ wordpress_user }}'
group: '{{ wordpress_group }}'
mode: '0755'
when: wordpress_install_enabled

- name: Configure wp-cli
template:
Expand All @@ -17,6 +18,7 @@
owner: '{{ wordpress_user }}'
group: '{{ wordpress_group }}'
mode: '0644'
when: wordpress_install_enabled

- name: Check if WordPress is installed
command: 'wp core is-installed'
Expand All @@ -26,38 +28,39 @@
register: wordpress_installed
changed_when: False
failed_when: False
when: wordpress_install_enabled

- name: Download WordPress
command: 'wp core download'
become_user: '{{ wordpress_user }}'
args:
chdir: '{{ wordpress_root }}'
creates: '{{ wordpress_root }}/index.php'
when: wordpress_installed is defined and wordpress_installed.rc == 1
when: wordpress_installed is defined and wordpress_installed.rc == 1 and wordpress_install_enabled

- name: Configure WordPress
command: 'wp core config --dbhost="{{ wordpress_database_host }}" --dbname="{{ wordpress_database_name }}" --dbuser="{{ wordpress_database_user }}" --dbpass="{{ wordpress_database_password }}" --dbprefix="{{ wordpress_table_prefix }}"'
become_user: '{{ wordpress_user }}'
args:
chdir: '{{ wordpress_root }}'
creates: '{{ wordpress_root }}/wp-config.php'
when: wordpress_installed is defined and wordpress_installed.rc == 1
when: wordpress_installed is defined and wordpress_installed.rc == 1 and wordpress_install_enabled

- name: Install WordPress
command: 'wp core install --title="{{ wordpress_title }}" --admin_user="{{ wordpress_admin_username }}" --admin_password="{{ wordpress_admin_password }}" --admin_email="{{ wordpress_admin_email }}"'
become_user: '{{ wordpress_user }}'
args:
chdir: '{{ wordpress_root }}'
when: ((wordpress_installed is defined and wordpress_installed.rc == 1) and
(wordpress_multisite is defined and not wordpress_multisite))
(wordpress_multisite is defined and not wordpress_multisite)) and wordpress_install_enabled

- name: Install WordPress Multisite
command: 'wp core multisite-install --base="{{ wordpress_multisite_path }}" {{ "--subdomains" if wordpress_multisite_subdomains else "" }} --title="{{ wordpress_title }}" --admin_user="{{ wordpress_admin_username }}" --admin_password="{{ wordpress_admin_password }}" --admin_email="{{ wordpress_admin_email }}"'
become_user: '{{ wordpress_user }}'
args:
chdir: '{{ wordpress_root }}'
when: ((wordpress_installed is defined and wordpress_installed.rc == 1) and
(wordpress_multisite is defined and wordpress_multisite))
(wordpress_multisite is defined and wordpress_multisite)) and wordpress_install_enabled

- name: Schedule regular calls to wp-cron.php
cron:
Expand All @@ -68,3 +71,4 @@

- include: manage_plugins.yml
tags: [ 'role::wordpress:plugins' ]
when: wordpress_install_enabled

0 comments on commit a9018c7

Please sign in to comment.