Skip to content

Commit

Permalink
Initial pass at adding RH-capable provisioning for 'st2' and 'st2repo…
Browse files Browse the repository at this point in the history
…s' roles

Signed-off-by: Matt Oswalt <[email protected]>
  • Loading branch information
Matt Oswalt committed Jan 4, 2017
1 parent dd92822 commit 36329a6
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 43 deletions.
11 changes: 7 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision :hostmanager
end

# Install Ansible native packages so the Ansible provisioner will work on systems
# without Python 2.7 (i.e. Xenial)
config.vm.provision "shell",
inline: "sudo apt-add-repository -y ppa:ansible/ansible; sudo apt-get update; sudo apt-get install -y ansible"
if config.vm.box.include? "ubuntu"
# Install Ansible native packages so the Ansible provisioner will work on systems
# without Python 2.7 (i.e. Xenial)
config.vm.provision "shell",
inline: "sudo apt-add-repository -y ppa:ansible/ansible; sudo apt-get update; sudo apt-get install -y ansible"
end


config.vm.provision :ansible do |ansible|
ansible.playbook = "requirements.yml"
Expand Down
22 changes: 20 additions & 2 deletions roles/st2/tasks/config_auth.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
- name: Install auth pre-reqs
- name: Install auth pre-reqs (Debian)
become: yes
apt:
name: "{{ item }}"
state: present
with_items:
- python-passlib
- apache2-utils
when: ansible_os_family == 'Debian'

- name: Install epel-release repo (RedHat)
become: yes
yum:
name: epel-release
state: present
when: ansible_os_family == 'RedHat'

- name: Install auth pre-reqs (RedHat)
become: yes
yum:
name: "{{ item }}"
state: present
with_items:
- python-passlib
- httpd-tools
when: ansible_os_family == 'RedHat'

- name: Create htpasswd file
become: true
Expand All @@ -16,7 +34,7 @@
notify:
- restart st2api/st2stream

- name: Enable autentication
- name: Enable authentication
become: yes
ini_file:
dest: /etc/st2/st2.conf
Expand Down
18 changes: 18 additions & 0 deletions roles/st2/tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Install latest st2 package
become: yes
apt:
name: st2
state: latest
when: st2_version == "stable"
notify:
- restart st2

- name: Install latest st2 package
become: yes
apt:
name: st2={{ st2_version }}-{{ st2_revision }}
state: present
when: st2_version != "stable"
notify:
- restart st2
20 changes: 4 additions & 16 deletions roles/st2/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
---

- name: Install latest st2 package
become: yes
apt:
name: st2
state: latest
when: st2_version == "stable"
notify:
- restart st2
- include: debian.yml
when: ansible_os_family == 'Debian'

- name: Install latest st2 package
become: yes
apt:
name: st2={{ st2_version }}-{{ st2_revision }}
state: present
when: st2_version != "stable"
notify:
- restart st2
- include: redhat.yml
when: ansible_os_family == 'RedHat'

- include: user.yml

Expand Down
18 changes: 18 additions & 0 deletions roles/st2/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Install latest st2 package
become: yes
yum:
name: st2
state: latest
when: st2_version == "stable"
notify:
- restart st2

- name: Install latest st2 package
become: yes
yum:
name: st2={{ st2_version }}-{{ st2_revision }}
state: present
when: st2_version != "stable"
notify:
- restart st2
23 changes: 23 additions & 0 deletions roles/st2repos/tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Install prereqs (Debian)
become: yes
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- debian-archive-keyring
- apt-transport-https

- name: Add keys to keyring
become: yes
apt_key:
url: https://packagecloud.io/StackStorm/{{ st2_pkg_repo }}/gpgkey
state: present

- name: Add StackStorm repos
become: yes
apt_repository:
repo: 'deb https://packagecloud.io/StackStorm/{{ st2_pkg_repo }}/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} main'
state: present
update_cache: yes
25 changes: 4 additions & 21 deletions roles/st2repos/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
---
# tasks file for st2repos

- name: Install prereqs
become: yes
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- debian-archive-keyring
- apt-transport-https

- name: Add keys to keyring
become: yes
apt_key:
url: https://packagecloud.io/StackStorm/{{ st2_pkg_repo }}/gpgkey
state: present
- include: debian.yml
when: ansible_os_family == 'Debian'

- name: Add StackStorm repos
become: yes
apt_repository:
repo: 'deb https://packagecloud.io/StackStorm/{{ st2_pkg_repo }}/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} main'
state: present
update_cache: yes
- include: redhat.yml
when: ansible_os_family == 'RedHat'
21 changes: 21 additions & 0 deletions roles/st2repos/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Tasks based on https://packagecloud.io/install/repositories/StackStorm/stable/script.rpm.sh

- name: Retrieve configuration
get_url:
url: "https://packagecloud.io/install/repositories/StackStorm/stable/config_file.repo?os={{ ansible_distribution }}&dist={{ ansible_distribution_version }}&source=script"
dest: /tmp/yum_config
mode: 0440

- name: Load config file
shell: cat /tmp/yum_config
register: yum_config

- name: Update YUM configuration
become: yes
blockinfile:
dest: /etc/yum.repos.d/StackStorm_stable.repo
create: yes
marker: "### ANSIBLE MANAGED BLOCK ###"
content: |
{{ yum_config.stdout }}

0 comments on commit 36329a6

Please sign in to comment.