Skip to content

Instantly share code, notes, and snippets.

@larsks
Last active January 26, 2019 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/c0e94a8ee04760fcede315999af93bc5 to your computer and use it in GitHub Desktop.
Save larsks/c0e94a8ee04760fcede315999af93bc5 to your computer and use it in GitHub Desktop.
---
C_NAME: larsks
DB_CPASSWD: password
---
DB_HOST: 172.17.0.2
DB_MUSER: root
DB_MPASSWD: secret
---
- hosts: localhost
vars_files:
- customer_details.yml
- db_details.yml
tasks:
- name: Create a new database with name {{ C_NAME }} Company
mysql_db:
login_host: '{{ DB_HOST }}'
login_user: "{{ DB_MUSER }}"
login_port: 3306
login_password: "{{ DB_MPASSWD }}"
name: "{{ C_NAME }}"
state: present
- name: Create tables in the database with name {{ C_NAME }} Company
mysql_db:
login_host: "{{ DB_HOST }}"
login_user: "{{ DB_MUSER }}"
login_port: 3306
login_password: "{{DB_MPASSWD}}"
name: "{{ C_NAME }}"
- name: Create a new user {{ C_NAME }} with all rights on {{ C_NAME }} database
mysql_user:
login_host: "{{ DB_HOST }}"
login_user: "{{ DB_MUSER }}"
login_port: 3306
login_password: "{{ DB_MPASSWD }}"
name: "{{ C_NAME }}"
password: "{{DB_CPASSWD}}"
host: '%'
priv: "{{ C_NAME }}.*:ALL"
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment