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

Add vars to configure any 'st2.conf' and 'mistral.conf' settings #121

Merged
merged 8 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Below is the list of variables you can redefine in your playbook to customize st
| **st2**
| `st2_version` | `latest` | StackStorm version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.2.0`.
| `st2_revision` | `1` | StackStorm revision to install. Used only with pinned `st2_version`.
| `st2_config` | `{}` | Hash with StackStorm configuration settings to set in [`st2.conf`](https://github.com/StackStorm/st2/blob/master/conf/st2.conf.sample) ini file.
| `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.
Expand All @@ -44,9 +45,10 @@ Below is the list of variables you can redefine in your playbook to customize st
| `st2_save_credentials` | `yes` | Save credentials for local CLI in `/root/.st2/config` file.
| **st2mistral**
| `st2mistral_version` | `latest` | st2mistral version to install. Use latest `latest` to get automatic updates or pin it to numeric version like `2.2.0`.
| `st2mistral_db` | `mistral` | PostgreSQL DB name for Mistral.
| `st2mistral_db_username` | `mistral` | PostgreSQL DB user for Mistral.
| `st2mistral_db` | `mistral` | PostgreSQL DB name that will be created for Mistral.
| `st2mistral_db_username` | `mistral` | PostgreSQL DB user that will be created for Mistral.
| `st2mistral_db_password` | `StackStorm` | PostgreSQL DB password for Mistral.
| `st2mistral_config` | `{}` | Hash with configuration settings to set in [`mistral.conf`](https://github.com/StackStorm/st2-packages/blob/master/packages/st2mistral/conf/mistral.conf) ini file.
| **st2web**
| `st2web_ssl_certificate` | `null` | String with custom SSL certificate (`.crt`). If not provided, self-signed certificate will be generated.
| `st2web_ssl_certificate_key` | `null` | String with custom SSL certificate secret key (`.key`). If not provided, self-signed certificate will be generated.
Expand Down
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Vagrant.configure(2) do |config|

vm_config.vm.provision :ansible_local do |ansible|
ansible.install = true
ansible.verbose = true
ansible.playbook = "stackstorm.yml"
end
end
Expand Down
15 changes: 15 additions & 0 deletions roles/st2/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ st2_version: latest
# used only if 'st2_version' is numeric
st2_revision: 1

# Hash with StackStorm configuration settings to set in 'st2.conf' ini file
# See https://github.com/StackStorm/st2/blob/master/conf/st2.conf.sample for a full list
st2_config: {}
# Example:
#st2_config:
# auth:
# debug: True
# enable: True
# database:
# username: st2
# db_name: st2
# password: random-password123
# messaging:
# url: amqp://st2:st2@127.0.0.1:5672//

# System user from which st2 will execute local/remote shell actions
st2_system_user: stanley
# Add `st2_system_user` to the sudoers (recommended for most `st2` features to work)
Expand Down
14 changes: 14 additions & 0 deletions roles/st2/tasks/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Change '[{{ _conf_section_name }}]' options in st2.conf
become: yes
ini_file:
dest: /etc/st2/st2.conf
section: "{{ _conf_section_name }}"
option: "{{ _conf_option.key }}"
value: "{{ _conf_option.value }}"
with_dict: "{{ _conf_options }}"
loop_control:
loop_var: _conf_option
notify:
- restart st2
tags: st2, config
10 changes: 9 additions & 1 deletion roles/st2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@

- name: Configure StackStorm authentication
include: auth.yml
when: st2_auth_enable
when: "{{ st2_config.auth.enable|default(st2_auth_enable) if st2_config.auth is defined else st2_auth_enable }}"
tags: st2, auth

- name: Configure StackStorm st2.conf settings
# Ansible nested loop to iterate through a hash of hashes
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
with_dict: "{{ st2_config }}"
loop_control:
loop_var: _conf_section
tags: st2, config

- name: Ensure StackStorm services are enabled and running
become: yes
service:
Expand Down
10 changes: 10 additions & 0 deletions roles/st2mistral/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ st2mistral_db: mistral
st2mistral_db_username: mistral
# PostgreSQL DB password for Mistral.
st2mistral_db_password: StackStorm

# Hash with configuration settings to set in `mistral.conf` ini file.
# See: https://github.com/StackStorm/st2-packages/blob/master/packages/st2mistral/conf/mistral.conf for a full list.
st2mistral_config: {}
# Example:
#st2mistral_config:
# DEFAULT:
# transport_url: rabbit://guest:guest@127.0.0.1:5672
# database:
# connection: postgresql://mistral:StackStorm@localhost/mistral
14 changes: 14 additions & 0 deletions roles/st2mistral/tasks/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Change '[{{ _conf_section_name }}]' options in mistral.conf
become: yes
ini_file:
dest: /etc/mistral/mistral.conf
section: "{{ _conf_section_name }}"
option: "{{ _conf_option.key }}"
value: "{{ _conf_option.value }}"
with_dict: "{{ _conf_options }}"
loop_control:
loop_var: _conf_option
notify:
- restart mistral
tags: st2mistral, config
8 changes: 8 additions & 0 deletions roles/st2mistral/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
- restart mistral
tags: st2mistral

- name: Configure mistral.conf settings
# Ansible nested loop to iterate through a hash of hashes
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
with_dict: "{{ st2mistral_config }}"
loop_control:
loop_var: _conf_section
tags: st2mistral, config

- 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
Expand Down