--- - gather_facts: false hosts: tag_system_wordpress2 become: yes vars: mysql_root_password: "mypass" mysql_root_password: mypass wordpress_db_name: wordpress wordpress_db_user: dbuser wordpress_db_user_pass: dbpass wordpress_db_prefix: wp_ tasks: - name: Install LAMP apt: pkg: ['apache2', 'mysql-server', 'mysql-client', 'python-mysqldb', 'libmysqlclient-dev','php-fpm', 'php-gd', 'php-curl', 'php-mysql', 'php-xml', 'php', 'libapache2-mod-php', 'php-mysql'] state: installed update_cache: true - name: Enable apache2 modules command: a2enmod rewrite actions alias - name: Upload apache2 default configuration copy: src=files/000-default.conf dest=/etc/apache2/sites-enabled/ - name: Remove default apache2 index.html file ignore_errors: yes command: rm /var/www/html/index.html - name: Upload default index.php for host copy: src=files/index.php dest=/var/www/html/ mode=0644 - name: Restart webserver service: name=apache2 state=restarted - name : Ensure mysql started become: yes service: name=mysql state=started enabled=yes - name: Create WordPress database mysql_db: name: "{{ wordpress_db_name }}" state: present login_user: root login_password: "{{ mysql_root_password }}" - name: Create MySQL conf file copy: dest: "/home/ubuntu/.my.cnf" content: | [client] user=root password={{ mysql_root_password }} - name: Create WordPress DB user and grant permissions to WordPress DB mysql_user: name: "{{ wordpress_db_user }}" password: "{{ wordpress_db_user_pass }}" priv: "{{ wordpress_db_name }}.*:ALL" state: present login_unix_socket: /var/run/mysqld/mysqld.sock - name: Update MySQL root password for all root accounts mysql_user: name=root host={{ item }} password={{ mysql_root_password }} login_user=root login_password="" state=present with_items: - 127.0.0.1 - ::1 - localhost - name: Configure php-fom with apache2 become: true copy: src=files/www.conf dest=/etc/php/7.0/fpm/pool.d/