Merge "Implement Multi-OS support in os_cloudkitty"
This commit is contained in:
@@ -23,6 +23,10 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- trusty
|
||||
- xenial
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
categories:
|
||||
- cloud
|
||||
- python
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- include: cloudkitty_upstart_common_init.yml
|
||||
- include: cloudkitty_init_common.yml
|
||||
vars:
|
||||
program_name: "{{ cloudkitty_service_program_name }}"
|
||||
service_name: "{{ cloudkitty_service_name }}"
|
||||
@@ -22,7 +22,8 @@
|
||||
service_home: "{{ cloudkitty_system_home_folder }}"
|
||||
when: >
|
||||
inventory_hostname in groups['cloudkitty_api']
|
||||
- include: cloudkitty_upstart_common_init.yml
|
||||
|
||||
- include: cloudkitty_init_common.yml
|
||||
vars:
|
||||
program_name: "{{ cloudkitty_service_processor_program_name }}"
|
||||
service_name: "{{ cloudkitty_service_name }}"
|
||||
@@ -31,4 +32,3 @@
|
||||
service_home: "{{ cloudkitty_system_home_folder }}"
|
||||
when: >
|
||||
inventory_hostname in groups['cloudkitty_api']
|
||||
|
||||
27
tasks/cloudkitty_init_common.yml
Normal file
27
tasks/cloudkitty_init_common.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- include: cloudkitty_init_upstart.yml
|
||||
when: pid1_name == "init"
|
||||
|
||||
- include: cloudkitty_init_systemd.yml
|
||||
when: pid1_name == "systemd"
|
||||
|
||||
- name: Load service
|
||||
service:
|
||||
name: "{{ program_name }}"
|
||||
enabled: "yes"
|
||||
notify:
|
||||
- Restart cloudkitty services
|
||||
53
tasks/cloudkitty_init_systemd.yml
Normal file
53
tasks/cloudkitty_init_systemd.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Create TEMP run dir
|
||||
file:
|
||||
path: "/var/run/{{ program_name }}"
|
||||
state: directory
|
||||
owner: "{{ system_user }}"
|
||||
group: "{{ system_group }}"
|
||||
mode: "02755"
|
||||
|
||||
- name: Create TEMP lock dir
|
||||
file:
|
||||
path: "/var/lock/{{ program_name }}"
|
||||
state: directory
|
||||
owner: "{{ system_user }}"
|
||||
group: "{{ system_group }}"
|
||||
mode: "02755"
|
||||
|
||||
- name: Create tempfile.d entry
|
||||
template:
|
||||
src: "cloudkitty-systemd-tempfiles.j2"
|
||||
dest: "/etc/tmpfiles.d/cloudkitty.conf"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
|
||||
- name: Place the systemd init script
|
||||
template:
|
||||
src: "cloudkitty-systemd-init.j2"
|
||||
dest: "/etc/systemd/system/{{ program_name }}.service"
|
||||
mode: "0644"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
register: systemd_init
|
||||
|
||||
- name: Reload the systemd daemon
|
||||
command: "systemctl daemon-reload"
|
||||
when: systemd_init | changed
|
||||
notify:
|
||||
- Restart cloudkitty services
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2014, Rackspace US, Inc.
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,18 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- include: cloudkitty_install_apt.yml
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
tags:
|
||||
- cloudkitty-install
|
||||
|
||||
- include: cloudkitty_install_yum.yml
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
tags:
|
||||
- cloudkitty-install
|
||||
|
||||
- name: Create developer mode constraint file
|
||||
copy:
|
||||
dest: "/opt/developer-pip-constraints.txt"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2014, Rackspace US, Inc.
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ cloudkitty_apt_packages }}"
|
||||
with_items: "{{ cloudkitty_packages }}"
|
||||
tags:
|
||||
- cloudkitty-install
|
||||
- cloudkitty-apt-packages
|
||||
24
tasks/cloudkitty_install_yum.yml
Normal file
24
tasks/cloudkitty_install_yum.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Install yum packages
|
||||
yum:
|
||||
pkg: "{{ item }}"
|
||||
state: latest
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ cloudkitty_packages }}"
|
||||
@@ -15,14 +15,28 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#- name: Gather variables for each operating system
|
||||
# include_vars: "{{ item }}"
|
||||
# with_first_found:
|
||||
# - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
||||
# - "{{ ansible_distribution | lower }}.yml"
|
||||
# - "{{ ansible_os_family | lower }}.yml"
|
||||
# tags:
|
||||
# - always
|
||||
- name: Gather variables for each operating system
|
||||
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 }}.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Check init system
|
||||
command: cat /proc/1/comm
|
||||
register: _pid1_name
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Set the name of pid1
|
||||
set_fact:
|
||||
pid1_name: "{{ _pid1_name.stdout }}"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- include: cloudkitty_pre_install.yml
|
||||
- include: cloudkitty_install.yml
|
||||
@@ -36,7 +50,7 @@
|
||||
when: >
|
||||
inventory_hostname == groups['cloudkitty_all'][0]
|
||||
|
||||
- include: cloudkitty_upstart_init.yml
|
||||
- include: cloudkitty_init.yml
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
25
templates/cloudkitty-systemd-init.j2
Normal file
25
templates/cloudkitty-systemd-init.j2
Normal file
@@ -0,0 +1,25 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=cloudkitty openstack service
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ system_user }}
|
||||
Group={{ system_group }}
|
||||
|
||||
{% if program_override is defined %}
|
||||
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/cloudkitty/{{ program_name }}.log
|
||||
{% else %}
|
||||
ExecStart={{ cloudkitty_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/cloudkitty/{{ program_name }}.log
|
||||
{% endif %}
|
||||
|
||||
# Give a reasonable amount of time for the server to start up/shut down
|
||||
TimeoutSec=300
|
||||
Restart=on-failure
|
||||
RestartSec=150
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
4
templates/cloudkitty-systemd-tempfiles.j2
Normal file
4
templates/cloudkitty-systemd-tempfiles.j2
Normal file
@@ -0,0 +1,4 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
|
||||
D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
|
||||
20
vars/debian.yml
Normal file
20
vars/debian.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
# Copyright 2016, Walmart Stores, 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.
|
||||
|
||||
## APT Cache options
|
||||
cache_timeout: 600
|
||||
|
||||
cloudkitty_packages:
|
||||
- git
|
||||
17
vars/redhat.yml
Normal file
17
vars/redhat.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
# Copyright 2016, Walmart Stores, 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.
|
||||
|
||||
cloudkitty_packages:
|
||||
- git
|
||||
Reference in New Issue
Block a user