Skip to content

Commit

Permalink
Use variable name that doesn't conflict with Ansible internals
Browse files Browse the repository at this point in the history
  • Loading branch information
bviktor committed Apr 18, 2023
1 parent 24f6afc commit ce9781b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This role lets you perform various tasks on your WordPress instances.

| Name | Required | Example | Description |
|---|---|---|---|
| `path` | no | `/var/www/html/wordpress` | Path to your WordPress instance. Only optional if no other parameters are passed. |
| `update` | no | `true` | If `true`, the specified WP instance is updated to the latest version. |
| `path` | no | `/var/www/html/wordpress` | Path to your WordPress instance. Only optional if `dry_run` is `true`. |
| `dry_run` | no | `true` | If `true`, only the required tools are installed, but the upgrade itself is not performed. Defaults to `false`. |

## Examples

Expand All @@ -18,7 +18,7 @@ This role lets you perform various tasks on your WordPress instances.
name: bviktor.wordpress
vars:
path: '/var/www/html/wordpress'
update: yes
dry_run: false
```
## Return Values
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
when: installed_wpcli is not defined

- include_tasks: update.yml
when: update is defined and update | bool
when: not eff_dry_run | bool
10 changes: 6 additions & 4 deletions tests/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
- hosts: 127.0.0.1
tasks:

# Dry run, var casting, obtain CLI tools
- include_role:
name: "{{ playbook_dir.split('/')[:-1] | last }}"
vars:
dry_run: "true"

- include_tasks: install.yml

# Initial run, var casting
# Live run, var casting
- include_role:
name: "{{ playbook_dir.split('/')[:-1] | last }}"
vars:
path: /var/www/html/wordpress
update: "true"
dry_run: "false"

# Idempotency
# Idempotency, default value
- include_role:
name: "{{ playbook_dir.split('/')[:-1] | last }}"
vars:
path: /var/www/html/wordpress
update: true
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ wp_up_core_str: 'Success: WordPress is at the latest version.'
wp_up_db_str: 'Success: WordPress database already at latest db version'
wp_up_plugin_str: 'Success: Plugin already updated.'
wp_up_theme_str: 'Success: Theme already updated.'

eff_dry_run: "{{ dry_run | default(false) | bool }}"

0 comments on commit ce9781b

Please sign in to comment.