Skip to content

Ansible custom module that allows you to set values in mysql databases

License

Notifications You must be signed in to change notification settings

sysreq0/ansible-mysql-query

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role: mysql_query

Ansible module to set values in a mysql table, or insert records. Useful for web-applications that store configurations in database. E.g. icingaweb2 requires the initial user to be inserted into the database. The install-wizard could do it, but with ansible you want to automate installation ;)

Listed at Ansible Galaxy Page as zauberpony.mysql-query

Install

Install via ansible-galaxy, ansible-galaxy install zauberpony.mysql-query, or manually put the file mysql_query into your roles_path.

Requirements:

python bindings for mysql (python-mysqldb on Debian, MySQL-python on RedHat/Fedora), just like the core mysql_* modules.

Example playbook

A complete example that ensures a record is present in a given table.

---
- hosts: all
  roles:
    - zauberpony.mysql-query
  tasks:
    - name: insert a row
      mysql_query:
        name: ansible-playbook-example
        table: simple_table
        login_host: ::1
        login_user: root
        login_password: password
        identifiers:
          identifier1: 14
          identifier2: 'eighteen'
        values:
          value1: 115
          value2: 'one-hundred-sixteen'
        defaults:
          default1: 125
          default2: one-hundred-25

Running the examples from sources

Make sure you have a running mysql server (e.g.: use the docker-compose.yml in tests/infrastructure) and update the connection-parameters if necessary.

Run via ansible-playbook -i demo.yml (or even simpler ./demo.yml) and undo (to start all over) with ansible-playbook -i reset.yml.

About

Ansible custom module that allows you to set values in mysql databases

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%