Don't download WP if project_dir exists

This commit is contained in:
David Petric 2023-04-07 18:19:36 +02:00
parent 17a8185f97
commit cb91f1a9fe

View File

@ -1,39 +1,52 @@
--- ---
- name: Task name
stat:
path: /var/www/{{ vhost_name }}
register: project_dir
- name: Download latest WP - name: Download latest WP
get_url: get_url:
url: https://wordpress.org/latest.zip url: https://wordpress.org/latest.zip
dest: /tmp/latest.zip dest: /tmp/latest.zip
mode: '0660' mode: '0660'
when: not project_dir.stat.exists
- name: Extract wordpress - name: Extract wordpress
unarchive: unarchive:
src: /tmp/latest.zip src: /tmp/latest.zip
dest: /var/www/ dest: /var/www/
remote_src: yes remote_src: yes
when: not project_dir.stat.exists
- name: Delete the wordpress zip - name: Delete the wordpress zip
file: file:
state: absent state: absent
path: /tmp/latest.zip path: /tmp/latest.zip
when: not project_dir.stat.exists
- name: Create wwwroot - name: Create wwwroot
file: file:
path: /var/www/{{ vhost_name}} path: /var/www/{{ vhost_name}}
state: directory state: directory
mode: '0755' mode: '0755'
when: not project_dir.stat.exists
- name: Rename folder - name: Rename folder
shell: mv /var/www/wordpress/* /var/www/{{ vhost_name }}/ shell: mv /var/www/wordpress/* /var/www/{{ vhost_name }}/
when: not project_dir.stat.exists
- name: Delete old folder - name: Delete old folder
file: file:
path: /var/www/wordpress path: /var/www/wordpress
state: absent state: absent
when: not project_dir.stat.exists
- name: Chown - name: Chown
become: true become: true
shell: chown -R www-data:www-data /var/www/{{ vhost_name }} shell: chown -R www-data:www-data /var/www/{{ vhost_name }}
when: not project_dir.stat.exists
- name: Chmod - name: Chmod
become: true become: true
shell: chmod -R 755 /var/www/{{ vhost_name }} shell: chmod -R 755 /var/www/{{ vhost_name }}
when: not project_dir.stat.exists