Skip to content

MySQL Module Playbook

This playbook provides direct access to an Ansible Module. The following Modules are supported by this playbook:

For each of the above modules, variable module_database must be defined. This variable is a dictionary of the options as are used by the module. The documentation for each module can be found by click on the module name above.

Playbook AWX / Ansible Automation Platform Template Import

This playbook includes the AWX feature where it imports the playbook as job templates in to AWX / Ansible Automation Platform. The following job templates that will be created:

  • Database/MySQL/Database/Create Create a Database

  • Database/MySQL/Database/Delete Delete a Database

  • Database/MySQL/Database/Dump Dump a database to a .sql file

  • Database/MySQL/Database/Import Import a database from a .sql file

On import to AWX / Ansible Automation Platform a credential type will also be created, playbook/mysql/login that can be used to supply the required secrets to log in to the database.

Module definitions

Each module definition is detailed below under the tab matching the module name. This directly shows what is or is not supported.

# No Fuss Computing
# image: nofusscomputing/ansible-ee > 0.11.0rc0

- name: Connection Validation - Assumed Socket
      - is defined
    msg: "If no host DNS or IP Address is specified, you must supply the socket to use for the connection"
  when: is not defined

- name: Variable Validation - Dump Database
      - is defined
    msg: "to dump a database, you must specify the path to save the dump"
  when: module_database.state == 'dump'

- name: Variable Validation - Import Database
      - is defined
    msg: "to Import a database, you must specify the path to the dump (.sql) file"
  when: module_database.state == 'import'

- name: Install MariaDB Dependencies
    name: "{{ item }}"
    state: present
    install_recommends: false
  become: true
  loop: "{{ apps }}"
      - mariadb-client

- name: Install MariaDB required PIP Modules
    name: "{{ item }}"
    state: present
  become: true
  loop: "{{ modules }}"
      - PyMySQL

- name: "{{ task_name_module | default('MariaDB Database Action') }}"
    login_host: "{{ | default(omit)}}"
    login_user: "{{ nfc_pb_mariadb_username }}"
    login_password: "{{ nfc_pb_mariadb_password }}"
    login_port: "{{ | default(omit) }}"
    login_unix_socket: "{{ | default(omit) }}"

    name: "{{ }}"
    state: "{{ module_database.state }}"
    target: "{{ | default(omit) }}"

  become: "{{ module_database.become | default(omit) }}"
  delegate_to: "{{ module_database.delegate_to | default(omit) }}"
  no_log: "{{ module_database.no_log | default(false) | bool }}"


This page forms part of our Project Ansible Playbooks.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-01-14
Date Edited: 2024-01-14


Would You like to contribute to our Ansible Playbooks project? You can assist in the following ways:


ToDo: Add the page list of contributors