websoft9/apps/roles/wordpress/tasks/main.yml
2022-11-30 10:00:43 +08:00

47 lines
2.0 KiB
YAML

- name: Install {{appname}}
include_tasks: tasks/install.yml
vars:
app: "wordpress"
- block:
- name: Create backup directory
shell: |
mkdir -p /data/apps/wordpress/data/backup/plugins
mkdir -p /data/apps/wordpress/data/backup/themes
- name: Download wp-cli
shell: |
cd /data/apps/wordpress/data/backup
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar wp
- block:
- name: Download {{wordpress_solution}} theme to host machine
unarchive:
src: "{{wordpress_theme_download_url}}/{{wordpress_solution}}/{{wordpress_theme_meta[wordpress_solution].theme}}.zip"
dest: /data/apps/wordpress/data/backup/themes
remote_src: yes
- name: Download plugin to host machine
unarchive:
src: "{{wordpress_theme_download_url}}/{{wordpress_solution}}/{{item}}.zip"
dest: /data/apps/wordpress/data/backup/plugins
remote_src: yes
with_items:
- "{{wordpress_theme_meta[wordpress_solution].plugin}}"
when: wordpress_theme_meta[wordpress_solution].plugin !=""
- name: Install theme and plugins
shell: |
echo "cp -r /data/apps/wordpress/data/backup/plugins/* /data/apps/wordpress/data/wordpress/wp-content/plugins" >> /data/apps/{{appname}}/src/after_up.sh
echo "cp -r /data/apps/wordpress/data/backup/themes/* /data/apps/wordpress/data/wordpress/wp-content/themes" >> /data/apps/{{appname}}/src/after_up.sh
echo "sudo sed -i 's/twentytwentythree/{{wordpress_solution}}/g' /data/apps/wordpress/data/wordpress/wp-includes/default-constants.php" >> /data/apps/{{appname}}/src/after_up.sh
echo "docker restart wordpress" >> /data/apps/{{appname}}/src/after_up.sh
when: wordpress_solution != "" and wordpress_solution != "multisite"
- name: Set the multisite solution(TODO)
shell:
echo "add line [define( 'WP_ALLOW_MULTISITE', true );] to wp-config.php" >> /data/apps/{{appname}}/src/after_up.sh
when: wordpress_solution == "multisite"