-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
- name: Install latest st2mistral | ||
become: yes | ||
apt: | ||
package: | ||
name: st2mistral | ||
state: latest |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this PR is still WIP, I left some early comments, - hopefully that'll help.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_cache: yes
will break Ansible idempotence. Avoid using where possible
|
||
- 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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
- 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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, Ansibe module http://docs.ansible.com/ansible/lineinfile_module.html can help to make sure the command is Ansible-idempotent
@@ -5,6 +5,7 @@ | |||
- mongodb | |||
- rabbitmq | |||
- st2repos | |||
- postgresql | |||
- mistral |
There was a problem hiding this comment.
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.
service: | ||
name: postgresql | ||
state: started | ||
tags: [db, postgresql] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional "enable" action is missing
@@ -0,0 +1,34 @@ | |||
--- | |||
- name: yum | Initialize postgresql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you meant Install postgresql
, because next block is Initialize postgresql
connection: local | ||
tasks: | ||
- name: Install galaxy dependencies | ||
command: ansible-galaxy install -r roles/mistral/requirements.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
when: ansible_distribution == "CentOS" | ||
tags: [db, postgresql] | ||
|
||
- name: yum | Get pgdg-centos94-9.4-2 for {{ ansible_distribution }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be confusing. Probably it means "Setup PostgreSQL repository" or something like that.
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if https://
version will work here (and in previous block)? for yum install from url
@@ -0,0 +1,14 @@ | |||
--- | |||
- name: apt | Initialize postgresql |
There was a problem hiding this comment.
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.
@@ -26,8 +26,6 @@ ansible-playbook stackstorm.yml | |||
``` | |||
|
|||
## Dependencies | |||
Ansible Galaxy roles used by StackStorm installation: |
There was a problem hiding this comment.
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.
- trusty | ||
- xenial | ||
- name: EL | ||
- 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versions:
is missing
- name: Install st2mistral dependency | ||
become: yes | ||
package: | ||
name: st2python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
I assume that's the case why mistral didn't work for you.
We install st2python
as package dependency for st2
, see: https://github.com/StackStorm/st2-packages/blob/a46cc2267ac4b23c8f21a3471824c7c7f430cd1a/packages/st2/rpm/st2.spec#L15
Seems like we should add the same dependency for st2mistral
as well in st2-packages
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an Issue for that: StackStorm/st2-packages#407 so we won't forget about it and fix the root cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the bootstrap scripts we install st2
and its dependencies before st2mistral
, that is why it was never caught: https://github.com/StackStorm/st2-packages/blob/master/scripts/st2bootstrap-el6.sh#L653. However, we may not have another use case, besides this and docker, where anyone installs st2mistral
before st2
.
package: | ||
name: st2python | ||
state: present | ||
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ansible_distribution == "CentOS"
Will it work on RHEL6
?
- name: yum | Initialize Postgresql-9.4 | ||
become: yes | ||
command: service postgresql-9.4 initdb | ||
tags: [db, postgresql] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, this command needs a "file lock" to ensure that we run initdb
only once per system and don't repeat it.
OR even better, - it's possible to run init
only when previous block "changed", eg. only when package was installed.
See: https://raymii.org/s/tutorials/Ansible_-_Only-do-something-if-another-action-changed.html
yum: | ||
name: "{{ item }}" | ||
state: installed | ||
update_cache: yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid update_cache
here to make this command Ansible-idempotent friendly?
With update_cache it will always have "changed" state.
- trusty | ||
- xenial | ||
- name: EL | ||
- 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versions:
is missing
Overall looks nice 👍 The final thing I would like you to address is Ansible Idempotence.
|
- name: yum | Initialize Postgresql | ||
become: yes | ||
command: postgresql-setup initdb | ||
when: install_postgresql.changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice indeed 👍
@@ -19,15 +19,11 @@ 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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR indeed 👍
A lot of work and in-depth testing (especially +:100: for real RHEL
testing).
Besides of comment ^^ above about README.md
update everything looks good to me. Let's change and if you see it's Ansible-idempotent, I'm +1 to merge.
cc @bigmstone @Mierdin please take a look as well.
TASK [ANXS.postgresql : PostgreSQL | Add PostgreSQL repository] ****************
task path: /tmp/kitchen/roles/ANXS.postgresql/tasks/install.yml:17
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'postgresql_apt_repository' failed. The error was: expected token 'end of statement block', got 'http'\n line 1\n\nThe error appears to have been in '/tmp/kitchen/roles/ANXS.postgresql/tasks/install.yml': line 17, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: PostgreSQL | Add PostgreSQL repository\n ^ here\n"} https://travis-ci.org/StackStorm/ansible-st2/jobs/191748821 So this PR which removes external dependencies is just in time! |
Covers #76 and #11