--- - name: Apache and php 5 package: name="{{ item }}" state=latest update_cache=yes with_items: - apache2 - php5 - php5-mysql - php5-gd - nfs-common - unzip - ssmtp when: ansible_distribution == 'Ubuntu' and ansible_distribution_version < '16.04' - name: Apache and php 7 package: name="{{ item }}" state=latest update_cache=yes with_items: - apache2 - php7.0 - php7.0-mysql - libapache2-mod-php7.0 - php7.0-cli - php7.0-cgi - php7.0-gd - nfs-common - unzip - ssmtp when: ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '16.04' - name: Apache and php 5 package: name="{{ item }}" state=latest with_items: - httpd - php - php-mysqlnd - php5-gd - nfs-utils - unzip - ssmtp when: ansible_distribution == 'Fedora' - shell: rm -rf /var/www/html/index.html args: warn: no - name: Enable mod_rewrite apache2_module: name=rewrite state=present - name: Enable htaccess blockinfile: dest: /etc/apache2/sites-enabled/000-default.conf insertafter: "DocumentRoot /var/www/html" content: | AllowOverride All RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] - name: Creates share directory for wpcontent file: path: /var/www/html/wp-content state: directory owner: www-data group: www-data when: ansible_distribution == 'Ubuntu' - name: Creates share directory for wpcontent file: path: /var/www/html/wp-content state: directory owner: apache group: apache when: ansible_distribution == 'Fedora' - name: Mount the directory using private IP mount: name: /var/www/html/wp-content src: "{{ hostvars.cloud.database.openstack.private_v4 }}:/storage/wpcontent" state: mounted fstype: nfs when: hostvars.cloud.database.openstack.private_v4 != "" - name: Mount the directory using public IP mount: name: /var/www/html/wp-content src: "{{ hostvars.cloud.database.openstack.public_v4 }}:/storage/wpcontent" state: mounted fstype: nfs when: hostvars.cloud.database.openstack.private_v4 == "" - lineinfile: dest=/etc/apache2/apache2.conf line="ServerName localhost" when: ansible_distribution == 'Ubuntu' - lineinfile: dest=/etc/httpd/conf/httpd.conf line="ServerName localhost" when: ansible_distribution == 'Fedora' - name: Download wordpress get_url: url: "{{ app_env.wp_latest | default('https://wordpress.org/wordpress-4.6.1.tar.gz') }}" dest: /var/www/latest.tar.gz force: no - name: Unpack latest wordpress shell: tar -xf /var/www/latest.tar.gz -C /var/www/html --strip-components=1 args: warn: no - name: Create wordpress configuration shell: cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php args: warn: no - name: Configure wordpress database, username and password replace: dest: /var/www/html/wp-config.php regexp: "'{{ item.then }}'" replace: "'{{ item.now }}'" backup: no with_items: - { then: 'database_name_here', now: 'decision2016' } - { then: 'username_here', now: "{{ db_user }}" } - { then: 'password_here', now: "{{ db_pass }}" } - name: Configure wordpress network access using private IP replace: dest: /var/www/html/wp-config.php regexp: "'localhost'" replace: "'{{ hostvars.cloud.database.openstack.private_v4 }}'" backup: no when: hostvars.cloud.database.openstack.private_v4 != "" - name: Configure wordpress network access using public IP replace: dest: /var/www/html/wp-config.php regexp: "'localhost'" replace: "'{{ hostvars.cloud.database.openstack.public_v4 }}'" backup: no when: hostvars.cloud.database.openstack.private_v4 == "" - name: Change ownership of wordpress shell: chown -R www-data:www-data /var/www/html args: warn: no when: ansible_distribution == 'Ubuntu' - name: Change ownership of wordpress shell: chown -R apache:apache /var/www/html args: warn: no when: ansible_distribution == 'Fedora' - service: name=apache2 state=restarted enabled=yes when: ansible_distribution == 'Ubuntu' - service: name=httpd state=restarted enabled=yes when: ansible_distribution == 'Fedora' - name: Install wordpress command line tool copy: src: files/wp-cli.phar dest: /usr/local/bin/wp mode: "a+x" force: no