Merge "Add cloudkitty ansible role"

This commit is contained in:
Jenkins 2016-09-07 15:21:44 +00:00 committed by Gerrit Code Review
commit 5d8878de6d
24 changed files with 447 additions and 0 deletions

View File

@ -120,6 +120,8 @@ ceilometer_api_port: "8777"
congress_api_port: "1789"
cloudkitty_api_port: "8889"
iscsi_port: "3260"
gnocchi_api_port: "8041"
@ -231,6 +233,7 @@ enable_ceph: "no"
enable_ceph_rgw: "no"
enable_cinder: "no"
enable_cinder_backend_lvm: "no"
enable_cloudkitty: "no"
enable_congress: "no"
enable_gnocchi: "no"
enable_heat: "yes"

View File

@ -48,6 +48,9 @@ network
[cinder:children]
control
[cloudkitty:children]
control
[memcached:children]
control
@ -171,6 +174,13 @@ cinder
[cinder-volume:children]
storage
# Cloudkitty
[cloudkitty-api:children]
cloudkitty
[cloudkitty-processor:children]
cloudkitty
# iSCSI
[iscsid:children]
compute

View File

@ -65,6 +65,9 @@ network
[cinder:children]
control
[cloudkitty:children]
control
[memcached:children]
control
@ -188,6 +191,13 @@ cinder
[cinder-volume:children]
storage
# Cloudkitty
[cloudkitty-api:children]
cloudkitty
[cloudkitty-processor:children]
cloudkitty
# iSCSI
[iscsid:children]
compute

View File

@ -0,0 +1,39 @@
---
project_name: "cloudkitty"
####################
# Database
####################
cloudkitty_database_name: "cloudkitty"
cloudkitty_database_user: "cloudkitty"
cloudkitty_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
####################
# Docker
####################
cloudkitty_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-cloudkitty-api"
cloudkitty_api_tag: "{{ openstack_release }}"
cloudkitty_api_image_full: "{{ cloudkitty_api_image }}:{{ cloudkitty_api_tag }}"
cloudkitty_processor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-cloudkitty-processor"
cloudkitty_processor_tag: "{{ openstack_release }}"
cloudkitty_processor_image_full: "{{ cloudkitty_processor_image }}:{{ cloudkitty_processor_tag }}"
####################
# OpenStack
####################
cloudkitty_admin_endpoint: "{{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ cloudkitty_api_port }}"
cloudkitty_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ cloudkitty_api_port }}"
cloudkitty_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn }}:{{ cloudkitty_api_port }}"
cloudkitty_logging_debug: "{{ openstack_logging_debug }}"
cloudkitty_keystone_user: "cloudkitty"
openstack_cloudkitty_auth: "{'auth_url':'{{ openstack_auth.auth_url }}','username':'{{ openstack_auth.username }}','password':'{{ openstack_auth.password }}','project_name':'{{ openstack_auth.project_name }}'}"
####################
# Cloudkitty
####################
cloudkitty_openstack_keystone_default_role: "rating"

View File

@ -0,0 +1,3 @@
---
dependencies:
- { role: common }

View File

@ -0,0 +1,41 @@
---
- name: Creating Cloudkitty database
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_db
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ cloudkitty_database_name }}'"
register: database
changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
(database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['cloudkitty-api'][0] }}"
- name: Reading json from variable
set_fact:
database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
- name: Creating Cloudkitty database user and setting permissions
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_user
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ cloudkitty_database_name }}'
password='{{ cloudkitty_database_password }}'
host='%'
priv='{{ cloudkitty_database_name }}.*:ALL'
append_privs='yes'"
register: database_user_create
changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
(database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['cloudkitty-api'][0] }}"
- include: bootstrap_service.yml
when: database_created

View File

@ -0,0 +1,20 @@
---
- name: Running Cloudkitty bootstrap container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ cloudkitty_api_image_full }}"
labels:
BOOTSTRAP:
name: "bootstrap_cloudkitty"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/cloudkitty-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True
delegate_to: "{{ groups['cloudkitty-api'][0] }}"

View File

@ -0,0 +1,34 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "cloudkitty-api"
- "cloudkitty-processor"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "cloudkitty-api"
- "cloudkitty-processor"
- name: Copying over cloudkitty.conf
merge_configs:
vars:
service_name: "{{ item }}"
sources:
- "{{ role_path }}/templates/cloudkitty.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/database.conf"
- "{{ node_custom_config }}/messaging.conf"
- "{{ node_custom_config }}/cloudkitty.conf"
- "{{ node_custom_config }}/cloudkitty/{{ item }}.conf"
- "{{ node_custom_config }}/cloudkitty/{{ inventory_hostname }}/cloudkitty.conf"
dest: "{{ node_config_directory }}/{{ item }}/cloudkitty.conf"
with_items:
- "cloudkitty-api"
- "cloudkitty-processor"

View File

@ -0,0 +1,14 @@
---
- include: register.yml
when: inventory_hostname in groups['cloudkitty-api']
- include: config.yml
when: inventory_hostname in groups['cloudkitty-api'] or
inventory_hostname in groups['cloudkitty-processor']
- include: bootstrap.yml
when: inventory_hostname in groups['cloudkitty-api']
- include: start.yml
when: inventory_hostname in groups['cloudkitty-api'] or
inventory_hostname in groups['cloudkitty-processor']

View File

@ -0,0 +1,66 @@
---
- name: Ensuring the containers up
kolla_docker:
name: "{{ item.name }}"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: cloudkitty_api, group: cloudkitty-api }
- { name: cloudkitty_processor, group: cloudkitty-processor }
- include: config.yml
- name: Check the configs
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: cloudkitty_api, group: cloudkitty-api }
- { name: cloudkitty_processor, group: cloudkitty-processor }
- name: Containers config strategy
kolla_docker:
name: "{{ item.name }}"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: cloudkitty_api, group: cloudkitty-api }
- { name: cloudkitty_processor, group: cloudkitty-processor }
- name: Remove the containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "remove_container"
register: remove_containers
when:
- inventory_hostname in groups[item[0]['group']]
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[2]['rc'] == 1
with_together:
- [{ name: cloudkitty_api, group: cloudkitty-api },
{ name: cloudkitty_processor, group: cloudkitty-processor }]
- container_envs.results
- check_results.results
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: cloudkitty_api, group: cloudkitty-api },
{ name: cloudkitty_processor, group: cloudkitty-processor }]
- container_envs.results
- check_results.results

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,14 @@
---
- name: Pulling cloudkitty-api image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ cloudkitty_api_image_full }}"
when: inventory_hostname in groups['cloudkitty-api']
- name: Pulling cloudkitty-processor image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ cloudkitty_processor_image_full }}"
when: inventory_hostname in groups['cloudkitty-processor']

View File

@ -0,0 +1,5 @@
---
- include: do_reconfigure.yml
serial: "30%"
when: inventory_hostname in groups['cloudkitty-api']
or inventory_hostname in groups['cloudkitty-processor']

View File

@ -0,0 +1,53 @@
---
- name: Creating the Cloudkitty service and endpoint
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m kolla_keystone_service
-a "service_name=cloudkitty
service_type=rating
description='OpenStack Rating'
endpoint_region={{ openstack_region_name }}
url='{{ item.url }}'
interface='{{ item.interface }}'
region_name={{ openstack_region_name }}
auth={{ '{{ openstack_cloudkitty_auth }}' }}"
-e "{'openstack_cloudkitty_auth':{{ openstack_cloudkitty_auth }}}"
register: cloudkitty_endpoint
changed_when: "{{ cloudkitty_endpoint.stdout.find('localhost | SUCCESS => ') != -1 and (cloudkitty_endpoint.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
until: cloudkitty_endpoint.stdout.split()[2] == 'SUCCESS'
retries: 10
delay: 5
run_once: True
with_items:
- {'interface': 'admin', 'url': '{{ cloudkitty_admin_endpoint }}'}
- {'interface': 'internal', 'url': '{{ cloudkitty_internal_endpoint }}'}
- {'interface': 'public', 'url': '{{ cloudkitty_public_endpoint }}'}
- name: Creating the Cloudkitty project, user, and role
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m kolla_keystone_user
-a "project=service
user=cloudkitty
password={{ cloudkitty_keystone_password }}
role=admin
region_name={{ openstack_region_name }}
auth={{ '{{ openstack_cloudkitty_auth }}' }}"
-e "{'openstack_cloudkitty_auth':{{ openstack_cloudkitty_auth }}}"
register: cloudkitty_user
changed_when: "{{ cloudkitty_user.stdout.find('localhost | SUCCESS => ') != -1 and (cloudkitty_user.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
until: cloudkitty_user.stdout.split()[2] == 'SUCCESS'
retries: 10
delay: 5
run_once: True
- name: Creating the rating role
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m kolla_keystone_role
-a "role={{ cloudkitty_openstack_keystone_default_role }}
auth={{ '{{ openstack_cloudkitty_auth }}' }}"
-e "{'openstack_cloudkitty_auth':{{ openstack_cloudkitty_auth }}}"
register: cloudkitty_role
changed_when: "{{ cloudkitty_role.stdout.find('localhost | SUCCESS => ') != -1 and (cloudkitty_role.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
until: cloudkitty_role.stdout.split()[2] == 'SUCCESS'
retries: 10
delay: 5
run_once: True

View File

@ -0,0 +1,24 @@
---
- name: Starting cloudkitty-processor container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ cloudkitty_processor_image_full }}"
name: "cloudkitty_processor"
volumes:
- "{{ node_config_directory }}/cloudkitty-processor/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['cloudkitty-processor']
- name: Starting cloudkitty-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ cloudkitty_api_image_full }}"
name: "cloudkitty_api"
volumes:
- "{{ node_config_directory }}/cloudkitty-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['cloudkitty-api']

View File

@ -0,0 +1,7 @@
---
- include: config.yml
- include: bootstrap_service.yml
- include: start.yml
serial: "30%"

View File

@ -0,0 +1,11 @@
{
"command": "cloudkitty-api --config-file /etc/cloudkitty/cloudkitty.conf",
"config_files": [
{
"source": "{{ container_config_directory }}/cloudkitty.conf",
"dest": "/etc/cloudkitty/cloudkitty.conf",
"owner": "cloudkitty",
"perm": "0600"
}
]
}

View File

@ -0,0 +1,11 @@
{
"command": "cloudkitty-processor --config-file /etc/cloudkitty/cloudkitty.conf",
"config_files": [
{
"source": "{{ container_config_directory }}/cloudkitty.conf",
"dest": "/etc/cloudkitty/cloudkitty.conf",
"owner": "cloudkitty",
"perm": "0600"
}
]
}

View File

@ -0,0 +1,46 @@
[DEFAULT]
debug = {{ cloudkitty_logging_debug }}
log_dir = /var/log/kolla/cloudkitty
transport_url = rabbit://{% for host in groups['rabbitmq'] %}{{ rabbitmq_user }}:{{ rabbitmq_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ rabbitmq_port }}{% if not loop.last %},{% endif %}{% endfor %}
[database]
connection = mysql+pymysql://{{ cloudkitty_database_user }}:{{ cloudkitty_database_password }}@{{ cloudkitty_database_address}}/{{ cloudkitty_database_name }}
max_retries = -1
[keystone_authtoken]
auth_uri = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_public_port }}
auth_url = {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = {{ cloudkitty_keystone_user }}
password = {{ cloudkitty_keystone_password }}
memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ memcache_secret_key }}
memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %}
[oslo_concurrency]
lock_path = /var/lib/cloudkitty/tmp
[collect]
collector = ceilometer
services = compute,image{% if enable_cinder | bool %},volume{% endif %}, network_bw_out, network_bw_in, network_floating
[oslo_messaging_notifications]
driver = messagingv2
topics = notifications
[keystone_fetcher]
keystone_version = 3
auth_section = keystone_authtoken
[ceilometer_collector]
auth_section = keystone_authtoken
[api]
host_ip = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
port = {{ cloudkitty_api_port }}

View File

@ -236,6 +236,25 @@ listen cinder_api_external
{% endif %}
{% endif %}
{% if enable_cloudkitty | bool %}
listen cloudkitty_api
bind {{ kolla_internal_vip_address }}:{{ cloudkitty_api_port }}
http-request del-header X-Forwarded-Proto
{% for host in groups['cloudkitty-api'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ cloudkitty_api_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% if haproxy_enable_external_vip | bool %}
listen cloudkitty_api_external
bind {{ kolla_external_vip_address }}:{{ cloudkitty_api_port }} {{ tls_bind_info }}
http-request del-header X-Forwarded-Proto
http-request set-header X-Forwarded-Proto https if { ssl_fc }
{% for host in groups['cloudkitty-api'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ cloudkitty_api_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% endif %}
{% endif %}
{% if enable_heat | bool %}
listen heat_api
bind {{ kolla_internal_vip_address }}:{{ heat_api_port }}

View File

@ -276,3 +276,11 @@
- { role: watcher,
tags: watcher,
when: enable_watcher | bool }
- hosts:
- cloudkitty-api
- cloudkitty-processor
roles:
- { role: cloudkitty,
tags: cloudkitty,
when: enable_cloudkitty | bool }

View File

@ -127,6 +127,7 @@ kolla_internal_vip_address: "10.10.10.254"
#enable_ceph_rgw: "no"
#enable_cinder: "no"
#enable_cinder_backend_lvm: "no"
#enable_cloudkitty: "no"
#enable_congress: "no"
#enable_heat: "yes"
#enable_horizon: "yes"

View File

@ -44,6 +44,9 @@ metadata_secret:
cinder_database_password:
cinder_keystone_password:
cloudkitty_database_password:
cloudkitty_keystone_password:
swift_keystone_password:
swift_hash_path_suffix:
swift_hash_path_prefix:

View File

@ -0,0 +1,3 @@
---
features:
- Add cloudkitty, the Rating as a Service component.