---
# This playbook installs and configures WordPress

- name: Download WordPress
  get_url: url=http://wordpress.org/latest.tar.gz dest=/srv/latest.tar.gz

- name: Extract archive
  command: chdir=/srv/ /bin/tar xvf latest.tar.gz creates=/srv/wordpress

- name: Add group "wordpress"
  group: name=wordpress

- name: Add user "wordpress"
  user: name=wordpress group=wordpress home=/srv/wordpress/

- name: Fetch random salts for Wordpress config
  local_action: command curl https://api.wordpress.org/secret-key/1.1/salt/
  register: "wp_salt"
  sudo: no

- name: Create Wordpress database
  mysql_db: name={{ wp_db_name }} state=present

- name: Create Wordpress database user
  mysql_user: name={{ wp_db_user }} password={{ wp_db_password }} priv={{ wp_db_name }}.*:ALL host='localhost' state=present

- name: Copy Wordpress config file
  template: src=wp-config.php dest=/srv/wordpress/

- name: Change ownership of Wordpress installation
  file: path=/srv/wordpress/ owner=wordpress group=wordpress state=directory recurse=yes

- name: Update Apache2 sites configuration
  copy: src=default dest=/etc/apache2/sites-available/default
  notify: restart apache2

---
# This playbook installs and configures WordPress

- name: Download WordPress
  get_url: url=http://wordpress.org/latest.tar.gz dest=/srv/latest.tar.gz

- name: Extract archive
  command: chdir=/srv/ /bin/tar xvf latest.tar.gz creates=/srv/wordpress/readme.html

- name: Add group "wordpress"
  group: name=wordpress

- name: Add user "wordpress"
  user: name=wordpress group=wordpress home=/srv/wordpress/

- name: Fetch random salts for Wordpress config
  local_action: command curl https://api.wordpress.org/secret-key/1.1/salt/
  register: "wp_salt"
  sudo: no

- name: Create Wordpress database
  mysql_db: name={{ wp_db_name }} state=present

- name: Create Wordpress database user
  mysql_user: name={{ wp_db_user }} password={{ wp_db_password }} priv={{ wp_db_name }}.*:ALL host='localhost' state=present

- name: Copy Wordpress config file
  template: src=wp-config.php dest=/srv/wordpress/

- name: Change ownership of Wordpress installation
  file: path=/srv/wordpress/ owner=wordpress group=wordpress state=directory recurse=yes

- name: Update Apache2 sites configuration
  copy: src=default dest=/etc/apache2/sites-available/default
  notify: restart apache2

Change creates check due to folder is already created with synced
Change creates check due to folder is already created with synced
