Skip to content
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

Merged
merged 15 commits into from
Jan 23, 2017

Conversation

arm4b
Copy link
Member

@arm4b arm4b commented Jan 20, 2017

We renamed mistral -> st2mistral role for consistency with other packages we install via roles (st2, st2web), but forgot to do so for respective variables.

This PR is a follow-up for #78 which actualizes variable names with a role name (it's good practice to prefix variable name with a role name).

  • mistral_version -> st2mistral_version
  • mistral_db -> st2mistral_db
  • mistral_db_username -> st2mistral_db_username
  • mistral_db_password -> st2mistral_db_password

Additionally tiny improvements:

  • Cosmetic fixes, more clear Task descriptions
  • Fix some st2mistral DB migration corner cases with "file locks" we create
  • Ensure mistral service is enabled and running

@arm4b
Copy link
Member Author

arm4b commented Jan 23, 2017

So after playing a bit and taking closer look at st2mistral role, I created a new issue to improve it in some better times:

Move DB creation logic from st2mistral to postgresql role #95

@arm4b arm4b added RFR and removed WIP labels Jan 23, 2017
@arm4b arm4b changed the title Rename st2mistral vars Rename st2mistral vars & Misc cosmetic improvements Jan 23, 2017
tags: st2mistral

- name: Initiate database
- name: Initiate mistral database
become: yes
become_user: postgres
shell: psql < /etc/mistral/init_mistral_db.SQL
Copy link
Member Author

@arm4b arm4b Jan 23, 2017

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, - the SQL 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.

@@ -55,9 +42,29 @@
- restart mistral
tags: st2mistral

- name: Setup Mistral DB tables, etc
- name: Make sure "Initiate mistral database" doesn't run twice
Copy link
Member

Choose a reason for hiding this comment

The 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 when clause)

Copy link
Member Author

@arm4b arm4b Jan 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: creates: /etc/mistral/init_mistral_db.SQL.ansible.has.run in previous task.
If file from the creates exists, - the command won't be executed.

See: http://docs.ansible.com/ansible/shell_module.html for more info.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay I get it now.

- restart mistral
tags: st2mistral

- name: Setup mistral DB tables, etc
Copy link
Member

Choose a reason for hiding this comment

The 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 when clause

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

@arm4b arm4b Jan 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We touch the file first, find: && touch /etc/mistral/mistral-db-manage.populate.ansible.has.run
and later in block don't execute it if touch exists:

creates: /etc/mistral/mistral-db-manage.populate.ansible.has.run

Copy link
Member

@Mierdin Mierdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@humblearner humblearner self-requested a review January 23, 2017 19:50
Copy link
Contributor

@humblearner humblearner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@arm4b
Copy link
Member Author

arm4b commented Jan 23, 2017

@humblearner I just moved that mistral.conf task after DB creation stage.

So DB is created first and then we change the mistral.conf setting if DB creation was successful.
Logically, it looks a bit better order for me.

@arm4b arm4b merged commit 156a084 into master Jan 23, 2017
@arm4b arm4b deleted the fix/rename-mistral-vars branch January 23, 2017 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants