aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/sz-ds/tasks/main.yml
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-08-27 20:38:23 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-08-27 20:38:23 +0200
commit8db1109ca093e057a0ac40aa6283030d536508ee (patch)
tree1a22ba7f769602d492d44c2fe5d26e1547de5230 /ansible/roles/sz-ds/tasks/main.yml
parent1c9619633840a0e7588a5fdf6996faddf32e8090 (diff)
downloadinfra-8db1109ca093e057a0ac40aa6283030d536508ee.tar.gz
infra-8db1109ca093e057a0ac40aa6283030d536508ee.tar.bz2
infra-8db1109ca093e057a0ac40aa6283030d536508ee.tar.xz
infra-8db1109ca093e057a0ac40aa6283030d536508ee.zip
o sz-ds: wip.
Diffstat (limited to 'ansible/roles/sz-ds/tasks/main.yml')
-rw-r--r--ansible/roles/sz-ds/tasks/main.yml87
1 files changed, 87 insertions, 0 deletions
diff --git a/ansible/roles/sz-ds/tasks/main.yml b/ansible/roles/sz-ds/tasks/main.yml
new file mode 100644
index 0000000..9e55292
--- /dev/null
+++ b/ansible/roles/sz-ds/tasks/main.yml
@@ -0,0 +1,87 @@
+- name: misc packages
+ tags: packages
+ apt:
+ name: "{{ item }}"
+ install_recommends: no
+ with_items:
+ - python-psycopg2
+ - python3-psycopg2
+
+- name: accounts for sz-ds
+ tags: user
+ block:
+ - name: create sz-ds user
+ user:
+ name: sz-ds
+ shell: "/bin/bash"
+ createhome: no
+ home: /opt/sz-ds
+ system: yes
+ - file:
+ state: directory
+ path: /opt/sz-ds
+ owner: sz-ds
+ mode: u=rwx,go=
+ - file:
+ state: directory
+ path: /opt/sz-ds/bin
+ - copy:
+ src: opt/sz-ds/bash_profile
+ dest: /opt/sz-ds/.bash_profile
+
+- name: flyway for sz-ds
+ tags: flyway
+ block:
+ - name: mkdir /opt/sz-ds/flyway
+ file:
+ state: directory
+ path: /opt/sz-ds/flyway
+ - template:
+ src: opt/sz-ds/bin/flyway.j2
+ dest: /opt/sz-ds/bin/flyway
+ mode: a=rx
+ - name: Download and extract Flyway {{ flyway_version }}
+ unarchive:
+ src: "https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/{{ flyway_version }}/flyway-commandline-{{ flyway_version }}.zip"
+ dest: /opt/sz-ds/flyway
+ creates: "/opt/sz-ds/flyway/flyway-{{ flyway_version }}"
+ remote_src: yes
+ - file:
+ path: "/opt/sz-ds/flyway/flyway-{{ flyway_version }}/flyway"
+ mode: a=rx
+ # flyway.conf is created later
+- name: sz-ds database
+ tags: sz-ds-pg
+ become: yes
+ become_user: postgres
+ vars:
+ ansible_ssh_pipelining: true
+ block:
+ - name: sz-ds
+ postgresql_user:
+ name: sz-ds
+ role_attr_flags: "NOLOGIN"
+ - name: sz-ds-flyway
+ tags: update-password
+ postgresql_user:
+ name: sz-ds-flyway
+ password: "{{ sz_ds_secret.db_password_flyway }}"
+ encrypted: yes
+ - name: sz-ds-web
+ tags: update-password
+ postgresql_user:
+ name: sz-ds-web
+ password: "{{ sz_ds_secret.db_password_web }}"
+ encrypted: yes
+ - name: sz-ds db
+ postgresql_db:
+ name: "sz-ds"
+ encoding: "utf-8"
+ owner: "sz-ds"
+ - postgresql_privs:
+ database: sz-ds
+ state: present
+ privs: USAGE
+ type: schema
+ objs: public
+ roles: sz-ds-web,sz-ds-flyway