<commit_before>#
# This play will create databases and user for an application.
# It can be run like so:
#
# ansible-playbook -c local -i 'localhost,' create_dbs_and_users.yml -e@./db.yml
#
# where the content of db.yml contains the following dictionaries
#
# database_connection: &default_connection
#   login_host: "mysql.example.org"
#   login_user: "root"
#   login_password: "<PASSWORD>"

# DEFAULT_ENCODING: "utf8"

# databases:
#   reports:
#     state: "present"
#     encoding: "{{ DEFAULT_ENCODING }}"
#     <<: *default_connection
#   application:
#     state: "present"
#     encoding: "{{ DEFAULT_ENCODING }}"
#     <<: *default_connection

# database_users:
#   migrate:
#     state: "present"
#     password: "<PASSWORD>"
#     host: "%"
#     privileges:
#       - "reports.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
#       - "wwc.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
#     <<: *default_connection
#   runtime:
#     state: "present"
#     password: "<PASSWORD>"
#     host: "%"
#     privileges:
#       - "reports.*:SELECT"
#       - "wwc.*:SELECT,INSERT,UPDATE,DELETE"
#     <<: *default_connection

- name: Create databases and users
  hosts: all
  gather_facts: False
  tasks:
    # Install required library, currently this needs to be available
    # to system python.
    - name: install python mysqldb module
      pip: name={{item}} state=present
      with_items:
        - MySQL-python

    - name: create mysql databases
      mysql_db:
        db: "{{ item.name}}"
        state: "{{ item.state }}"
        encoding: "{{ item.encoding }}"
        login_host: "{{ item.login_host }}"
        login_user: "{{ item.login_user }}"
        login_password: "{{ item.login_password }}"
      with_items: "{{ databases }}"
      tags:
        - dbs

    - name: create mysql users and assign privileges
      mysql_user:
        name: "{{ item.name }}"
        state: "{{ item.state }}"
        priv: "{{ '/'.join(item.privileges) }}"
        password: "{{ item.password }}"
        host: "{{ item.host }}"
        login_host: "{{ item.login_host }}"
        login_user: "{{ item.login_user }}"
        login_password: "{{ item.login_password }}"
        append_privs: yes
      with_items: "{{ database_users }}"
      tags:
        - users<commit_msg>set state var default to present<commit_after>#
# This play will create databases and user for an application.
# It can be run like so:
#
# ansible-playbook -c local -i 'localhost,' create_dbs_and_users.yml -e@./db.yml
#
# where the content of db.yml contains the following dictionaries
#
# database_connection: &default_connection
#   login_host: "mysql.example.org"
#   login_user: "root"
#   login_password: "<PASSWORD>"

# DEFAULT_ENCODING: "utf8"

# databases:
#   reports:
#     state: "present"
#     encoding: "{{ DEFAULT_ENCODING }}"
#     <<: *default_connection
#   application:
#     state: "present"
#     encoding: "{{ DEFAULT_ENCODING }}"
#     <<: *default_connection

# database_users:
#   migrate:
#     state: "present"
#     password: "<PASSWORD>"
#     host: "%"
#     privileges:
#       - "reports.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
#       - "wwc.*:SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE,DROP,INDEX"
#     <<: *default_connection
#   runtime:
#     state: "present"
#     password: "<PASSWORD>"
#     host: "%"
#     privileges:
#       - "reports.*:SELECT"
#       - "wwc.*:SELECT,INSERT,UPDATE,DELETE"
#     <<: *default_connection

- name: Create databases and users
  hosts: all
  gather_facts: False
  tasks:
    # Install required library, currently this needs to be available
    # to system python.
    - name: install python mysqldb module
      pip: name={{item}} state=present
      with_items:
        - MySQL-python

    - name: create mysql databases
      mysql_db:
        db: "{{ item.name}}"
        state: "{{ item.state }}"
        encoding: "{{ item.encoding }}"
        login_host: "{{ item.login_host }}"
        login_user: "{{ item.login_user }}"
        login_password: "{{ item.login_password }}"
      with_items: "{{ databases }}"
      tags:
        - dbs

    - name: create mysql users and assign privileges
      mysql_user:
        name: "{{ item.name }}"
        state: "{{ item.state | default('present') }}"
        priv: "{{ '/'.join(item.privileges) }}"
        password: "{{ <PASSWORD> }}"
        host: "{{ item.host }}"
        login_host: "{{ item.login_host }}"
        login_user: "{{ item.login_user }}"
        login_password: "{{ <PASSWORD>.<PASSWORD>_password }}"
        append_privs: yes
      with_items: "{{ database_users }}"
      tags:
        - users
{'fraction_non_alphanumeric': 0.15156719622155432, 'fraction_numerical': 0.00042936882782310007, 'mean_word_length': 2.724220623501199, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5205604', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1496, 'n_words': 325}