I make a playbook in order to make alls updates available on my Wordpress serveurs.
It works but, I want to rewrite it with a loop to respect "Don't Repeat Yourself"
It is not a playbook. Just some tasks in roles > Intranet > tasks > main.yaml
---
# Main tasks for wordpress serveurs
# Updates
- name: Update WP command line tool
command: wp cli update
register: wpcli_result
- name: Update Wordpress Core
command: wp core update --allow-root --path=/var/www/html
register: update_core
- name: Update Wordpress Core Data Base
command: wp core update-db --allow-root --path=/var/www/html
register: update_core_db
- name: Update Plugins
command: wp plugin update --all --allow-root --path=/var/www/html
register: update_plugins
- name: Update Themes
command: wp theme update --all --allow-root --path=/var/www/html
register: update_themes
...
# Debug
- name: Debug wp cli update
ansible.builtin.debug:
var: wpcli_result.stdout
- name: Debug wp Core update
ansible.builtin.debug:
var: update_core.stdout
- name: Debug wp Core update data base
ansible.builtin.debug:
var: update_core_db.stdout
- name: Debug wp plugins update
ansible.builtin.debug:
var: update_plugins.stdout
- name: Debug wp Themes update
ansible.builtin.debug:
var: update_themes.stdout
...
# Call to Zabbix tasks
- include: zabbix.yml
question from:https://stackoverflow.com/questions/65842706/how-to-rewrite-this-ansible-playbook-with-a-loop