Clean up ansible-role-ara
- Add copyright headers (sorry) - Re-order tasks - Add missing wsgi required packages - Use template instead of file for default ansible.cfg - Use handler to restart apache if need be - Use command instead of shell unless necessary - Fix mistakes in systemd service - Fix mistakes in debian family required packages - Add friendly instructions at the end of the setup - Improve README Change-Id: I84d59facfdc593bc82ac1d1436a49f85c2d1637b
This commit is contained in:
parent
cea2a3eea8
commit
8863c8887c
41
README.md
41
README.md
|
@ -1,41 +0,0 @@
|
|||
Ansible Role: ara
|
||||
=========
|
||||
Ansible role to install, configure ara on RHEL, Fedora, Centos, Debian and Ubuntu
|
||||
|
||||
systemd is configured to start ara on boot, failures
|
||||
|
||||
By default embedded server is used to host ara on localhost, if you prefer mod_wsgi then you can set the mod_wsgi variable in defaults/main.yml
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- role: chaitanyaenr.ara
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Apache-2.0
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Naga Ravi Chaitanya Elluri - nelluri@redhat.com
|
||||
|
||||
Copyright
|
||||
------------------
|
||||
|
||||
Copyright 2016 Red Hat, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,67 @@
|
|||
ansible-role-ara
|
||||
================
|
||||
|
||||
Ansible role to install and configure ARA on Fedora, RHEL, Fedora as well as
|
||||
Debian and Ubuntu.
|
||||
|
||||
ARA_ (Ansible Run Analysis) records Ansible_ Playbook runs seamlessly to make
|
||||
them easier to visualize, understand and troubleshoot. It integrates with
|
||||
Ansible wherever you run it.
|
||||
|
||||
.. _ARA: https://github.com/openstack/ara
|
||||
.. _Ansible: https://www.ansible.com/
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
Please note that this role is still a work in progress and in development.
|
||||
|
||||
What the role does
|
||||
------------------
|
||||
|
||||
By default, the role allows for the installation of ARA and the `configuration
|
||||
of Ansible`_ to leverage the ARA callback.
|
||||
It also allows for the configuration of the `different parameters`_ to customize
|
||||
the behavior of ARA.
|
||||
|
||||
It provides installation and configuration of the web application under the
|
||||
`embedded webserver or apache+mod_wsgi`_.
|
||||
|
||||
.. _configuration of Ansible: http://ara.readthedocs.io/en/latest/configuration.html#ansible
|
||||
.. _different parameters: http://ara.readthedocs.io/en/latest/configuration.html#ara
|
||||
.. _embedded webserver or apache+mod_wsgi: http://ara.readthedocs.io/en/latest/webserver.html
|
||||
|
||||
Using the role
|
||||
--------------
|
||||
::
|
||||
|
||||
mkdir roles
|
||||
git clone https://git.openstack.org/openstack/ansible-role-ara roles/ara
|
||||
cat << EOF > playbook.yml
|
||||
- hosts: all
|
||||
roles:
|
||||
- ara
|
||||
EOF
|
||||
ansible-playbook playbook.yml
|
||||
|
||||
Contributors
|
||||
============
|
||||
See contributors on GitHub_.
|
||||
|
||||
.. _GitHub: https://github.com/openstack/ansible-role-ara/graphs/contributors
|
||||
|
||||
Copyright
|
||||
=========
|
||||
Copyright 2017 Red Hat, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,10 +1,33 @@
|
|||
---
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
ara_host: localhost
|
||||
ara_port: 9191
|
||||
default_embedded_config_path: ~/ansible.cfg
|
||||
default_wsgi_config_path: /var/www/ara/ansible.cfg
|
||||
# set config_path
|
||||
#config_path:
|
||||
# Default paths where an ansible.cfg file is expected
|
||||
default_embedded_config_path: "{{ lookup('env','HOME') }}"
|
||||
default_wsgi_config_path: "/var/www/ara"
|
||||
|
||||
# Override the path where an ansible.cfg file will be used
|
||||
# config_path:
|
||||
|
||||
# Host to listen on for embedded server or apache
|
||||
ara_host: "localhost"
|
||||
|
||||
# Port to listen on for embedded server or apache
|
||||
ara_port: "9191"
|
||||
|
||||
# Deploy with apache and mod_wsgi
|
||||
mod_wsgi: false
|
||||
|
||||
# Deploy with persistent embedded_webserver
|
||||
embedded_server: true
|
||||
|
|
|
@ -1,2 +1,23 @@
|
|||
---
|
||||
# handlers file for ara
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Restart apache
|
||||
service:
|
||||
name: "{{ apache_service }}"
|
||||
state: "restarted"
|
||||
enabled: yes
|
||||
|
||||
- name: Reload systemctl
|
||||
command: systemctl daemon-reload
|
||||
|
|
|
@ -1,20 +1,37 @@
|
|||
---
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
galaxy_info:
|
||||
author: Naga Ravi Chaitanya Elluri
|
||||
description: Installs ara
|
||||
company: redhat
|
||||
description: Installs and configure ARA
|
||||
company: Red Hat
|
||||
license: Apache2
|
||||
min_ansible_version: 2.1
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- installer
|
||||
- application
|
||||
|
|
225
tasks/main.yml
225
tasks/main.yml
|
@ -1,112 +1,177 @@
|
|||
---
|
||||
- name: include OS family/distribution specific variables
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Include OS family/distribution specific variables
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: install required dependencies
|
||||
- name: Install required dependencies
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: "present"
|
||||
with_items: "{{ required_packages }}"
|
||||
|
||||
- name: install pip
|
||||
- name: Install pip
|
||||
easy_install:
|
||||
name: pip
|
||||
state: present
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
- name: install ara
|
||||
- name: Install ARA with pip
|
||||
pip:
|
||||
name: ara
|
||||
state: present
|
||||
|
||||
- name: set ara_config_path when using mod_wsgi
|
||||
set_fact:
|
||||
ara_config_path: "{{ config_path | default(default_wsgi_config_path) }}"
|
||||
- block:
|
||||
- name: Install required dependencies for mod_wsgi
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: "present"
|
||||
with_items: "{{ required_wsgi_packages }}"
|
||||
|
||||
- name: Get status of selinux
|
||||
command: getenforce
|
||||
register: selinux_status
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Set selinux boolean to allow Apache to manage the files
|
||||
seboolean:
|
||||
name: httpd_unified
|
||||
state: yes
|
||||
when:
|
||||
- ansible_os_family == "RedHat"
|
||||
- selinux_status.stdout == "Enforcing"
|
||||
|
||||
- name: Set ara_config_path when using mod_wsgi
|
||||
set_fact:
|
||||
ara_config_path: "{{ config_path | default(default_wsgi_config_path) }}"
|
||||
|
||||
- name: Ensure configuration directory for Ansible and ARA exists
|
||||
file:
|
||||
path: "{{ ara_config_path }}"
|
||||
owner: "{{ apache_user }}"
|
||||
group: "{{ apache_group }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
|
||||
- name: Create default configuration file if one does not exist
|
||||
template:
|
||||
src: templates/ansible.cfg.j2
|
||||
dest: "{{ ara_config_path }}/ansible.cfg"
|
||||
force: no
|
||||
|
||||
- name: Copy ARA’s WSGI script to the config path
|
||||
shell: cp -p $(which ara-wsgi) {{ ara_config_path }}
|
||||
|
||||
- name: Set up Apache configuration
|
||||
template:
|
||||
src: templates/ara.conf.j2
|
||||
dest: "{{ apache_config_path }}/ara.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- Restart Apache
|
||||
|
||||
- name: Ensure the configuration is enabled
|
||||
command: a2ensite ara
|
||||
when: ansible_os_family == "Debian"
|
||||
notify:
|
||||
- Restart Apache
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Ensure apache is enabled
|
||||
service:
|
||||
name: "{{ apache_service }}"
|
||||
enabled: yes
|
||||
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) }}"
|
||||
- block:
|
||||
- name: Set ara_config_path when using embedded_server
|
||||
set_fact:
|
||||
ara_config_path: "{{ config_path | default(default_embedded_config_path) }}"
|
||||
|
||||
- name: Ensure configuration directory for ARA exists
|
||||
file:
|
||||
path: "{{ ara_config_path }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
|
||||
- name: Create default configuration file if one does not exist
|
||||
template:
|
||||
src: templates/ansible.cfg.j2
|
||||
dest: "{{ ara_config_path }}/ansible.cfg"
|
||||
force: no
|
||||
|
||||
- name: Get the location of ara-manage
|
||||
command: which ara-manage
|
||||
register: ara_manage
|
||||
changed_when: false
|
||||
|
||||
- name: Copy systemd service template
|
||||
template:
|
||||
src: templates/ara-service.conf.j2
|
||||
dest: /etc/systemd/system/ara.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- Reload systemctl
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Start and enable the embedded server service
|
||||
service:
|
||||
name: ara
|
||||
state: started
|
||||
enabled: yes
|
||||
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
|
||||
- name: Get ARA's installed location
|
||||
shell: python -c "import os,ara; print(os.path.dirname(ara.__file__))"
|
||||
register: ara_location
|
||||
changed_when: false
|
||||
|
||||
- name: enable ara callback plugin
|
||||
- name: Enable ARA's callback plugin
|
||||
ini_file:
|
||||
dest: "{{ ara_config_path }}"
|
||||
dest: "{{ ara_config_path }}/ansible.cfg"
|
||||
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: Provide web application URL
|
||||
vars:
|
||||
msg: >-
|
||||
ARA was installed succesfully !
|
||||
The web application should now be reachable at http://{{ ara_host }}:{{ ara_port }} !
|
||||
To customize the host and port on which the application listens to, override the defaults for the ara_host and ara_port variables.
|
||||
Data from recorded playbooks will be available in the interface as soon as you run your first ansible-playbook command.
|
||||
debug:
|
||||
msg: "{{ msg.split('\n') }}"
|
||||
|
||||
- name: copy ARA’s WSGI script to the web directory
|
||||
shell: cp -p $(which ara-wsgi) /var/www/ara/
|
||||
- name: Provide instructions
|
||||
vars:
|
||||
msg: >-
|
||||
We've set up an ansible.cfg file for you inside {{ ara_config_path }}.
|
||||
Make sure to have Ansible and ARA use it for everything to work properly.
|
||||
|
||||
- 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
|
||||
This can be done from using Ansible or the ARA CLI commands directly from that directory or by using the ANSIBLE_CONFIG environment variable, like so:
|
||||
export ANSIBLE_CONFIG={{ ara_config_path }}/ansible.cfg
|
||||
debug:
|
||||
msg: "{{ msg.split('\n') }}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[defaults]
|
||||
# This directory is required to store temporary files for Ansible and ARA
|
||||
local_tmp = /var/www/ara/.ansible/tmp
|
||||
local_tmp = {{ ara_config_path }}/.ansible/tmp
|
||||
|
||||
[ara]
|
||||
# This will default the database and logs location to be inside that directory.
|
||||
dir = /var/www/ara/.ara
|
||||
dir = {{ ara_config_path }}/.ara
|
|
@ -1,5 +1,5 @@
|
|||
[unit]
|
||||
Description=ara
|
||||
[Unit]
|
||||
Description=ARA
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
|
@ -8,7 +8,7 @@ TimeoutStartSec=0
|
|||
Restart=on-failure
|
||||
RestartSec=10
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/ara-manage runserver -h {{ ara_host }} -p {{ ara_port }}
|
||||
ExecStart={{ ara_manage.stdout }} runserver -h {{ ara_host }} -p {{ ara_port }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<VirtualHost *:80>
|
||||
<VirtualHost *:{{ ara_port }}>
|
||||
ServerName {{ ara_host }}
|
||||
|
||||
ErrorLog {{ apache_log_path }}/ara-error.log
|
||||
|
|
|
@ -1,16 +1,31 @@
|
|||
---
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
required_packages:
|
||||
- gcc
|
||||
- python-dev
|
||||
- libffi-dev
|
||||
- libssl-dev
|
||||
- python-setuptools
|
||||
- libxml2-devel
|
||||
- libxslt-devel
|
||||
- libselinux-python
|
||||
- libxml2-dev
|
||||
- libxslt-dev
|
||||
|
||||
required_wsgi_packages:
|
||||
- apache2
|
||||
- libapache2-mod-wsgi
|
||||
|
||||
apache_service: apache2
|
||||
apache_user: www-data
|
||||
apache_group: www-data
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
---
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
required_packages:
|
||||
- gcc
|
||||
- python-devel
|
||||
|
@ -9,9 +23,11 @@ required_packages:
|
|||
- libxml2-devel
|
||||
- libxslt-devel
|
||||
- libselinux-python
|
||||
|
||||
required_wsgi_packages:
|
||||
- httpd
|
||||
- mod_wsgi
|
||||
|
||||
apache_service: httpd
|
||||
apache_user: apache
|
||||
apache_group: apache
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
---
|
||||
# vars file for ara
|
Loading…
Reference in New Issue