Installing Apache, Mysql server, Adding database and a user with full Privileges, Similarly adding Ppa for Different Package With Ansible

Create a playbook apache.yml run with either defining host or with host password argument on ansible server, it will install all the package listed below.


---

- hosts: ubuntu

 remote_user: nmg

 become: yes

 become_method: sudo

 tasks:

  - name: Add php Repository

   apt_repository: repo='ppa:ondrej/php' state=present

   register: ppastable


  - name: Add php Repository

   apt_repository: repo='ppa:ondrej/mysql-5.6' state=present

   register: ppastable


  - name: "Adding repo for rabiitvca"

   apt_repository: repo='ppa:rabbitvcs/ppa' state=present

   register: ppastable


  - name: "Install Apache, MySQL, and PHP5"

   apt: name={{ item }} state=present

   with_items:

    - apache2

    - mysql-server

    - python-mysqldb

    - php

    - php-pear

    - php-mysql

- name: "Turn on Apache and MySQL and set them to run on boot"

   service: name={{ item }} state=started enabled=yes

   with_items:

    - apache2

    - mysql


  - name: Create a test database

   mysql_db: name=testDb

        state=present


  - name: Create a new user for connections

   mysql_user: name=webapp

         password=mypassword

         priv=*.*:ALL state=present


  - name: "Installing rabbitvcs"

   apt: name={{ item }} state=present

   with_items:

    - rabbitvcs-cli

    - rabbitvcs-core

    - rabbitvcs-gedit

    - rabbitvcs-nautilus



To view or add a comment, sign in

More articles by Jayant Bhagat

Explore content categories