Skip to content

Commit

Permalink
Merge pull request #78 from StackStorm/rhel_mistral_support
Browse files Browse the repository at this point in the history
Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency)
  • Loading branch information
humblearner authored Jan 16, 2017
2 parents bae94e2 + d6144fd commit f5df0b6
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 57 deletions.
1 change: 0 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ provisioner:
name: ansible_playbook
hosts: all
roles_path: roles
requirements_path: roles/mistral/requirements.yml
ansible_verbose: true
ansible_verbosity: 2
# TODO: Make sure Ansible playbooks are idepotent
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Aka IFTTT orchestration for Ops.

## Supported platforms
* Ubuntu Trusty (14.04)
* Ubuntu Xenial (16.04)
* Ubuntu Xenial (16.04)

> If you're using the provided Vagrantfile, note that it uses Xenial by default. Due to some of the changes there, Vagrant 1.9.1 or better is required.
Expand All @@ -19,16 +19,10 @@ At least 2GB of memory and 3.5GB of disk space is required, since StackStorm is

## Installation
```sh
# ansible galaxy roles
ansible-playbook requirements.yml
# stackstorm
ansible-playbook stackstorm.yml
```

## Dependencies
Ansible Galaxy roles used by StackStorm installation:
* [ANXS.postgresql](https://galaxy.ansible.com/list#/roles/512) - PostgreSQL, needed by Mistral

## Variables
Below is the list of variables you can redefine in your playbook to customize st2 deployment:

Expand All @@ -52,15 +46,15 @@ ansible-playbook stackstorm.yml -i 'localhost,' --connection=local
```

> Note that keeping `stable` version is useful to update StackStorm by re-running playbook, since it will reinstall st2 if there is new version available.
This is default behavior. If you don't want updates - consider pinning version-revision numbers.
This is default behavior. If you don't want updates - consider pinning version-revision numbers.

Install specific numeric version of st2 with pinned revision number as well:
```sh
ansible-playbook stackstorm.yml --extra-vars='st2_version=1.4.0 st2_revision=8'
```

## Other Installers
You might be interested in other methods to deploy StackStorm engine:
You might be interested in other methods to deploy StackStorm engine:
* Configuration Management
* [Chef Cookbook](https://github.com/StackStorm/chef-stackstorm/)
* [Puppet Module](https://github.com/stackstorm/puppet-st2)
Expand Down
3 changes: 0 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
inline: "sudo yum -y install epel-release; sudo yum -y install ansible git"
end

vm_config.vm.provision :ansible do |ansible|
ansible.playbook = "requirements.yml"
end
vm_config.vm.provision :ansible do |ansible|
ansible.playbook = "stackstorm.yml"
end
Expand Down
7 changes: 0 additions & 7 deletions requirements.yml

This file was deleted.

26 changes: 0 additions & 26 deletions roles/mistral/meta/main.yml

This file was deleted.

3 changes: 0 additions & 3 deletions roles/mistral/requirements.yml

This file was deleted.

19 changes: 19 additions & 0 deletions roles/postgresql/meta/main.yaml
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
11 changes: 11 additions & 0 deletions roles/postgresql/tasks/main.yml
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"

15 changes: 15 additions & 0 deletions roles/postgresql/tasks/postgresql_apt.yml
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]
66 changes: 66 additions & 0 deletions roles/postgresql/tasks/postgresql_yum6.yml
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]

- 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]

42 changes: 42 additions & 0 deletions roles/postgresql/tasks/postgresql_yum7.yml
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
when: install_postgresql.changed
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]
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions roles/st2mistral/meta/main.yml
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
- 7
categories:
- system
dependencies:
- role: postgresql
- role: st2repos
37 changes: 31 additions & 6 deletions roles/mistral/tasks/main.yml → roles/st2mistral/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
---
- name: Install st2mistral dependency
become: yes
package:
name: st2python
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
Expand All @@ -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 }};
Loading

0 comments on commit f5df0b6

Please sign in to comment.