summaryrefslogtreecommitdiff
path: root/openstack/usr/share/openstack/postgres.yml
blob: 76888c188b37ebaa0653d20af2dc8b209503cca6 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
---
- hosts: localhost
  vars_files:
  - "/etc/openstack/postgres.conf"
  tasks:

  - name: Create postgres user
    user:
        name: postgres
        comment: PostgreSQL Server
        shell: /sbin/nologin
        home: /var/lib/pgsql

  - name: Create the postgres directories
    file:
        path: "{{ item }}"
        state: directory
        owner: postgres
        group: postgres
    with_items:
    - /var/run/postgresql
    - /var/lib/pgsql/data

  - name: Initialise postgres database
    command: pg_ctl -D  /var/lib/pgsql/data initdb
    args:
        creates: /var/lib/pgsql/data/base
    sudo: yes
    sudo_user: postgres

  - name: Add the configuration needed for postgres for Openstack
    template:
        src: /usr/share/openstack/postgres/{{ item }}
        dest: /var/lib/pgsql/data/{{ item }}
        owner: postgres
        group: postgres
        mode: 0600
    with_items:
    - postgresql.conf
    - pg_hba.conf

  - name: Enable and start postgres services
    service:
        name: "{{ item }}"
        enabled: yes
        state: started
    with_items:
    - postgres-server

### MARIADB conf
  - name: Create postgres user
    user:
        name: mysql
        comment: MySQL Server
        shell: /sbin/nologin
        home: /var/lib/mysql

  - name: Install database priviledge tables
    shell: mysql_install_db --basedir=/usr --datadir=/var/lib/mysql --user=mysql

  - name: Setup mysql server daemon
    shell: install -v -m755 -o mysql -g mysql -d /run/mysqld

  - name: Enable and start postgres services
    service:
        name: "{{ item }}"
        enabled: yes
        state: started
    with_items:
    - mariadb

  - name: Create a database user (for the first run only)
    mysql_user:
      name: "{{ mysqldb_admin_user | default('root') }}"
      password: "{{ mysqldb_admin_password | default('toor') }}"
      priv: "*.*:ALL"
      host: localhost
      state: present
    ignore_errors: yes