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

Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency) #78

Merged
merged 19 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from 10 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
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
8 changes: 3 additions & 5 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 @@ -26,8 +26,6 @@ ansible-playbook stackstorm.yml
```

## Dependencies
Copy link
Member

Choose a reason for hiding this comment

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

This line could be removed as well, take a look at resulting README.md.

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

Copy link
Member

@arm4b arm4b Jan 13, 2017

Choose a reason for hiding this comment

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

Please also remove another requirements.yml occurrence in README.md.

## Variables
Below is the list of variables you can redefine in your playbook to customize st2 deployment:
Expand All @@ -52,15 +50,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.

19 changes: 7 additions & 12 deletions roles/mistral/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ galaxy_info:
author: armab
company: StackStorm
license: Apache
min_ansible_version: 1.9.1
min_ansible_version: 2.2
tags: mistral
platforms:
- name: Ubuntu
versions:
- trusty
- precise
- xenial
- name: EL
- 6
- 7
categories:
- system
dependencies:
- role: ANXS.postgresql
version: v1.5.0
tags: [db, postgresql]
become: yes
postgresql_databases:
- name: "{{ mistral_db }}"
postgresql_users:
- name: "{{ mistral_db_username }}"
pass: "{{ mistral_db_password }}"
encrypted: yes
- role: postgresql
- role: st2repos
3 changes: 0 additions & 3 deletions roles/mistral/requirements.yml

This file was deleted.

23 changes: 16 additions & 7 deletions roles/mistral/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
---

- name: Install latest st2mistral
become: yes
apt:
package:
name: st2mistral
state: latest
Copy link
Contributor Author

@humblearner humblearner Jan 12, 2017

Choose a reason for hiding this comment

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

Not sure if we should keep it latest or use present

Copy link
Member

@arm4b arm4b Jan 12, 2017

Choose a reason for hiding this comment

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

Yeah, it's good.
The idea here to install latest mistral eg. get upgrades, but only when condition is met in this block.

when: mistral_version == "stable"
tags: mistral

- name: Install latest st2mistral
become: yes
apt:
package:
name: st2mistral={{ mistral_version }}
state: present
when: mistral_version != "stable"
tags: mistral

- name: Configure mistral
become: yes
Expand All @@ -22,45 +23,51 @@
option: connection
value: postgresql://{{ mistral_db_username }}:{{ mistral_db_password }}@localhost/{{ mistral_db }}
backup: yes
tags: mistral

- 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
notify:
- restart mistral
tags: mistral

- 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
notify:
- restart mistral
tags: mistral

- name: Make sure "Initiate database" doesn't run twice
become: yes
file:
path: /etc/mistral/init_mistral_db.SQL.ansible.has.run
state: touch
tags: mistral

- 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:
notify:
- restart mistral
tags: mistral

- 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
tags: mistral

- name: Register mistral actions
become: yes
Expand All @@ -69,9 +76,11 @@
creates: /etc/mistral/mistral-db-manage.populate.ansible.has.run
notify:
- restart mistral
tags: mistral

- 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
tags: mistral
2 changes: 1 addition & 1 deletion roles/mistral/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 ROLE {{ mistral_db_username }} WITH CREATEDB LOGIN ENCRYPTED PASSWORD '{{ mistral_db_password }}';
CREATE DATABASE {{ mistral_db }} OWNER {{ mistral_db_username }};
18 changes: 18 additions & 0 deletions roles/postgresql/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
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
- 6
Copy link
Member

Choose a reason for hiding this comment

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

versions: is missing

- 7
categories:
- system
11 changes: 11 additions & 0 deletions roles/postgresql/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Install postgres 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 postgres on {{ ansible_distribution }}-{{ ansible_distribution_major_version }}
include: roles/postgresql/tasks/postgresql_{{ ansible_pkg_mgr }}.yml
tags: [db, postgresql]
when: ansible_os_family == "Debian"

14 changes: 14 additions & 0 deletions roles/postgresql/tasks/postgresql_apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: apt | Initialize postgresql
Copy link
Member

Choose a reason for hiding this comment

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

Probably Install PostgreSQL and so Initialize PostgreSQL step is missing.

become: yes
apt:
name: postgresql
state: installed
tags: [db, postgresql]

- name: apt | Start and Enable Postgresql
become: yes
service:
name: postgresql
state: started
tags: [db, postgresql]
53 changes: 53 additions & 0 deletions roles/postgresql/tasks/postgresql_yum6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
- name: yum | Get pgdg-centos94-9.4-2 for {{ ansible_distribution }}
become: yes
yum:
name: http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-2.noarch.rpm
state: installed
update_cache: yes
when: ansible_distribution == "CentOS"
tags: [db, postgresql]

- name: yum | Get pgdg-centos94-9.4-2 for {{ ansible_distribution }}
become: yes
yum:
name: http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-2.noarch.rpm
state: installed
update_cache: yes
when: ansible_distribution == "RedHat"
tags: [db, postgresql]

- name: yum | Install postgresql94
become: yes
yum:
name: "{{ item }}"
state: installed
update_cache: yes
with_items:
- postgresql94-server
- postgresql94-contrib
- postgresql94-devel
tags: [db, postgresql]

- name: yum | Initialize Postgresql-9.4
become: yes
command: service postgresql-9.4 initdb
tags: [db, postgresql]

- name: yum | MD5-encrypted password for postgresql 1
become: yes
command: 'sed -i "s/\(host.*all.*all.*127.0.0.1\/32.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf'
tags: [db, postgresql]

- name: yum | MD5-encrypted password for postgresql 2
become: yes
command: 'sed -i "s/\(host.*all.*all.*::1\/128.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf'
tags: [db, postgresql]

- name: yum | Start and Enable Postgresql-9.4
become: yes
service:
name: postgresql-9.4
state: started
tags: [db, postgresql]

34 changes: 34 additions & 0 deletions roles/postgresql/tasks/postgresql_yum7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: yum | Initialize postgresql
become: yes
yum:
name: "{{ item }}"
state: installed
update_cache: yes
with_items:
- postgresql-server
- postgresql-contrib
- postgresql-devel
tags: [db, postgresql]

- name: yum | Initialize Postgresql
become: yes
command: postgresql-setup initdb
tags: [db, postgresql]

- name: yum | MD5-encrypted password for postgres 1
become: yes
command: 'sed -i "s/\(host.*all.*all.*127.0.0.1\/32.*\)ident/\1md5/" /var/lib/pgsql/data/pg_hba.conf'
tags: [db, postgresql]

- name: yum | MD5-encrypted password for postgres 2
become: yes
command: 'sed -i "s/\(host.*all.*all.*::1\/128.*\)ident/\1md5/" /var/lib/pgsql/data/pg_hba.conf'
tags: [db, postgresql]

- name: yum | Start and Enable Postgresql
become: yes
service:
name: postgresql
state: started
tags: [db, postgresql]
1 change: 1 addition & 0 deletions stackstorm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- mongodb
- rabbitmq
- st2repos
- postgresql
- mistral
Copy link
Member

Choose a reason for hiding this comment

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

Please don't forget to rename misral to st2mistral as requested in #11

So we'll use the following roles responsible for StackStorm:

  • st2
  • st2mistral
  • st2web
  • st2chatops in future

for consistency.

- st2
- st2web
Expand Down