ansible-role-ara/tasks/main.yml

127 lines
3.6 KiB
YAML

---
# 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
become: true
package:
name: "{{ item }}"
state: "present"
with_items: "{{ required_packages }}"
- name: Install pip
become: true
easy_install:
name: pip
state: present
- name: Install ARA with pip
become: true
pip:
name: ara
state: present
- name: Create user for ARA
become: true
user:
name: ara
comment: User for ARA Records Ansible
shell: /sbin/nologin
home: /var/lib/ara
- name: Create ARA directories
become: true
file:
path: "{{ item }}"
state: directory
owner: ara
group: ara
mode: 0750
with_items:
- /var/log/ara
- /var/lib/ara
- /etc/ara
- name: Setup ARA logrotate
become: true
template:
src: logrotate.conf.j2
dest: /etc/logrotate.d/ara
- name: Include web server configuration
include_tasks: "{{ ara.deployment.server }}/{{ ara.deployment.type }}.yml"
- name: Create the ARA configuration file
become: true
ini_file:
path: /etc/ara/ara.cfg
section: ara
option: "{{ item.key }}"
value: "{{ item.value }}"
create: yes
owner: ara
group: ara
mode: 0640
with_dict: "{{ ara.config }}"
notify:
- restart ara
- restart nginx
- name: Get ARA installed location
shell: python -c "import os,ara; print(os.path.dirname(ara.__file__))"
register: ara_location
changed_when: false
- name: Enable ARA Ansible configuration
become: true
ini_file:
dest: /etc/ara/ara.cfg
section: defaults
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: local_tmp, value: /var/lib/ara/.ansible/ }
- { option: callback_plugins, value: "{{ ara_location.stdout }}/plugins/callbacks" }
- { option: action_plugins, value: "{{ ara_location.stdout }}/plugins/actions" }
- name: Provide web application URL
vars:
msg: >-
ARA was installed succesfully !
The web application should now be reachable at http://{{ ara.config.host_proxy | default(ara.config.host) }}:{{ ara.config.port_proxy | default(ara.config.port) }} !
debug:
msg: "{{ msg.split('\n') }}"
- name: Provide instructions
vars:
msg: >-
To customize the host and port on which the web application is served, supply an 'ara_override' dictionary variables with new host and port keys.
A configuration file was set up automatically in /etc/ara/ara.cfg.
The ARA service is already using this configuration file but you'll need to make sure Ansible is using it so that Ansible knows where ARA is located.
This can be done by exporting the ANSIBLE_CONFIG environment variable, like so:
$ export ANSIBLE_CONFIG=/etc/ara/ara.cfg
$ ansible-playbook playbook.yml
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') }}"