xoxys.matrix/tasks/prepare.yml
2019-01-18 14:52:23 +01:00

61 lines
2.7 KiB
YAML

---
- block:
- name: Create group '{{ matrix_group }}'
group:
name: "{{ matrix_group }}"
state: present
gid: "{{ matrix_gid | default(omit) }}"
- name: Create user '{{ matrix_user }}'
user:
comment: matrix
name: "{{ matrix_user }}"
home: "{{ matrix_user_home }}"
uid: "{{ matrix_uid | default(omit) }}"
group: "{{ matrix_group }}"
groups: "{{ matrix_extra_groups | join(',') }}"
- name: Install dependencies
package:
name: "{{ item }}"
state: present
loop: "{{ matrix_dependencies }}"
become: True
become_user: root
- block:
- name: Setup postgres db '{{ matrix_postgres_db.name }}'
postgresql_db:
name: "{{ matrix_postgres_db.name }}"
lc_collate: "{{ matrix_postgres_db.lc_collate | default('en_US.UTF-8') }}"
lc_ctype: "{{ matrix_postgres_db.lc_ctype | default('en_US.UTF-8') }}"
encoding: "{{ matrix_postgres_db.encoding | default('UTF-8') }}"
template: "{{ matrix_postgres_db.template | default('template0') }}"
login_host: "{{ matrix_postgres_db.login_host | default('localhost') }}"
login_password: "{{ matrix_postgres_db.login_password | default(omit) }}"
login_user: "{{ matrix_postgres_db.login_user | default(postgresql_user) }}"
login_unix_socket: "{{ matrix_postgres_db.login_unix_socket | default(omit) }}"
port: "{{ matrix_postgres_db.port | default(omit) }}"
owner: "{{ matrix_postgres_db.owner | default(omit) }}"
state: "{{ matrix_postgres_db.state | default('present') }}"
no_log: True
when: matrix_postgres_db is defined
- name: Setup postgres user '{{ matrix_postgres_user.name }}'
postgresql_user:
name: "{{ matrix_postgres_user.name }}"
password: "{{ 'md5' + (matrix_postgres_user.password + matrix_postgres_user.name) | hash('md5') }}"
encrypted: "{{ matrix_postgres_user.encrypted | default('yes') }}"
priv: "{{ matrix_postgres_user.priv | default(omit) }}"
role_attr_flags: "{{ matrix_postgres_user.role_attr_flags | default(omit) }}"
db: "{{ matrix_postgres_user.db | default(omit) }}"
login_host: "{{ matrix_postgres_user.login_host | default('localhost') }}"
login_password: "{{ matrix_postgres_user.login_password | default(omit) }}"
login_user: "{{ matrix_postgres_user.login_user | default(omit) }}"
login_unix_socket: "{{ matrix_postgres_user.login_unix_socket | default(omit) }}"
port: "{{ matrix_postgres_user.port | default(omit) }}"
state: "{{ matrix_postgres_user.state | default('present') }}"
no_log: True
when: matrix_postgres_user is defined
delegate_to: "{{ matrix_postgres_server }}"