<commit_before>---

- name: Check for existing root database credentials.
  stat:
    path: "{{ ansible_user_dir }}/.my.cnf"
  register: my_cnf

- name: Install random password generator.
  apt:
    name: pwgen
    state: present
  when: my_cnf.stat.exists == False

- name: Generate a random database root password.
  shell: pwgen -B -s 24 1
  register: mariadb_root_password
  ignore_errors: false
  when: my_cnf.stat.exists == False

- name: Get list of hosts for the root user.
  command: mysql -NBe 'SELECT Host FROM mysql.user WHERE User = "root" ORDER BY (Host="localhost") ASC'
  register: mariadb_root_hosts
  changed_when: false

- name: Update MySQL root password for localhost root account.
  shell: >
    mysql -u root -NBe
    'SET PASSWORD FOR "root"@"{{ item }}" = PASSWORD("{{ mariadb_root_password.stdout }}");'
  with_items: mariadb_root_hosts.stdout_lines
  when: mariadb_install_packages.changed == True and mariadb_root_password.changed == True

- name: Copy .my.cnf file with database root credentials.
  template:
    src: "user-my.cnf.j2"
    dest: "{{ ansible_user_dir }}/.my.cnf"
    owner: "{{ ansible_user_id }}"
    group: "{{ ansible_user_gecos }}"
    mode: 0600
  when: mariadb_root_password.changed == True

- name: Get list of hosts for the anonymous user.
  command: mysql -NBe 'SELECT Host FROM mysql.user WHERE User = ""'
  register: mariadb_anonymous_hosts
  changed_when: false

- name: Remove anonymous MariaDB users.
  mysql_user:
     name: ""
     host: "{{ item }}"
     state: "absent"
  with_items: mariadb_anonymous_hosts.stdout_lines

- name: Remove MariaDB test database.
  mysql_db:
    name: test
    state: absent
<commit_msg>MariaDB stdout_lines wasn't parsing as a variable.<commit_after>---

- name: Check for existing root database credentials.
  stat:
    path: "{{ ansible_user_dir }}/.my.cnf"
  register: my_cnf

- name: Install random password generator.
  apt:
    name: pwgen
    state: present
  when: my_cnf.stat.exists == False

- name: Generate a random database root password.
  shell: pwgen -B -s 24 1
  register: mariadb_root_password
  ignore_errors: false
  when: my_cnf.stat.exists == False

- name: Get list of hosts for the root user.
  command: mysql -NBe 'SELECT Host FROM mysql.user WHERE User = "root" ORDER BY (Host="localhost") ASC'
  register: mariadb_root_hosts
  changed_when: false

- name: Update MySQL root password for localhost root account.
  shell: >
    mysql -u root -NBe
    'SET PASSWORD FOR "root"@"{{ item }}" = PASSWORD("{{ mariadb_root_password.stdout }}");'
  with_items:
    - "{{ mariadb_root_hosts.stdout_lines }}"
  when: mariadb_install_packages.changed == True and mariadb_root_password.changed == True

- name: Copy .my.cnf file with database root credentials.
  template:
    src: "user-my.cnf.j2"
    dest: "{{ ansible_user_dir }}/.my.cnf"
    owner: "{{ ansible_user_id }}"
    group: "{{ ansible_user_gecos }}"
    mode: 0600
  when: mariadb_root_password.changed == True

- name: Get list of hosts for the anonymous user.
  command: mysql -NBe 'SELECT Host FROM mysql.user WHERE User = ""'
  register: mariadb_anonymous_hosts
  changed_when: false

- name: Remove anonymous MariaDB users.
  mysql_user:
     name: ""
     host: "{{ item }}"
     state: absent
  with_items:
    - "{{ mariadb_anonymous_hosts.stdout_lines }}"

- name: Remove MariaDB test database.
  mysql_db:
    name: test
    state: absent

{'fraction_non_alphanumeric': 0.10932475884244373, 'fraction_numerical': 0.00467699503069278, 'mean_word_length': 3.5145118733509233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2869830', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1160, 'n_words': 348}