joelbirchler
2020-03-04 b8653c1cbc02baf7daecd41e56979b2003656953
Merge branch '1025' of github.com:RedHatTraining/agnosticd into test
5 files added
102 ■■■■■ changed files
ansible/roles/status-report-install/defaults/main.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/status-report-install/tasks/main.yml 83 ●●●●● patch | view | raw | blame | history
ansible/roles/status-report-install/vars/RedHat.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/status-report/defaults/main.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/status-report/tasks/main.yml 13 ●●●●● patch | view | raw | blame | history
ansible/roles/status-report-install/defaults/main.yml
New file
@@ -0,0 +1,2 @@
---
bastion_dns_name: "bastion.{{ guid }}{{ subdomain_base_suffix }}"
ansible/roles/status-report-install/tasks/main.yml
New file
@@ -0,0 +1,83 @@
---
- name: Create application folder
  file:
    name: "/opt/status/src"
    state: directory
    owner: "{{ ansible_user }}"
- name: Retrieve application source files
  git:
    clone: yes
    force: yes
    dest: "/tmp/status"
    repo: "http://github.com/RedHatTraining/provisioner-api.git"
- name: Copy application files
  copy:
    dest: "/opt/status/src/{{ item }}"
    src: "/tmp/status/{{ item }}"
    owner: "{{ ansible_user }}"
    mode: 0644
    remote_src: true
  with_items:
    - requirements.txt
    - server.py
    - wsgi.py
- name: Install pip
  package:
    name: python36-pip
- name: Upgrade pip
  pip:
    name: pip
    state: latest
    executable: /usr/bin/pip3
- name: Install python virtualenv
  pip:
    name: virtualenv
    state: latest
    executable: /usr/bin/pip3
- name: Allow nginx to access non-standard port
  shell: |
    semanage port -a -t http_port_t -p tcp 30904
    semanage port -m -t http_port_t -p tcp 30904
- name: Stouts.wsgi virtual environment fix
  file:
    src: /usr/local/bin/virtualenv
    dest: /usr/bin/virtualenv
    owner: root
    group: root
    state: link
- name: Install python application as a service
  include_role:
    name: Stouts.wsgi
  vars:
    python_enabled: false
    wsgi_group: nginx
    wsgi_nginx_servernames: "{{ bastion_dns_name }}"
    wsgi_nginx_port: 30904
    wsgi_virtualenv_python: python3
    wsgi_applications:
    - name: status
      server: gunicorn
      module: wsgi
      pip_requirements: requirements.txt
- name: Create runtime folders
  file:
    name: "{{item}}"
    state: directory
    owner: "{{ansible_user}}"
    group: nginx
  with_items:
    - /opt/status/run
    - /opt/status/log
- name: Fix selinux context for nginx access
  shell: |
    semanage fcontext -a -t httpd_sys_rw_content_t "{{item}}(/.*)?"
    restorecon -R -v "{{item}}"
  with_items:
    - /opt/status/run
    - /opt/status/log
- name: Activate application service
  service:
    name: status-wsgi
    state: restarted
    enabled: yes
ansible/roles/status-report-install/vars/RedHat.yml
New file
@@ -0,0 +1,2 @@
---
wsgi_service: systemd
ansible/roles/status-report/defaults/main.yml
New file
@@ -0,0 +1,2 @@
---
report_status: false
ansible/roles/status-report/tasks/main.yml
New file
@@ -0,0 +1,13 @@
---
- name:
  set_fact:
    bastion_dns_name: "bastion.{{ guid }}{{ subdomain_base_suffix }}"
  when: bastion_dns_name is not defined
- name: Report provisioning status
  uri:
    url: "http://{{ bastion_dns_name }}:30904/api/provision/v1/report"
    method: POST
    body: "{{ status_json }}"
    status_code: 200
    body_format: json