Skip to content

Commit

Permalink
Merge pull request #94 from StackStorm/fix/rename-mistral-vars
Browse files Browse the repository at this point in the history
Rename st2mistral vars & Misc cosmetic improvements
  • Loading branch information
armab authored Jan 23, 2017
2 parents 9dd652e + 2b9a446 commit 156a084
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 46 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ ansible-playbook stackstorm.yml
## Variables
Below is the list of variables you can redefine in your playbook to customize st2 deployment:

| Variable | Default | Description |
| --------------------- | ------------- | ------------ |
| Variable | Default | Description |
| ------------------------ | ------------- | ------------ |
| **st2repo**
| `st2_pkg_repo` | `stable` | StackStorm PackageCloud repository to install. [`stable`](https://packagecloud.io/StackStorm/stable/), [`unstable`](https://packagecloud.io/StackStorm/unstable/), [`staging-stable`](https://packagecloud.io/StackStorm/staging-stable/), [`staging-unstable`](https://packagecloud.io/StackStorm/staging-unstable/)
| `st2_pkg_repo` | `stable` | StackStorm PackageCloud repository to install. [`stable`](https://packagecloud.io/StackStorm/stable/), [`unstable`](https://packagecloud.io/StackStorm/unstable/), [`staging-stable`](https://packagecloud.io/StackStorm/staging-stable/), [`staging-unstable`](https://packagecloud.io/StackStorm/staging-unstable/)
| **st2**
| `st2_version` | `latest` | StackStorm version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.1.1`.
| `st2_revision` | `1` | StackStorm revision to install. Used only with pinned `st2_version`.
| `st2_system_user` | `stanley` | System user from which st2 will execute local/remote shell actions.
| `st2_version` | `latest` | StackStorm version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.1.1`.
| `st2_revision` | `1` | StackStorm revision to install. Used only with pinned `st2_version`.
| `st2_system_user` | `stanley` | System user from which st2 will execute local/remote shell actions.
| `st2_system_user_in_sudoers` | `yes`| Add `st2_system_user` to the sudoers (recommended for most `st2` features to work).
| `st2_ssh_key_file` | `/home/{{st2_system_user}}/.ssh/{{st2_system_user}}_rsa` | Path to `st2_system_user` SSH private key. It will be autogenerated by default.
| `st2_auth_enable` | `yes` | Enable StackStorm standalone authentication.
| `st2_auth_username` | `testu` | Username used by StackStorm standalone authentication.
| `st2_auth_password` | `testp` | Password used by StackStorm standalone authentication.
| `st2_ssh_key_file` | `/home/{{st2_system_user}}/.ssh/{{st2_system_user}}_rsa` | Path to `st2_system_user` SSH private key. It will be autogenerated by default.
| `st2_auth_enable` | `yes` | Enable StackStorm standalone authentication.
| `st2_auth_username` | `testu` | Username used by StackStorm standalone authentication.
| `st2_auth_password` | `testp` | Password used by StackStorm standalone authentication.
| **st2mistral**
| `mistral_version` | `latest` | st2mistral version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.1.1`.
| `mistral_db` | `mistral` | PostgreSQL DB name for Mistral.
| `mistral_db_username` | `mistral` | PostgreSQL DB user for Mistral.
| `mistral_db_password` | `StackStorm` | PostgreSQL DB password for Mistral.
| `st2mistral_version` | `latest` | st2mistral version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.1.1`.
| `st2mistral_db` | `mistral` | PostgreSQL DB name for Mistral.
| `st2mistral_db_username` | `mistral` | PostgreSQL DB user for Mistral.
| `st2mistral_db_password` | `StackStorm` | PostgreSQL DB password for Mistral.

## Examples
Install latest `stable` StackStorm with all its components on local machine:
Expand Down
12 changes: 8 additions & 4 deletions roles/st2mistral/defaults/main.yml
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
6 changes: 4 additions & 2 deletions roles/st2mistral/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ galaxy_info:
description: Install custom OpenStack Mistral, patched by StackStorm
author: armab
company: StackStorm
license: Apache
license: Apache 2.0
min_ansible_version: 2.2
tags: st2mistral
platforms:
Expand All @@ -16,7 +16,9 @@ galaxy_info:
- 6
- 7
categories:
- system
- automation
- devops
- workflows
dependencies:
- role: postgresql
- role: st2repos
63 changes: 39 additions & 24 deletions roles/st2mistral/tasks/main.yml
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
Expand All @@ -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
Expand All @@ -55,9 +42,29 @@
- restart mistral
tags: st2mistral

- name: Setup Mistral DB tables, etc
- name: Make sure "Initiate mistral database" doesn't run twice
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
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
Expand All @@ -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
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
4 changes: 2 additions & 2 deletions roles/st2mistral/templates/init_mistral_db.SQL.j2
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 }};

0 comments on commit 156a084

Please sign in to comment.