-
-
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
Setup BWC repos, Install BWC and Setup RBAC #126
Changes from 12 commits
ab143a0
6d05514
dca13a3
3098871
b850d58
c287cc3
b3772fc
8548acc
a09cb88
ac4cd06
69fd550
1aa9d35
ea34e3c
22f86a1
1c1ebd0
bd198f2
17d7045
aaccdab
18da115
a5f2478
b7d84e7
a343cd6
6ff9e0b
e1977f0
5318182
9a5dee6
df65ee2
2fd65e8
56d0587
c1d98a9
8837fff
48dcd6b
b4843f3
76084dd
15ac7e6
9891ed2
9b5ff73
a729179
51ff517
7baa909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
bwc_pkg_repo: "enterprise" | ||
# 'latest' to get latest version or numeric like '2.1.1' | ||
bwc_version: latest | ||
# used only if 'bwc_version' is numeric | ||
bwc_revision: 1 | ||
|
||
st2_config_file_path: /etc/st2/st2.conf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As noted before, don't forget to hardcode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
- name: reload bwc_rbac | ||
become: yes | ||
command: st2-apply-rbac-definitions --config-file {{ st2_config_file_path }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
galaxy_info: | ||
description: Install BWC Entperprise components, setup RBAC and LDAP | ||
author: lakshmi-kannan | ||
company: StackStorm | ||
license: Apache 2.0 | ||
min_ansible_version: 2.2 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- trusty | ||
- xenial | ||
- name: EL | ||
versions: | ||
- 6 | ||
- 7 | ||
categories: | ||
- stackstorm | ||
- BWC | ||
- Brocade Workflow Composer | ||
- repositories | ||
- packagecloud | ||
dependencies: | ||
- role: st2repos | ||
- role: st2 | ||
- role: st2web | ||
- role: bwc_repos |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
- name: Setup st2.conf auth backend to LDAP | ||
become: yes | ||
ini_file: | ||
dest: "{{ st2_config_file_path }}" | ||
section: auth | ||
option: backend | ||
value: ldap | ||
backup: yes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notify st2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we also have to set the backend_kwargs before restarting. See next step. I did notify. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include notify for every task where its needed logically (ex: changing the conf file), its less error prone since "next task" could be removed, adjusted or never ran because of some conditional. It doesn't matter how many times we call Ansible handlers, - they will be executed in the end of entire play run in any way. See "Handlers: Running Operations On Change": http://docs.ansible.com/ansible/playbooks_intro.html with better explanation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, good to know about that. |
||
|
||
- name: Setup st2.conf auth backend_kwargs for LDAP | ||
become: yes | ||
ini_file: | ||
dest: "{{ st2_config_file_path }}" | ||
section: auth | ||
option: backend_kwargs | ||
value: "{{ ldap.config | to_nice_json }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prints out a multi-line string in the ini file and our config parser pukes. I tried to_json. Still the same. |
||
backup: yes | ||
notify: | ||
- restart st2api | ||
- restart st2stream |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
|
||
- name: Install latest bwc-enterprise package | ||
become: yes | ||
package: | ||
name: bwc-enterprise | ||
state: latest | ||
when: bwc_version == "latest" | ||
tags: | ||
- bwc | ||
- st2 enterprise | ||
|
||
- name: Install pinned bwc-enterprise package | ||
become: yes | ||
package: | ||
name: bwc-enterprise={{ bwc_version }}-{{ bwc_revision }} | ||
state: present | ||
when: bwc_version != "latest" | ||
tags: | ||
- bwc | ||
- st2 enterprise | ||
|
||
- name: Setup RBAC and setup roles and assignments if enable_rbac is defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is |
||
include: "rbac.yml" | ||
when: rbac is defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please name vars accordingly to role, eg: |
||
|
||
- name: Setup LDAP and set up LDAP configuration | ||
include: "ldap.yml" | ||
when: ldap is defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please name vars accordingly to role, eg: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
|
||
- name: Create BWC RBAC directories | ||
become: yes | ||
file: | ||
path: "{{ item }}" | ||
mode: "u+rw,g-wx,o-rwx" | ||
owner: st2 | ||
group: st2 | ||
state: directory | ||
with_items: | ||
- /opt/stackstorm/rbac/assignments | ||
- /opt/stackstorm/rbac/roles | ||
|
||
- name: Copy RBAC roles to /opt/stackstorm/rbac/roles directory | ||
become: yes | ||
template: | ||
src: rbac_roles/roles.yml.j2 | ||
dest: /opt/stackstorm/rbac/roles/{{ item.name }}.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing any file in Make sure we run that thing for other tasks in this file. |
||
owner: st2 | ||
group: st2 | ||
with_items: "{{ rbac.roles }}" | ||
when: rbac_roles is defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't find any occurrence of |
||
|
||
- name: Copy RBAC assignments to /opt/stackstorm/rbac/assignments directory | ||
become: yes | ||
template: | ||
src: rbac_assignments/assignments.yml.j2 | ||
dest: /opt/stackstorm/rbac/assignments/{{ item.name }}.yaml | ||
owner: st2 | ||
group: st2 | ||
with_items: "{{ rbac.assignments }}" | ||
when: rbac_assignments is defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't find any occurrence of |
||
|
||
- name: Enable RBAC in st2 configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enable auth maybe? |
||
become: yes | ||
ini_file: | ||
dest: /etc/st2/st2.conf | ||
section: auth | ||
option: enable | ||
value: True | ||
backup: yes | ||
notify: | ||
- restart st2 | ||
- reload bwc_rbac | ||
- restart st2api | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
username: {{ item.name }} | ||
roles: {{ item.roles | to_nice_yaml }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
name: {{ item.name }} | ||
description: {{ item.description }} | ||
permission_grants: {{ item.permission_grants | to_nice_yaml }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# BWC PackageCloud repository to install: enterprise, enterprise-unstable, staging-enterprise, staging-enterprise-unstable. | ||
bwc_pkg_repo: enterprise | ||
|
||
deb_os: "{{ ansible_distribution|lower }}" | ||
deb_os_version: "{{ ansible_distribution_release|lower }}" | ||
|
||
rpm_os: "el" | ||
rpm_os_version: "{{ ansible_distribution_major_version }}" | ||
|
||
master_token: "{{ license }}" | ||
|
||
deb_gpg_key_url: "https://{{ master_token }}:@packagecloud.io/install/repositories/StackStorm/enterprise/gpg_key_url.list?os={{ deb_os }}&dist={{ deb_os_version }}&name={{ ansible_nodename }}" | ||
|
||
deb_config_file_url: "https://{{ master_token }}:@packagecloud.io/install/repositories/StackStorm/{{ bwc_pkg_repo }}/config_file.list?os={{ deb_os }}&dist={{ deb_os_version }}&name={{ ansible_nodename }}" | ||
deb_config_file_location: "/etc/apt/sources.list.d/packagecloud_io_StackStorm_{{ bwc_pkg_repo }}.list" | ||
|
||
rpm_config_file_url: "https://{{ master_token }}:@packagecloud.io/install/repositories/StackStorm/{{ bwc_pkg_repo }}/config_file.repo?os={{ rpm_os }}&dist={{ rpm_os_version }}&name={{ ansible_nodename }}" | ||
rpm_config_file_location: "/etc/yum.repos.d/packagecloud_io_StackStorm_{{ bwc_pkg_repo }}.repo" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
galaxy_info: | ||
description: Install BWC PackageCloud repository | ||
author: lakshmi-kannan | ||
company: StackStorm | ||
license: Apache 2.0 | ||
min_ansible_version: 2.2 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- trusty | ||
- xenial | ||
- name: EL | ||
versions: | ||
- 6 | ||
- 7 | ||
categories: | ||
- stackstorm | ||
- BWC | ||
- Brocade Workflow Composer | ||
- repositories | ||
- packagecloud |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||||||||||
--- | ||||||||||||||
|
||||||||||||||
- name: Assert that master_token is specified | ||||||||||||||
fail: msg="License key must be supplied for BWC enterprise installation." | ||||||||||||||
when: license is not defined | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please include all possible vars used in the roles in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, vars should follow the |
||||||||||||||
|
||||||||||||||
- name: Install prereqs (Debian) | ||||||||||||||
become: yes | ||||||||||||||
apt: | ||||||||||||||
name: "{{ item }}" | ||||||||||||||
state: present | ||||||||||||||
with_items: | ||||||||||||||
- debian-archive-keyring | ||||||||||||||
- apt-transport-https | ||||||||||||||
|
||||||||||||||
- name: Get GPG key URL for private repo | ||||||||||||||
become: yes | ||||||||||||||
shell: 'curl "{{ deb_gpg_key_url }}"' | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not idempotent |
||||||||||||||
register: deb_gpg_key | ||||||||||||||
|
||||||||||||||
# This is the exact key as the open source repo but this behavior might change. So just | ||||||||||||||
# following what's in packagecloud docs for private repos. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, and it's not idempotent. Please refactor Ex for this case: ansible-st2/roles/st2repos/tasks/st2repos_apt.yml Lines 11 to 16 in 91bd718
|
||||||||||||||
- name: Add GPG key to keyring | ||||||||||||||
become: yes | ||||||||||||||
shell: 'curl -L "{{ deb_gpg_key.stdout }}" | apt-key add -' | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not idempotent |
||||||||||||||
when: ansible_os_family == "Debian" and license is defined | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We never reach this task if license is not defined, because of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We're already in Debian play, according to file name |
||||||||||||||
|
||||||||||||||
- name: "Adding packagecloud.io repository: StackStorm/{{ bwc_pkg_repo }} with generated read token" | ||||||||||||||
become: yes | ||||||||||||||
shell: 'curl "{{ deb_config_file_url }}" > {{ deb_config_file_location }}' | ||||||||||||||
args: | ||||||||||||||
creates: "{{ deb_config_file_location }}" | ||||||||||||||
register: added_bwc_deb_repository | ||||||||||||||
when: ansible_os_family == "Debian" and license is defined | ||||||||||||||
|
||||||||||||||
- name: Update APT package cache | ||||||||||||||
become: yes | ||||||||||||||
apt: | ||||||||||||||
update_cache: true | ||||||||||||||
when: ansible_os_family == "Debian" and added_bwc_deb_repository|success |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
|
||
- name: Assert that master_token is specified | ||
fail: msg="License key must be supplied for BWC enterprise installation." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
when: license is not defined | ||
|
||
# Fixes "Failure talking to yum: Cannot retrieve repository metadata (repomd.xml) for repository: StackStorm_stable. Please verify its path and try again" when installing st2 | ||
- name: Update ca-certificates package | ||
become: yes | ||
yum: | ||
name: ca-certificates | ||
state: latest | ||
tags: skip_ansible_lint | ||
|
||
# See: https://github.com/docker-library/docs/tree/master/centos#package-documentation | ||
# We ship `nginx.conf` via `st2` package doc files, for example | ||
- name: Enable shipping package documentation files for EL | ||
become: yes | ||
ini_file: | ||
dest: /etc/yum.conf | ||
section: main | ||
option: tsflags | ||
value: nodocs | ||
state: absent | ||
when: ansible_os_family == "RedHat" | ||
|
||
- name: Add BWC enterprise repo | ||
become: yes | ||
shell: 'curl "{{ rpm_config_file_url }}" > {{ rpm_config_file_location }}' | ||
args: | ||
creates: "{{ rpm_config_file_location }}" | ||
register: added_bwc_rpm_repository | ||
when: ansible_os_family == "RedHat" and license is defined | ||
|
||
- name: Update yum package cache | ||
become: yes | ||
shell: yum -q makecache -y --disablerepo='*' --enablerepo='StackStorm_{{ bwc_pkg_repo|replace("/", "_") }}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any idea why do we need this? |
||
when: ansible_os_family == "RedHat" and added_bwc_rpm_repository|success | ||
|
||
- name: Update yum package cache BWC enterprise source repo | ||
become: yes | ||
shell: yum -q makecache -y --disablerepo='*' --enablerepo='StackStorm_{{ bwc_pkg_repo|replace("/", "_") }}-source' | ||
when: ansible_os_family == "RedHat" and added_bwc_rpm_repository|success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
we're already in os-family specific |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Add BWC enterprise repos on {{ ansible_distribution }} | ||
include: bwc_repos_{{ ansible_pkg_mgr }}.yml | ||
tags: | ||
- BWC repos | ||
- StackStorm enterprise |
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 define all vars used in this role with comments, as well as include them in
README.md
.