ansible-role-ara/tasks/main.yml

113 lines
2.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- name: include OS family/distribution specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- name: install required dependencies
package:
name: "{{ item }}"
state: "present"
with_items: "{{ required_packages }}"
- name: install pip
easy_install:
name: pip
state: present
when: ansible_pkg_mgr == 'yum'
- name: install ara
pip:
name: ara
- name: set ara_config_path when using mod_wsgi
set_fact:
ara_config_path: "{{ config_path | default(default_wsgi_config_path) }}"
when: mod_wsgi | bool
- name: set ara_config_path when using embedded_server
set_fact:
ara_config_path: "{{ config_path | default(default_embedded_config_path) }}"
when: embedded_server | bool
- name: check if ara_config_path exists
stat: path="{{ ara_config_path }}"
register: file_status
- name: create config file if it doesn't exist
copy:
src: files/ansible.cfg
dest: "{{ ara_config_path }}"
- name: get ara install location
shell: python -c "import os,ara; print(os.path.dirname(ara.__file__))"
register: ara_location
- name: enable ara callback plugin
ini_file:
dest: "{{ ara_config_path }}"
section: defaults
option: callback_plugins
value: "{{ ara_location.stdout }}/plugins/callbacks"
- block:
- name: create directory for ansible and ara
file:
path: /var/www/ara
owner: apache
group: apache
state: directory
recurse: yes
- name: copy ARAs WSGI script to the web directory
shell: cp -p $(which ara-wsgi) /var/www/ara/
- name: get status of selinux
shell: getenforce
register: selinux_status
- name: set selinux boolean to allow apache to manage the files
seboolean:
name: httpd_unified
state: yes
when: selinux_status.stdout == "Enforcing" and ansible_os_family == "RedHat"
- name: apache configuration
template:
src: templates/ara.conf.j2
dest: "{{ apache_config_path }}/ara.conf"
owner: root
group: root
mode: 0644
- name: ensure the configuration is enabled
shell: a2ensite ara
when: ansible_os_family == "Ubuntu"
- name: Restart apache
service:
name: "{{ apache_service }}"
state: "restarted"
enabled: yes
when: mod_wsgi | bool
- block:
- name: copy systemd service template
template:
src: templates/ara-service.conf.j2
dest: /etc/systemd/system/ara.service
owner: root
group: root
mode: 0644
- name: daemon reload
shell: systemctl daemon-reload
- name: start and enable service
service:
name: ara
state: started
enabled: yes
when: embedded_server | bool