Role cleanup/update for ocata

- Use dictionary for service group mappings, bringing the
  role into line with the method used in other roles;

- Use systemd module instead of shell on the services
  restart handlers;

- Use ansible package module to install distro packages;

- Added variables for CentOS. The role should now support
  CentOS;

- Removed extras folder.

Change-Id: I5c8430804aacceca01c5821ca2528514033d15f4
(cherry picked from commit 95e4f4877b)
This commit is contained in:
Flávio Ramalho 2017-02-13 12:33:06 -03:00 committed by Jesse Pretorius (odyssey4me)
parent e051fe7493
commit a7681b96b8
20 changed files with 93 additions and 238 deletions

View File

@ -75,8 +75,6 @@ sahara_galera_user: sahara
sahara_role_name: admin
sahara_api_bind_address: 0.0.0.0
sahara_api_service_port: 8386
sahara_api_program_name: sahara-api
sahara_engine_program_name: sahara-engine
## Service Type and Data
sahara_service_region: RegionOne
@ -152,7 +150,7 @@ sahara_policy_dirs: policy.d
sahara_service_in_ldap: False
# Sahara packages that must be installed before anything else
sahara_required_pip_packages:
sahara_requires_pip_packages:
- virtualenv
- virtualenv-tools
- python-keystoneclient # Keystoneclient needed to OSA keystone lib
@ -170,9 +168,13 @@ sahara_pip_packages:
- warlock
## Service Names
sahara_service_names:
- "sahara-api"
- "sahara-engine"
sahara_services:
sahara-api:
group: sahara_api
service_name: sahara-api
sahara-engine:
group: sahara_engine
service_name: sahara-engine
# This variable is used by the repo_build process to determine
# which host group to check for members of before building the

View File

@ -1,38 +0,0 @@
---
# 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.
component_skel:
sahara_api:
belongs_to:
- sahara_all
sahara_engine:
belongs_to:
- sahara_all
container_skel:
sahara_container:
belongs_to:
- sahara-infra_containers
contains:
- sahara_api
- sahara_engine
properties:
service_name: sahara
physical_skel:
sahara-infra_containers:
belongs_to:
- all_containers
sahara-infra_hosts:
belongs_to:
- hosts

View File

@ -1,20 +0,0 @@
---
# 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.
sahara_service_region: "{{ service_region }}"
sahara_service_in_ldap: "{{ service_ldap_backend_enabled }}"
sahara_galera_address: "{{ galera_address }}"
# If there are any Ceilometer hosts in the environment, then enable its usage
sahara_ceilometer_enabled: "{{ (groups['ceilometer_all'] is defined) and (groups['ceilometer_all'] | length > 0) }}"

View File

@ -1,10 +0,0 @@
haproxy_service_configs:
- service:
haproxy_service_name: sahara_api
haproxy_backend_nodes: "{{ groups['sahara_api'] | default([]) }}"
haproxy_ssl: "{{ haproxy_ssl }}"
haproxy_balance_alg: source
haproxy_port: 8386
haproxy_balance_type: http
haproxy_backend_options:
- "httpchk /healthcheck"

View File

@ -1,64 +0,0 @@
---
# 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: Install sahara server
hosts: sahara_all
gather_facts: "{{ gather_facts | default(True) }}"
max_fail_percentage: 20
user: root
pre_tasks:
- include: common-tasks/rabbitmq-servers-sort.yml
vars:
sort_group_name: "sahara_all"
- include: common-tasks/os-lxc-container-setup.yml
- include: common-tasks/rabbitmq-vhost-user.yml
vars:
user: "{{ sahara_rabbitmq_userid }}"
password: "{{ sahara_rabbitmq_password }}"
vhost: "{{ sahara_rabbitmq_vhost }}"
when:
- inventory_hostname == groups['sahara_all'][0]
- groups['rabbitmq_all'] | length > 0
- include: common-tasks/os-log-dir-setup.yml
vars:
log_dirs:
- src: "/openstack/log/{{ inventory_hostname }}-sahara"
dest: "/var/log/sahara"
- include: common-tasks/mysql-db-user.yml
vars:
user_name: "{{ sahara_galera_user }}"
password: "{{ sahara_container_mysql_password }}"
login_host: "{{ sahara_galera_address }}"
db_name: "{{ sahara_galera_database }}"
when: inventory_hostname == groups['sahara_all'][0]
- include: common-tasks/package-cache-proxy.yml
roles:
- role: "os_sahara"
sahara_venv_tag: "{{ openstack_release }}"
sahara_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/sahara-{{ openstack_release }}-{{ ansible_architecture | lower }}.tgz"
tags:
- "os-sahara"
- { role: "openstack_openrc", tags: [ "openstack-openrc" ] }
- role: "rsyslog_client"
rsyslog_client_log_rotate_file: sahara_log_rotate
rsyslog_client_log_dir: "/var/log/sahara"
rsyslog_client_config_name: "99-sahara-rsyslog-client.conf"
tags:
- "sahara-rsyslog-client"
- "rsyslog-client"
- role: "system_crontab_coordination"
tags:
- "system-crontab-coordination"
vars:
is_metal: "{{ properties.is_metal|default(false) }}"
pip_lock_to_internal_repo: "{{ (pip_links | length) >= 1 }}"

View File

@ -1,5 +0,0 @@
## Sahara service
sahara_git_repo: https://git.openstack.org/openstack/sahara
sahara_git_install_branch: master
sahara_git_dest: "/opt/sahara_{{ sahara_git_install_branch | replace('/', '_') }}"
sahara_git_project_group: sahara_all

View File

@ -1,3 +0,0 @@
sahara_container_mysql_password:
sahara_rabbitmq_password:
sahara_service_password:

View File

@ -11,18 +11,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Restart sahara api
service:
name: "sahara-api"
state: "restarted"
- name: Restart sahara engine
service:
name: "sahara-engine"
state: "restarted"
- name: Restart sahara services
service:
name: "{{ item }}"
systemd:
name: "{{ item.value.service_name }}"
state: "restarted"
with_items: "{{ sahara_service_names }}"
daemon_reload: yes
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]

View File

@ -4,7 +4,7 @@ galaxy_info:
description: Installation and setup of sahara
company: LSD/UFCG
license: Apache2
min_ansible_version: 2.0
min_ansible_version: 2.1
platforms:
- name: Ubuntu
versions:

View File

@ -15,7 +15,10 @@
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
- "{{ ansible_os_family | lower }}.yml"
tags:
- always
@ -32,7 +35,7 @@
tags:
- sahara-config
- include: sahara_init.yml
- include: sahara_init_common.yml
tags:
- sahara-config

View File

@ -1,28 +0,0 @@
---
# 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.
- include: sahara_init_common.yml
vars:
program_name: "{{ sahara_api_program_name }}"
service_name: "{{ sahara_service_name }}"
system_user: "{{ sahara_system_user_name }}"
system_group: "{{ sahara_system_group_name }}"
service_home: "{{ sahara_system_user_home }}"
- include: sahara_init_common.yml
vars:
program_name: "{{ sahara_engine_program_name }}"
service_name: "{{ sahara_service_name }}"
system_user: "{{ sahara_system_user_name }}"
system_group: "{{ sahara_system_group_name }}"
service_home: "{{ sahara_system_user_home }}"

View File

@ -12,13 +12,14 @@
# limitations under the License.
- include: sahara_init_systemd.yml
static: no
when:
- ansible_service_mgr == 'systemd'
- name: Load service
service:
name: "{{ program_name }}"
enabled: "yes"
name: "{{ item.value.service_name }}"
enabled: "yes"
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
notify:
- Restart sahara services

View File

@ -1,4 +1,3 @@
---
# Copyright 2016, Rackspace US, Inc.
#
@ -16,39 +15,52 @@
- name: Create TEMP run dir
file:
path: "/var/run/{{ program_name }}"
path: "/var/run/{{ item.value.service_name }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
owner: "{{ sahara_system_user_name }}"
group: "{{ sahara_system_group_name }}"
mode: "02755"
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
- name: Create TEMP lock dir
file:
path: "/var/lock/{{ program_name }}"
path: "/var/lock/{{ item.value.service_name }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
owner: "{{ sahara_system_user_name }}"
group: "{{ sahara_system_group_name }}"
mode: "02755"
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
- name: Create tempfile.d entry
# TODO:
# Remove this in Pike as it only needed to handle upgrades
# from Newton->Newton and Newton->Ocata
- name: Cleanup old tmpfiles.d entry
file:
path: "/etc/tmpfiles.d/{{ item.value.service_name }}.conf"
state: absent
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
- name: Create tmpfiles.d entry
template:
src: "sahara-systemd-tempfiles.j2"
dest: "/etc/tmpfiles.d/sahara.conf"
src: "sahara-systemd-tmpfiles.j2"
dest: "/etc/tmpfiles.d/{{ item.value.service_name }}.conf"
mode: "0644"
owner: "root"
group: "root"
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
- name: Place the systemd init script
template:
src: "sahara-systemd-init.j2"
dest: "/etc/systemd/system/{{ program_name }}.service"
dest: "/etc/systemd/system/{{ item.value.service_name }}.service"
mode: "0644"
owner: "root"
group: "root"
register: systemd_init
- name: Reload the systemd daemon
command: "systemctl daemon-reload"
when: systemd_init | changed
with_dict: "{{ sahara_services }}"
when: inventory_hostname in groups[item.value.group]
notify:
- Restart sahara services

View File

@ -11,9 +11,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: sahara_install_apt.yml
static: no
when: ansible_pkg_mgr == 'apt'
- name: Ensure apt cache is up to date
apt:
update_cache: yes
cache_valid_time: "{{ cache_timeout }}"
when:
- ansible_pkg_mgr == 'apt'
- name: Install distro packages
package:
name: "{{ item }}"
state: "{{ sahara_package_state }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ sahara_distro_packages }}"
- name: Create developer mode constraint file
copy:
@ -25,10 +38,10 @@
when:
- sahara_developer_mode | bool
- name: Install required pip packages
- name: Install requires pip packages
pip:
name: "{{ sahara_required_pip_packages }}"
state: present
name: "{{ sahara_requires_pip_packages }}"
state: "{{ sahara_pip_package_state }}"
extra_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}

View File

@ -40,8 +40,7 @@
config_overrides: "{{ sahara_policy_overrides }}"
config_type: "json"
notify:
- Restart sahara api
- Restart sahara engine
- Restart sahara services
- name: Drop rootwrap filter(s)
copy:
@ -52,5 +51,4 @@
with_fileglob:
- rootwrap.d/*
notify:
- Restart sahara api
- Restart sahara engine
- Restart sahara services

View File

@ -7,13 +7,13 @@ After=network.target
[Service]
Type=simple
User={{ system_user }}
Group={{ system_group }}
User={{ sahara_system_user_name }}
Group={{ sahara_system_group_name }}
{% if program_override is defined %}
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ program_name }}.log
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ item.value.service_name }}.log
{% else %}
ExecStart={{ sahara_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ program_name }}.log
ExecStart={{ sahara_bin }}/{{ item.value.service_name }} {{ program_config_options|default('') }} --log-file=/var/log/sahara/{{ item.value.service_name }}.log
{% endif %}
# Give a reasonable amount of time for the server to start up/shut down

View File

@ -1,4 +0,0 @@
# {{ ansible_managed }}
D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }}

View File

@ -0,0 +1,4 @@
# {{ ansible_managed }}
D /var/lock/{{ item.value.service_name }} 2755 {{ sahara_system_user_name }} {{ sahara_system_group_name }}
D /var/run/{{ item.value.service_name }} 2755 {{ sahara_system_user_name }} {{ sahara_system_group_name }}

View File

@ -45,5 +45,12 @@ nova_api_os_compute
[keystone_all]
openstack1
[sahara_all]
[sahara_api]
sahara1
[sahara_engine]
sahara1
[sahara_all:children]
sahara_api
sahara_engine

View File

@ -10,14 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install apt packages
apt:
pkg: "{{ item }}"
state: "{{ sahara_package_state }}"
update_cache: yes
cache_valid_time: "{{ cache_timeout }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ sahara_distro_packages }}"
sahara_distro_packages:
- cronie
- cronie-anacron
- rpcbind
- git
- which