- hosts: testservers tasks: #### SYSTEM UPDATE #### - name: System Update yum: name=* state=latest when: ansible_distribution == "CentOS" - name: Disable SELinux selinux: state=disabled when: ansible_distribution == "CentOS" - name: Installing epel-rep yum: pkg=epel-release state=latest when: ansible_distribution == "CentOS" - name: Reboot server shell: sleep 3 && /sbin/shutdown -r "Ansible system reboot" async: 1 poll: 0 - name: Waiting for SSH connection local_action: wait_for host={{ inventory_hostname }} port=22 delay=20 connect_timeout=200 become: false delegate_to: localhost #### Software Installation #### - name: Installation Utils yum: pkg={{ item }} with_items: - wget - mc - nano when: ansible_distribution == "CentOS" - name: Installation Apache yum: pkg=httpd state=present when: ansible_distribution == "CentOS" - name: Enable Apache on System Boot service: name=httpd enabled=yes when: ansible_distribution == "CentOS" - name: Installation PHP mods yum: pkg={{ item }} state=present with_items: - php - php-gd - php-mysql - php-devel when: ansible_distribution == "CentOS" - name: Installation MariaDB yum: pkg=mariadb-server state=present when: ansible_distribution == "CentOS" - name: Enable MariaDB on System Boot service: name=mariadb enabled=yes when: ansible_distribution == "CentOS" - name: Installation Pyton Mysql module yum: pkg=MySQL-python state=present when: ansible_distribution == "CentOS" - name: Installation PHPmyAdmin yum: pkg=phpMyAdmin state=present when: ansible_distribution == "CentOS" - name: Service Mariadb Start service: name=mariadb state=started when: ansible_distribution == "CentOS" - name: Service Apache Start service: name=httpd state=started when: ansible_distribution == "CentOS" ## Configuring MariaDB ## - name: Set root Password mysql_user: user=root password=P@ssw0rd host=localhost when: ansible_distribution == "CentOS" # - name: Reload privilege tables # command: mysql -u root -p P@ssw0rd -ne "{{ item }}" # with_items: # - FLUSH PRIVILEGES # when: ansible_distribution == "CentOS" - name: Create MySQL database mysql_db: name=wordpress login_user=root login_password=P@ssw0rd state=present when: ansible_distribution == "CentOS" - name: Create MySQL user mysql_user: login_user=root login_password=P@ssw0rd name=wpuser password=P@ssw0rd priv=*.*:ALL when: ansible_distribution == "CentOS" ## WordPress ## - name: DownLoad LAST version WordPress get_url: url=https://wordpress.org/latest.tar.gz dest=/tmp/wordpress.tar.gz validate_certs=no when: ansible_distribution == "CentOS" - name: Extract WordPress unarchive: src=/tmp/wordpress.tar.gz dest=/var/www/html copy=no when: ansible_distribution == "CentOS" #### Firewall Config #### - name: Add HTTP service command: firewall-cmd --add-service=http --permanent when: ansible_distribution == "CentOS" - name: Add HTTPs service command: firewall-cmd --add-service=https --permanent when: ansible_distribution == "CentOS" - name: Add MySQL service command: firewall-cmd --add-port=3306/tcp --permanent when: ansible_distribution == "CentOS" - name: Restarting firewall command: firewall-cmd --reload when: ansible_distribution == "CentOS" #### Services #### - name: MariaDB restart service: name=mariadb state=restarted when: ansible_distribution == "CentOS" - name: Apache restart service: name=httpd state=restarted when: ansible_distribution == "CentOS"