You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.3 KiB

#
# task: install maraidb-client
#
# author Björn Hase, <herrhase@node001.net>
#
#
#
# input ip of mariadb svser
#
- name: Input of DB-Server IP
pause:
prompt: "IP Mariadb Server?"
register: mariadb_remote_server
- name: create mysql group
group:
name: mysql
state: present
- name: add mysql user
user:
name: mysql
system: true
group: mysql
create_home: false
#
# add user to mysql
#
- name: mariadb / add current user to mysql
user:
name: "{{ ansible_user }}"
groups: mysql
append: yes
#
# check for
#
- name: Create the file, if it doesnt exist already
stat:
path: /etc/apt/sources.list.d/mariadb.list
register: list
#
#
#
- name: mariadb / prepare install
shell: 'curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-{{ mariadb_version }}"'
when: not list.stat.exists
#
#
#
- name: mariadb / install
apt:
update_cache: yes
name:
- mariadb-client
when: not list.stat.exists
#
#
#
- include_tasks: mkdir.yml
#
# getting certificates & change permissions
#
- name: rsync certificates
shell: "sshpass -p '{{ hostvars[mariadb_remote_server.user_input]['ansible_password'] }}' rsync -rv -e 'ssh -o PubkeyAuthentication=no -o StrictHostKeyChecking=no' {{ hostvars[mariadb_remote_server.user_input]['ansible_user'] }}@{{ hostvars[mariadb_remote_server.user_input]['ansible_host'] }}:/etc/mysql/ssl/{{ item }} /etc/mysql/ssl/{{ item }}"
with_items:
- "ca-cert.pem"
- "client-cert.pem"
- "client-key.pem"
- file:
path: /etc/mysql/ssl/{{ item }}
owner: mysql
group: mysql
mode: '0640'
with_items:
- "ca-cert.pem"
- "client-cert.pem"
- "client-key.pem"
#
# Check for include
#
- name: check for include, if not set add to file
lineinfile:
state: absent
path: /etc/mysql/mariadb.cnf
regex: '^!include /etc/mysql/config.cnf'
changed_when: false
register: mariadb_line_check
- name: adding to file if not set
lineinfile:
state: present
path: /etc/mysql/mariadb.cnf
line: "!include /etc/mysql/config.cnf"
when: mariadb_line_check.found == 0
#
#
#
- name: create config, from default
template:
src: client.conf
dest: /etc/mysql/config.cnf
owner: root
group: root
mode: '0644'