Giter VIP home page Giter VIP logo

ansible-role-mysql's Introduction

MySQL Server

This role is useful to install MySQL Server. It helps also:

  1. secure the root account with password
  2. remove test databases
  3. add one or more databases
  4. create users in the database
  5. configure the databases for master-slave replication
  6. install new mysql engines

Requirements

This role requires Ansible 1.4 or higher.

Role Variables

The variables that can be passed to this role and a brief description about them are as follows:

  # The port for mysql server to listen
  mysql_port: 3306

  # The bind address for mysql server
  mysql_bind_address: "0.0.0.0"

  # The root DB password
  mysql_root_db_pass: secret

  # A list that has all the databases to be
  # created and their replication status:
  mysql_db:
       - name: example_db1
         replicate: yes
       - name: example_db2
         replicate: no

  # A list of the mysql users to be created
  # and their password and privileges:
  mysql_users:
       - name: user1
         pass: verystrong
         priv: "*.*:ALL"

  # If the database is replicated the users
  # to be used for replication:
  mysql_repl_user:
    - name: repl
      pass: verystrong

  # The role of this server in replication:
  mysql_repl_role: master

  # A unique id for the mysql server (used in replication):
  mysql_db_id: 7

  # If you want to install new engine set this variables:
  # for RedHat-like systems
  mysql_extra_packages_rh:
    - engine_package_name
  # for Debian-like systems
  mysql_extra_packages_deb:
    - engine_package_name
  mysql_add_engine: true
  mysql_engines:
    - name: example_engine
      soname: example_engine.so
      service: example_engine_service

Examples

  1. Install MySQL Server and set the root password, but don't create any database or users.

    • hosts: all roles:
      • { role: mysql, mysql_root_db_pass: secret, mysql_db: none, mysql_users: none }
  2. Install MySQL Server and create 2 databases and 2 users.

    • hosts: all roles:
      • { role: mysql, mysql_db: [{ name: example_db1 }, { name: example_db2 }], mysql_users: [{ name: user1, pass: verystrong, priv: ".:ALL" }, { name: user2, pass: verystrongtoo }] }

Note: If users are specified and password/privileges are not specified, then default values are set.

  1. Install MySQL Server and create 2 databases and 2 users and configure the database as replication master with one database configured for replication.

    • hosts: all roles:
      • { role: mysql, mysql_db: [{ name: example_db1, replicate: yes }, { name: example_db2, replicate: no }], mysql_users: [{ name: user1, pass: verystrong, priv: ".:ALL" }, { name: user2, pass: verystrongtoo }], mysql_repl_user: [{ name: repl, pass: verystrong }] }
  2. A fully installed/configured MySQL Server with master and slave replication.

    • hosts: master roles:

      • { role: mysql, mysql_db: [{ name: example_db1 }, { name: example_db1 }], mysql_users: [{ name: user1, pass: verystrong, priv: ".:ALL" }, { name: user2, pass: verystrongtoo }], mysql_db_id: 8 }
    • hosts: slave roles:

      • { role: mysql, mysql_db: none, mysql_users: none, mysql_repl_role: slave, mysql_repl_master: master_host, mysql_db_id: 9, mysql_repl_user: [{ name: repl, pass: verystrong }] }
  3. Add new engine to MySQL Server

    • hosts: all roles:
      • { role: mysql, mysql_add_engine: true, mysql_engines: [{ name: example_engine, soname: example_engine.so, service: example_engine_service }] }

Note: When configuring the full replication please make sure the master is configured via this role and the master is available in inventory and facts have been gathered for master. The replication tasks assume the database is new and has no data.

ansible-role-mysql's People

Watchers

Gleb Vadyasov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.