-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency) #78
Changes from all commits
0a2bca9
143915c
b1fd33d
60861dc
3b42b08
8df8570
b7d92f7
e23443e
83be2c5
2a44c37
c76230d
8576179
127ca77
cddfc9a
eb24c61
697e31d
1426c6d
2d18979
d6144fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
galaxy_info: | ||
description: Install PostgreSQL | ||
author: humblearner | ||
company: StackStorm | ||
license: Apache | ||
min_ansible_version: 2.2 | ||
tags: [db, postgresql] | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- trusty | ||
- xenial | ||
- name: EL | ||
versions: | ||
- 6 | ||
- 7 | ||
categories: | ||
- system |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Install PostgreSQL on {{ ansible_distribution }}-{{ ansible_distribution_major_version }} | ||
include: roles/postgresql/tasks/postgresql_{{ ansible_pkg_mgr }}{{ ansible_distribution_major_version }}.yml | ||
tags: [db, postgresql] | ||
when: ansible_os_family == "RedHat" | ||
|
||
- name: Install PostgreSQL on {{ ansible_distribution }}-{{ ansible_distribution_major_version }} | ||
include: roles/postgresql/tasks/postgresql_{{ ansible_pkg_mgr }}.yml | ||
tags: [db, postgresql] | ||
when: ansible_os_family == "Debian" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: apt | Install PostgreSQL | ||
become: yes | ||
apt: | ||
name: postgresql | ||
state: installed | ||
tags: [db, postgresql] | ||
|
||
- name: apt | Start and Enable PostgreSQL | ||
become: yes | ||
service: | ||
name: postgresql | ||
state: started | ||
enabled: yes | ||
tags: [db, postgresql] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
- name: yum | Setup PostgreSQL repository for {{ ansible_distribution }} | ||
become: yes | ||
yum: | ||
name: https://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-3.noarch.rpm | ||
state: installed | ||
when: ansible_distribution == "CentOS" | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Setup PostgreSQL repository for {{ ansible_distribution }} | ||
become: yes | ||
yum: | ||
name: https://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-3.noarch.rpm | ||
state: installed | ||
when: ansible_distribution == "RedHat" | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Install PostgreSQL dependency | ||
become: yes | ||
yum: | ||
name: libselinux-python | ||
state: installed | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Install PostgreSQL-9.4 | ||
become: yes | ||
yum: | ||
name: "{{ item }}" | ||
state: installed | ||
with_items: | ||
- postgresql94-server | ||
- postgresql94-contrib | ||
- postgresql94-devel | ||
register: install_postgresql | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Initialize PostgreSQL-9.4 | ||
become: yes | ||
command: service postgresql-9.4 initdb | ||
when: install_postgresql.changed | ||
tags: [db, postgresql] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, this command needs a "file lock" to ensure that we run OR even better, - it's possible to run See: https://raymii.org/s/tutorials/Ansible_-_Only-do-something-if-another-action-changed.html |
||
|
||
- name: yum | MD5-encrypted password for PostgreSQL 1 | ||
become: yes | ||
replace: | ||
dest: /var/lib/pgsql/9.4/data/pg_hba.conf | ||
regexp: ^(host.*all.*all.*127.0.0.1\/32.*)ident$ | ||
replace: \1md5 | ||
tags: [db, postgresql] | ||
|
||
- name: yum | MD5-encrypted password for PostgreSQL 2 | ||
become: yes | ||
replace: | ||
dest: /var/lib/pgsql/9.4/data/pg_hba.conf | ||
regexp: ^(host.*all.*all.*::1\/128.*)ident$ | ||
replace: \1md5 | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Start and Enable PostgreSQL-9.4 | ||
become: yes | ||
service: | ||
name: postgresql-9.4 | ||
state: started | ||
enabled: yes | ||
tags: [db, postgresql] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: yum | Install PostgreSQL | ||
become: yes | ||
yum: | ||
name: "{{ item }}" | ||
state: installed | ||
with_items: | ||
- postgresql-server | ||
- postgresql-contrib | ||
- postgresql-devel | ||
register: install_postgresql | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Initialize PostgreSQL | ||
become: yes | ||
command: postgresql-setup initdb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This command needs idempotence, maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See another comment: https://github.com/StackStorm/ansible-st2/pull/78/files#r95995753 about executing an command only when another action is changed |
||
when: install_postgresql.changed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice indeed 👍 |
||
tags: [db, postgresql] | ||
|
||
- name: yum | MD5-encrypted password for PostgreSQL 1 | ||
become: yes | ||
replace: | ||
dest: /var/lib/pgsql/data/pg_hba.conf | ||
regexp: ^(host.*all.*all.*127.0.0.1\/32.*)ident$ | ||
replace: \1md5 | ||
tags: [db, postgresql] | ||
|
||
- name: yum | MD5-encrypted password for PostgreSQL 2 | ||
become: yes | ||
replace: | ||
dest: /var/lib/pgsql/data/pg_hba.conf | ||
regexp: ^(host.*all.*all.*::1\/128.*)ident$ | ||
replace: \1md5 | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Start and Enable PostgreSQL | ||
become: yes | ||
service: | ||
name: postgresql | ||
state: started | ||
enabled: yes | ||
tags: [db, postgresql] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional "enable" action is missing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
galaxy_info: | ||
description: Install custom OpenStack Mistral, patched by StackStorm | ||
author: armab | ||
company: StackStorm | ||
license: Apache | ||
min_ansible_version: 2.2 | ||
tags: st2mistral | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- trusty | ||
- xenial | ||
- name: EL | ||
versions: | ||
- 6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
- 7 | ||
categories: | ||
- system | ||
dependencies: | ||
- role: postgresql | ||
- role: st2repos |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
--- | ||
- name: Install st2mistral dependency | ||
become: yes | ||
package: | ||
name: st2python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch 👍 We install Seems like we should add the same dependency for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created an Issue for that: StackStorm/st2-packages#407 so we won't forget about it and fix the root cause. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the bootstrap scripts we install |
||
state: present | ||
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "6" | ||
tags: st2mistral | ||
|
||
- name: Install latest st2mistral | ||
become: yes | ||
apt: | ||
package: | ||
name: st2mistral | ||
state: latest | ||
when: mistral_version == "stable" | ||
tags: st2mistral | ||
|
||
- name: Install latest st2mistral | ||
become: yes | ||
apt: | ||
package: | ||
name: st2mistral={{ mistral_version }} | ||
state: present | ||
when: mistral_version != "stable" | ||
tags: st2mistral | ||
|
||
- name: Configure mistral | ||
become: yes | ||
|
@@ -22,56 +31,72 @@ | |
option: connection | ||
value: postgresql://{{ mistral_db_username }}:{{ mistral_db_password }}@localhost/{{ mistral_db }} | ||
backup: yes | ||
tags: st2mistral | ||
|
||
- name: Deploy database init script | ||
become: yes | ||
template: | ||
src: init_mistral_db.SQL.j2 | ||
dest: /etc/mistral/init_mistral_db.SQL | ||
notify: | ||
dest: /etc/mistral/init_mistral_db.SQL | ||
register: mistral_deploy_database_init_script | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Initiate database | ||
vars: | ||
ansible_ssh_pipelining: true | ||
become: yes | ||
become_user: postgres | ||
shell: psql < /etc/mistral/init_mistral_db.SQL | ||
args: | ||
args: | ||
creates: /etc/mistral/init_mistral_db.SQL.ansible.has.run | ||
register: mistral_initiate_database | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Make sure "Initiate database" doesn't run twice | ||
become: yes | ||
file: | ||
path: /etc/mistral/init_mistral_db.SQL.ansible.has.run | ||
state: touch | ||
when: mistral_initiate_database.changed | ||
tags: st2mistral | ||
|
||
- name: Setup Mistral DB tables, etc | ||
become: yes | ||
command: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf upgrade head | ||
args: | ||
creates: /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
notify: | ||
register: setup_mistral_DB_tables | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Make sure "Setup Mistral DB tables, etc" does not run again | ||
become: yes | ||
file: | ||
path: /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
state: touch | ||
when: setup_mistral_DB_tables.changed | ||
tags: st2mistral | ||
|
||
- name: Register mistral actions | ||
become: yes | ||
command: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf populate | ||
args: | ||
creates: /etc/mistral/mistral-db-manage.populate.ansible.has.run | ||
register: register_mistral_actions | ||
when: mistral_deploy_database_init_script.changed or mistral_initiate_database.changed or setup_mistral_DB_tables.changed | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Make sure "Register mistral actions" does not run again | ||
become: yes | ||
file: | ||
path: /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
state: touch | ||
when: register_mistral_actions.changed | ||
tags: st2mistral |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
CREATE ROLE {{ mistral_db_username }} WITH CREATEDB LOGIN ENCRYPTED PASSWORD {{ mistral_db_password }}; | ||
CREATE ROLE {{ mistral_db_username }} WITH CREATEDB LOGIN ENCRYPTED PASSWORD '{{ mistral_db_password }}'; | ||
CREATE DATABASE {{ mistral_db }} OWNER {{ mistral_db_username }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versions:
is missing