--- # tasks file for wordpress - name: install packages apt: name={{item}} with_items: - libapache2-mod-php5 #for ansible mysql_db: - python-mysqldb #for wordpress plugins - unzip #for wordpress - libphp-phpmailer - php-getid3 - php5-gd - php5-mysql - name: create wordpress directory file: path: /srv/{{ wp_domain }} state: directory - name: Extract wordpress archive unarchive: src: packages/wordpress-{{ wp_version }}.tgz dest: /srv/{{ wp_domain }} creates: /srv/{{ wp_domain }}/wordpress - name: Extract rest api plugin archive unarchive: src: packages/rest-api.2.0-{{ wp_rest_api_version }}.zip dest: /srv/{{ wp_domain }}/wordpress/wp-content/plugins creates: /srv/{{ wp_domain }}/wordpress/wp-content/plugins/rest-api - name: clone application-passwords plugin git git: repo: https://github.com/georgestephanis/application-passwords.git dest: /srv/{{ wp_domain }}/wordpress/wp-content/plugins/application-passwords - name: Create database mysql_db: name: "{{ wp_db_name }}" state: present - name: Create database user mysql_user: name: "{{ wp_db_user }}" password: "{{ wp_db_password }}" priv: "{{ wp_db_name }}.*:ALL" host: "{{ wp_db_host }}" state: present - name: create config file template: src=wp-config.php.jinja2 dest=/srv/{{ wp_domain }}/wordpress/wp-config.php - name: Change ownership of installation directory file: path=/srv/{{ wp_domain }}/wordpress owner=www-data group=www-data mode=775 state=directory recurse=yes - name: Change ownership of wp-content directory file: path=/srv/{{ wp_domain }}/wordpress/wp-content/ owner=www-data group=www-data mode=755 state=directory recurse=yes - name: Apache | Copy virtual host configuration file template: src=apache-vhost.conf.jinja2 dest=/etc/apache2/sites-available/{{wp_domain}}.conf owner=root group=root mode=0644 notify: restart apache - name: Apache | Symlink virtual host configuration file from sites-available to sites-enabled file: state=link src=/etc/apache2/sites-available/{{wp_domain}}.conf dest=/etc/apache2/sites-enabled/000-default.conf owner=root group=root mode=0644 # overwrite of 000-default.conf is necessary when wp_domain is fqdn notify: restart apache - name: Apache | Symlink virtual host configuration file from sites-available to sites-enabled file: state=link src=/etc/apache2/sites-available/{{wp_domain}}.conf dest=/etc/apache2/sites-enabled/{{wp_domain}}.conf owner=root group=root mode=0644 notify: restart apache - name: check syntax of apache httpd configuration command: /usr/sbin/apache2ctl configtest notify: - start apache