--- - 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: Files permission become: true shell: "/usr/bin/find /var/www/{{ vhost_name }}/ -type f -exec chmod 640 {} \\;" when: not project_dir.stat.exists - name: Directory permissions become: true shell: "/usr/bin/find /var/www/{{ vhost_name }}/ -type d -exec chmod 750 {} \\;" when: not project_dir.stat.exists