summaryrefslogtreecommitdiff
path: root/MariaDB/10.5.3/mariadb/role/tasks/deploy-standalone.yml
blob: d94eb38c68b51c3fac46a608cc16f4587ba77c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- name: Setting node_nums variable
  set_fact: node_nums={{ groups.mariadb|length }}

- name: To terminate execution
  fail:
    msg: "MariaDB standalone mode. The value must have 1 nodes,please checking configurations/hosts -> mariadb"
  when: node_nums != '1'

- name: Creating directory
  file:
    state: directory
    owner: ods
    group: root    
    path: '{{ deploy_dir }}/{{ container_name }}/{{ item.dir }}'
  with_items:
    - { dir: 'config' }
    - { dir: 'logs' }  
    - { dir: 'monitor' }  
    
- name: Copying image to {{ deploy_dir }}/{{ container_name }}/
  copy:
    src: 'files/{{ image_name }}-{{ image_tag }}.tar'
    dest: '{{ deploy_dir }}/{{ container_name }}/'
    force: true
  notify:
    - Loading Image

- name: Copying image to {{ deploy_dir }}/{{ container_name }}/monitor
  copy:
    src: 'files/mysqld_exporter-v1.0.tar'
    dest: '{{ deploy_dir }}/{{ container_name }}/monitor/'
    force: true
  notify:
    - Loading Exporter Image
    
- name: Copying Mariadb config files
  template:
    src: '{{ item.src }}'
    dest: '{{ item.dest }}'
    mode: 0644
  with_items:
    - { src: 'my.cnf.j2', dest: '{{ deploy_dir }}/{{ container_name }}/config/my.cnf' }
    - { src: 'docker-compose.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml' }
  notify:
    - Start Container

- meta: flush_handlers    
    
- name: Waitting for MariaDB running,20s
  shell: sleep 20

- name: Creating mariadb readonly user
  shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e "CREATE USER IF NOT EXISTS '{{ mariadb_query_username}}'@'%' IDENTIFIED BY '{{ mariadb_query_pin }}' WITH MAX_USER_CONNECTIONS 3;GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO '{{ mariadb_query_username}}'@'%';FLUSH PRIVILEGES;"
  
- name: change mariadb remote authority
  shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e"use mysql;grant all privileges on *.* to 'root'@'%' identified by '{{ mariadb_default_pin }}' with grant option;FLUSH PRIVILEGES;"

- name: Copying Mariadb config files
  template:
    src: 'exporter_docker-compose.yml.j2'
    dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml'
    mode: 0644
  notify:
    - Start Exporter Container

- meta: flush_handlers