code

---

- hosts: all

  become: yes

  tasks:

    - name: install packages

      package:

         name:

           - libselinux-python

           - libsemanage-python

           - firewalld

         state: installed




- hosts: lamp-db

  become: yes

  tasks:

    - name: install packages

      package:

         name:

           - mariadb-server

           - MySQL-python

         state: installed

    - name: Copy the MySQL Configuration file

      copy: src=files/my.cnf dest=/etc/my.cnf

   - name: Start and enable

      service: name=mariadb state=started enabled=yes


    - name: Start and enable the firewalld

      service: name=firewalld state=started enabled=yes


    - name: inserrt rukle

      firewalld: port={{ mysql_port }}/tcp permanent=true state=enabled immediate=yes


    - name: Create Application Database

      mysql_db: name={{ dbname }} state=present


    - name: Create Application DB User

      mysql_user: name={{ dbuser }} password={{ dbpassword }} priv=*.*:ALL host='172.20.1.100' state=present


    - name: Move db-load-script to db host

      copy:

        src: files/db-load-script.sql

        dest: /tmp/db-load-script.sql


    - name: Load Inventory Data

      shell: mysql -f < /tmp/db-load-script.sql

    - name: Install httpd and php
      yum:
        name:
          - httpd
          - php
          - php-mysql
        state: present

    - name: Install web role specific dependencies
      yum: name=git state=installed

    - name: Start firewalld
      service: name=firewalld state=started enabled=yes

    - name: insert firewalld rule for httpd
      firewalld: port={{ httpd_port }}/tcp permanent=true state=enabled immediate=yes

    - name: Set index.php as the default page
      tags: "Set index.php as the default page"
      replace:
        path: /etc/httpd/conf/httpd.conf
        regexp: 'DirectoryIndex index.html'
        replace: 'DirectoryIndex index.php'
  - name: http service state
      service: name=httpd state=started enabled=yes

Comments

Popular posts from this blog

exam 16

ansible 5

practical 3