ansible-wordpress-host-init/roles/install-wordpress/tasks/main.yml

60 lines
1.2 KiB
YAML
Raw Normal View History

2023-03-27 16:24:16 +00:00
---
- name: Task name
stat:
path: /var/www/{{ vhost_name }}
register: project_dir
2023-04-07 16:22:32 +00:00
- name: Create wwwroot
file:
path: /var/www/{{ vhost_name }}
state: directory
mode: '0755'
when: not project_dir.stat.exists
2023-03-27 16:24:16 +00:00
- name: Download latest WP
get_url:
url: https://wordpress.org/latest.zip
2023-03-28 08:24:45 +00:00
dest: /tmp/latest.zip
2023-03-27 16:24:16 +00:00
mode: '0660'
when: not project_dir.stat.exists
2023-03-27 16:24:16 +00:00
- name: Extract wordpress
unarchive:
2023-03-28 08:24:45 +00:00
src: /tmp/latest.zip
dest: /var/www/
2023-03-27 16:24:16 +00:00
remote_src: yes
when: not project_dir.stat.exists
2023-03-27 16:24:16 +00:00
- name: Delete the wordpress zip
file:
state: absent
2023-03-28 08:24:45 +00:00
path: /tmp/latest.zip
when: not project_dir.stat.exists
2023-03-27 16:38:19 +00:00
2023-03-28 08:24:45 +00:00
- name: Create wwwroot
2023-03-27 16:38:19 +00:00
file:
2023-03-28 08:24:45 +00:00
path: /var/www/{{ vhost_name}}
state: directory
mode: '0755'
when: not project_dir.stat.exists
2023-03-28 08:24:45 +00:00
- name: Rename folder
shell: mv /var/www/wordpress/* /var/www/{{ vhost_name }}/
when: not project_dir.stat.exists
2023-03-28 08:24:45 +00:00
- name: Delete old folder
file:
path: /var/www/wordpress
state: absent
when: not project_dir.stat.exists
2023-03-28 08:24:45 +00:00
- name: Chown
become: true
shell: chown -R www-data:www-data /var/www/{{ vhost_name }}
when: not project_dir.stat.exists
2023-03-28 08:24:45 +00:00
- name: Chmod
become: true
shell: chmod -R 755 /var/www/{{ vhost_name }}
when: not project_dir.stat.exists