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