-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Rename st2mistral vars & Misc cosmetic improvements #94
Changes from all commits
7d71a86
1c9623c
0a4a531
d1ebb5a
52727e7
7060d20
e750492
bad365b
2e34d64
ad0a1b4
b05d27f
f36ff60
fe51af7
7658acf
2b9a446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
mistral_version: latest | ||
mistral_db_username: mistral | ||
mistral_db_password: StackStorm | ||
mistral_db: mistral | ||
# st2mistral version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.1.1` | ||
st2mistral_version: latest | ||
# PostgreSQL DB name for Mistral. | ||
st2mistral_db: mistral | ||
# PostgreSQL DB user for Mistral. | ||
st2mistral_db_username: mistral | ||
# PostgreSQL DB password for Mistral. | ||
st2mistral_db_password: StackStorm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,26 @@ | ||
--- | ||
|
||
- name: Install st2mistral dependency | ||
- name: Install st2python dependency for EL6 | ||
become: yes | ||
package: | ||
name: st2python | ||
state: present | ||
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "6" | ||
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" | ||
tags: st2mistral | ||
|
||
- name: Install latest st2mistral | ||
- name: Install latest st2mistral package | ||
become: yes | ||
package: | ||
name: st2mistral | ||
state: latest | ||
when: mistral_version == "latest" | ||
when: st2mistral_version == "latest" | ||
tags: [st2mistral, skip_ansible_lint] | ||
|
||
- name: Install latest st2mistral | ||
- name: Install pinned st2mistral package | ||
become: yes | ||
package: | ||
name: st2mistral={{ mistral_version }} | ||
name: st2mistral={{ st2mistral_version }} | ||
state: present | ||
when: mistral_version != "latest" | ||
tags: st2mistral | ||
|
||
- name: Configure mistral | ||
become: yes | ||
ini_file: | ||
dest: /etc/mistral/mistral.conf | ||
section: database | ||
option: connection | ||
value: postgresql://{{ mistral_db_username }}:{{ mistral_db_password }}@localhost/{{ mistral_db }} | ||
backup: yes | ||
when: st2mistral_version != "latest" | ||
tags: st2mistral | ||
|
||
- name: Deploy database init script | ||
|
@@ -40,11 +29,9 @@ | |
src: init_mistral_db.SQL.j2 | ||
dest: /etc/mistral/init_mistral_db.SQL | ||
register: mistral_deploy_database_init_script | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Initiate database | ||
- name: Initiate mistral database | ||
become: yes | ||
become_user: postgres | ||
shell: psql < /etc/mistral/init_mistral_db.SQL | ||
|
@@ -55,9 +42,29 @@ | |
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Setup Mistral DB tables, etc | ||
- name: Make sure "Initiate mistral database" doesn't run twice | ||
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. You're creating the file here, but I don't see where you're checking for the presence of the file in the previous task (i.e. no 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: See: http://docs.ansible.com/ansible/shell_module.html for more info. 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. Ah, okay I get it now. |
||
become: yes | ||
shell: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf upgrade head && touch /etc/mistral/init_mistral_db.SQL.ansible.has.run | ||
file: | ||
path: /etc/mistral/init_mistral_db.SQL.ansible.has.run | ||
state: touch | ||
when: mistral_initiate_database.changed | ||
tags: st2mistral, skip_ansible_lint | ||
|
||
- name: Configure mistral | ||
become: yes | ||
ini_file: | ||
dest: /etc/mistral/mistral.conf | ||
section: database | ||
option: connection | ||
value: postgresql://{{ st2mistral_db_username }}:{{ st2mistral_db_password }}@localhost/{{ st2mistral_db }} | ||
backup: yes | ||
notify: | ||
- restart mistral | ||
tags: st2mistral | ||
|
||
- name: Setup mistral DB tables, etc | ||
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 as above - don't currently see how this is idempotent, since there is no 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. Similar example with |
||
become: yes | ||
shell: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf upgrade head && touch /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
args: | ||
creates: /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
register: setup_mistral_DB_tables | ||
|
@@ -67,11 +74,19 @@ | |
|
||
- name: Register mistral actions | ||
become: yes | ||
shell: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf populate && touch /etc/mistral/mistral-db-manage.upgrade.head.ansible.has.run | ||
shell: /opt/stackstorm/mistral/bin/mistral-db-manage --config-file /etc/mistral/mistral.conf populate && touch /etc/mistral/mistral-db-manage.populate.ansible.has.run | ||
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 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. We touch the file first, find: creates: /etc/mistral/mistral-db-manage.populate.ansible.has.run |
||
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, skip_ansible_lint | ||
|
||
- name: Ensure mistral service is enabled and running | ||
become: yes | ||
service: | ||
name: mistral | ||
enabled: yes | ||
state: started | ||
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 DATABASE {{ mistral_db }} OWNER {{ mistral_db_username }}; | ||
CREATE ROLE {{ st2mistral_db_username }} WITH CREATEDB LOGIN ENCRYPTED PASSWORD '{{ st2mistral_db_password }}'; | ||
CREATE DATABASE {{ st2mistral_db }} OWNER {{ st2mistral_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.
Here we have a problem when user will consider to change any of
st2mistral_
database settings in future, - theSQL
script will not run twice. That means, new DB is not created.We can workaround with additional lock files, but #95 should solve it in a right way.