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

Conversation

humblearner
Copy link
Contributor

@humblearner humblearner commented Jan 11, 2017

  • Xenial
  • Trusty
  • Centos6
  • Centos7
  • Rhel6
  • Rhel7

Covers #76 and #11

@humblearner humblearner changed the title [WIP] Rhel support: Mistral and create PostgreSQL role [WIP] Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency) Jan 12, 2017
- 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.

Copy link
Member

@arm4b arm4b left a 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
Copy link
Member

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'
Copy link
Member

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'
Copy link
Member

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

service:
name: postgresql
state: started
tags: [db, postgresql]
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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 }}
Copy link
Member

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
Copy link
Member

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

@humblearner humblearner added RFR and removed WIP labels Jan 13, 2017
@humblearner humblearner changed the title [WIP] Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency) Rhel support for mistral and create postgresql role (remove AXNS.postgresql dependency) Jan 13, 2017
@@ -26,8 +26,6 @@ ansible-playbook stackstorm.yml
```

## Dependencies
Ansible Galaxy roles used by StackStorm installation:
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.

- 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

- name: Install st2mistral dependency
become: yes
package:
name: st2python
Copy link
Member

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.

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.

Created an Issue for that: StackStorm/st2-packages#407 so we won't forget about it and fix the root cause.

Copy link
Contributor Author

@humblearner humblearner Jan 16, 2017

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"
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.

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

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
Copy link
Member

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

@arm4b
Copy link
Member

arm4b commented Jan 13, 2017

Overall looks nice 👍

The final thing I would like you to address is Ansible Idempotence.
Eg. Ansible-playbook re-run should end with the following results:

changed=0.*failed=0

- name: yum | Initialize Postgresql
become: yes
command: postgresql-setup initdb
when: install_postgresql.changed
Copy link
Member

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

Copy link
Member

@arm4b arm4b left a 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.

@arm4b arm4b mentioned this pull request Jan 16, 2017
@arm4b
Copy link
Member

arm4b commented Jan 16, 2017

ANXS.postgresql dependency started to fail for previously successful master builds:

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!

@humblearner humblearner merged commit f5df0b6 into master Jan 16, 2017
@humblearner humblearner deleted the rhel_mistral_support branch January 16, 2017 20:39
@blag blag added the OS support Support/issues/PRs on a specific OS label Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change feature OS support Support/issues/PRs on a specific OS RFR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants