main.yml 2.96 KB
Newer Older
ale's avatar
ale committed
1
2
3
4
5
---

- file:
    path: /etc/noblogs
    state: directory
6
7
    group: docker-noblogs
    mode: 0750
ale's avatar
ale committed
8
9
10
11
12

- name: Install noblogs config
  template:
    src: config.json.j2
    dest: /etc/noblogs/config.json
13
14
    group: docker-noblogs
    mode: 0640
ale's avatar
ale committed
15

16
17
18
19
20
- name: Install robots.txt
  template:
    src: robots.txt.j2
    dest: /etc/noblogs/robots.txt

ale's avatar
ale committed
21
22
- name: Create noblogs data directory
  file:
23
    path: "/opt/noblogs/{{ item }}"
ale's avatar
ale committed
24
    state: directory
25
26
    owner: docker-noblogs
    group: docker-noblogs
ale's avatar
ale committed
27
    mode: 0700
28
  with_items:
ale's avatar
ale committed
29
    - cache
30
    - data
31
32
    - tmp/sessions
    - tmp/uploads
ale's avatar
ale committed
33
34
35
36
37
38
39

- include_role:
    name: mariadb
  vars:
    mariadb_instance: noblogs
    mariadb_port: 3307
    mariadb_metrics_port: 9307
ale's avatar
ale committed
40
41
42
    mariadb_server_id: "{{ shard_id | regex_replace('\\D', '') }}"
    mariadb_enable_replication: true
    mariadb_replication_password: "{{ noblogs_db_replication_password }}"
ale's avatar
ale committed
43
    mariadb_master_host: "noblogs-master.{{ domain }}"
ale's avatar
ale committed
44
    mariadb_is_master: "{{ float_noblogs_is_master }}"
45
    mariadb_ulimit_nofile: 65535
ale's avatar
ale committed
46
47
    mariadb_replicate_dbs:
      - noblogs
48
    mariadb_settings:
49
      max_connections: 5000
50
      default-storage-engine: MyISAM
godog's avatar
godog committed
51
      key_buffer_size: "2048M"
52
      thread_stack: "192K"
godog's avatar
godog committed
53
      sort_buffer_size: "8M"
54
55
56
57
58
59
60
      tmp_table_size: "64M"
      max_heap_table_size: "64M"
      join_buffer_size: "256K"
      query_cache_limit: 1048576
      query_cache_size: "128M"
      query_cache_type: 1
      table_open_cache: 8192
ale's avatar
ale committed
61
62
63
      binlog-do-db: noblogs
      binlog-format: MIXED
      expire_logs_days: 7
64
      max_allowed_packet: "16M"
65
66
67
68

- name: Create noblogs MySQL user
  mysql_user:
    name: noblogs
ale's avatar
ale committed
69
    host: "{{ item }}"
70
71
72
73
    password: "{{ noblogs_db_user_password }}"
    login_unix_socket: "/var/run/mariadb-noblogs/server.sock"
    priv: "*.*:ALL"
    state: present
ale's avatar
ale committed
74
75
76
  loop:
    - localhost
    - "%"
77
78
79
80
81
82
83
84

# If the database directory for the 'noblogs' db does not exist,
# initialize the db. Only run on the master host.
- stat:
    path: /var/lib/mariadb/noblogs/noblogs
  register: noblogs_db_dir

- set_fact:
ale's avatar
ale committed
85
    noblogs_initialize: "{{ float_noblogs_is_master and not noblogs_db_dir.stat.exists }}"
86
87
88
89
90
91
92
93
94
95
96
97
98

- copy:
    src: "bootstrap/wordpress-base.sql"
    dest: "/etc/noblogs/wordpress-base.sql"
  when: noblogs_initialize

- name: Create noblogs database
  mysql_db:
    name: noblogs
    state: import
    target: /etc/noblogs/wordpress-base.sql
    login_unix_socket: "/var/run/mariadb-noblogs/server.sock"
  when: noblogs_initialize
ale's avatar
ale committed
99
100
101
102
103
104

- name: Create noblogs database shard
  mysql_db:
    name: "noblogs_{{ shard_id | regex_replace('\\D', '') }}"
    state: present
    login_unix_socket: "/var/run/mariadb-noblogs/server.sock"
105

ale's avatar
ale committed
106
107
108
109
110
- name: Install noblogs cron jobs
  copy:
    dest: /etc/cron.d/noblogs
    src: noblogs.cron

111
112
- name: Configure backup handler
  template:
ale's avatar
ale committed
113
    dest: /etc/tabacco/handlers/mysql-noblogs.yml
114
115
116
117
    src: backup/mysql-noblogs-handler.yml.j2

- name: Configure backup source
  template:
118
    dest: /etc/tabacco/sources/noblogs.yml
ale's avatar
ale committed
119
    src: backup/noblogs-source.yml.j2