Role cleanup/changes for newton OSA

- The database create and user creates have been removed from the
  role. These tasks have been relocated to the playbook.

- Tags cleanup.

- The "Attempt venv download" task now uses the "checksum" parameter
  from the get_url module to check if it is necessary to download
  the venv.

- The playbook and its variables (on extras folder) have been updated
  to reflect these chages.

Change-Id: If15f32d51a4f0265322abbcf25d96ba5c77fe1a6
This commit is contained in:
Flavio Ramalho 2016-08-24 02:37:46 +00:00
parent f272acfe88
commit c5c22e0b95
12 changed files with 73 additions and 235 deletions

View File

@ -22,12 +22,17 @@ component_skel:
container_skel: container_skel:
sahara_container: sahara_container:
belongs_to: belongs_to:
- infra_containers - sahara-infra_containers
- os-infra_containers
contains: contains:
- sahara_api - sahara_api
- sahara_engine - sahara_engine
properties: properties:
service_name: sahara service_name: sahara
container_release: trusty
container_fs_size: 12G physical_skel:
sahara-infra_containers:
belongs_to:
- all_containers
sahara-infra_hosts:
belongs_to:
- hosts

View File

@ -1,13 +1,20 @@
## Sahara ---
sahara_service_port: 8386 # Licensed under the Apache License, Version 2.0 (the "License");
sahara_service_proto: http # you may not use this file except in compliance with the License.
sahara_service_adminuri_proto: "{{ openstack_service_adminuri_proto | default(sahara_service_proto) }}" # You may obtain a copy of the License at
sahara_service_user_name: sahara #
sahara_service_project_name: service # http://www.apache.org/licenses/LICENSE-2.0
sahara_service_project_domain_id: default #
sahara_service_user_domain_id: default # Unless required by applicable law or agreed to in writing, software
sahara_service_adminuri: "{{ sahara_service_adminuri_proto }}://{{ internal_lb_vip_address }}:{{ sahara_service_port }}" # distributed under the License is distributed on an "AS IS" BASIS,
sahara_service_adminurl: "{{ sahara_service_adminuri }}/v1.1/%(tenant_id)s" # 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_region: "{{ service_region }}"
sahara_rabbitmq_userid: sahara sahara_service_in_ldap: "{{ service_ldap_backend_enabled }}"
sahara_rabbitmq_vhost: /sahara
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

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

View File

@ -13,96 +13,39 @@
- name: Install sahara server - name: Install sahara server
hosts: sahara_all hosts: sahara_all
gather_facts: "{{ gather_facts | default(True) }}"
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile - include: common-tasks/rabbitmq-servers-sort.yml
lxc_container: vars:
name: "{{ container_name }}" sort_group_name: "sahara_all"
container_config: - include: common-tasks/os-lxc-container-setup.yml
- "lxc.aa_profile=lxc-openstack" - include: common-tasks/rabbitmq-vhost-user.yml
delegate_to: "{{ physical_host }}" vars:
when: not is_metal | bool
register: container_config
tags:
- lxc-aa-profile
- name: Wait for container ssh
wait_for:
port: "22"
delay: "{{ ssh_delay }}"
search_regex: "OpenSSH"
host: "{{ ansible_ssh_host }}"
delegate_to: "{{ physical_host }}"
when: >
(container_config is defined and container_config | changed) or
(container_extra_config is defined and container_config | changed)
register: ssh_wait_check
until: ssh_wait_check | success
retries: 3
tags:
- ssh-wait
- name: Sort the rabbitmq servers
dist_sort:
value_to_lookup: "{{ container_name }}"
ref_list: "{{ groups['sahara_all'] }}"
src_list: "{{ rabbitmq_servers }}"
register: servers
- name: Set rabbitmq servers
set_fact:
rabbitmq_servers: "{{ servers.sorted_list }}"
- name: Create log dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-sahara" }
when: is_metal | bool
tags:
- sahara-logs
- sahara-log-dirs
- name: Create log aggregation links
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: "{{ item.state }}"
force: "yes"
with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-sahara", dest: "/var/log/sahara", state: "link" }
when: is_metal | bool
tags:
- sahara-logs
- name: Ensure Rabbitmq vhost
rabbitmq_vhost:
name: "{{ sahara_rabbitmq_vhost }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when:
- inventory_hostname == groups['sahara_all'][0]
- groups['rabbitmq_all']|length > 0
tags:
- sahara-rabbitmq
- sahara-rabbitmq-vhost
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ sahara_rabbitmq_userid }}" user: "{{ sahara_rabbitmq_userid }}"
password: "{{ sahara_rabbitmq_password }}" password: "{{ sahara_rabbitmq_password }}"
vhost: "{{ sahara_rabbitmq_vhost }}" vhost: "{{ sahara_rabbitmq_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: when:
- inventory_hostname == groups['sahara_all'][0] - inventory_hostname == groups['sahara_all'][0]
- groups['rabbitmq_all']|length > 0 - groups['rabbitmq_all'] | length > 0
tags: - include: common-tasks/os-log-dir-setup.yml
- sahara-rabbitmq vars:
- sahara-rabbitmq-user 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: roles:
- role: "os_sahara" - role: "os_sahara"
sahara_galera_address: "{{ galera_address }}"
sahara_venv_tag: "{{ openstack_release }}" sahara_venv_tag: "{{ openstack_release }}"
sahara_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/sahara-{{ openstack_release }}.tgz" sahara_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/sahara-{{ openstack_release }}-{{ ansible_architecture | lower }}.tgz"
tags: tags:
- "os-sahara" - "os-sahara"
- { role: "openstack_openrc", tags: [ "openstack-openrc" ] } - { role: "openstack_openrc", tags: [ "openstack-openrc" ] }
@ -117,10 +60,5 @@
tags: tags:
- "system-crontab-coordination" - "system-crontab-coordination"
vars: vars:
galera_address: "{{ internal_lb_vip_address }}"
is_metal: "{{ properties.is_metal|default(false) }}" is_metal: "{{ properties.is_metal|default(false) }}"
sahara_rabbitmq_userid: sahara pip_lock_to_internal_repo: "{{ (pip_links | length) >= 1 }}"
sahara_rabbitmq_vhost: /sahara
sahara_rabbitmq_servers: "{{ rabbitmq_servers }}"
sahara_rabbitmq_port: "{{ rabbitmq_port }}"
sahara_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}"

View File

@ -2,3 +2,4 @@
sahara_git_repo: https://git.openstack.org/openstack/sahara sahara_git_repo: https://git.openstack.org/openstack/sahara
sahara_git_install_branch: master sahara_git_install_branch: master
sahara_git_dest: "/opt/sahara_{{ sahara_git_install_branch | replace('/', '_') }}" sahara_git_dest: "/opt/sahara_{{ sahara_git_install_branch | replace('/', '_') }}"
sahara_git_project_group: sahara_all

View File

@ -33,17 +33,33 @@
- always - always
- include: sahara_pre_install.yml - include: sahara_pre_install.yml
tags:
- sahara-install
- include: sahara_install.yml - include: sahara_install.yml
tags:
- sahara-install
- include: sahara_post_install.yml - include: sahara_post_install.yml
tags:
- sahara-install
- sahara-config
- include: sahara_init.yml - include: sahara_init.yml
tags:
- sahara-install
- include: sahara_db_setup.yml - include: sahara_db_setup.yml
when: > when: >
inventory_hostname == groups['sahara_all'][0] inventory_hostname == groups['sahara_all'][0]
tags:
- sahara-install
- include: sahara_service_setup.yml - include: sahara_service_setup.yml
when: > when: >
inventory_hostname == groups['sahara_all'][0] inventory_hostname == groups['sahara_all'][0]
tags:
- sahara-install
- name: Flush handlers - name: Flush handlers
meta: flush_handlers meta: flush_handlers

View File

@ -11,38 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Create DB for service
mysql_db:
login_user: "{{ galera_root_user }}"
login_password: "{{ galera_root_password }}"
login_host: "{{ sahara_galera_address }}"
name: "{{ sahara_galera_database }}"
state: "present"
tags:
- sahara-db-setup
- name: Grant access to the DB for the service
mysql_user:
login_user: "{{ galera_root_user }}"
login_password: "{{ galera_root_password }}"
login_host: "{{ sahara_galera_address }}"
name: "{{ sahara_galera_user }}"
password: "{{ sahara_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ sahara_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
tags:
- sahara-db-setup
- name: Perform a Sahara DB sync - name: Perform a Sahara DB sync
command: "{{ sahara_bin }}/sahara-db-manage command: "{{ sahara_bin }}/sahara-db-manage
--config-file {{ sahara_db_config }} upgrade head" --config-file {{ sahara_db_config }} upgrade head"
become: yes become: yes
become_user: "{{ sahara_system_user_name }}" become_user: "{{ sahara_system_user_name }}"
tags:
- sahara-db-sync
- sahara-setup
- sahara-command-bin

View File

@ -13,13 +13,9 @@
- include: sahara_init_upstart.yml - include: sahara_init_upstart.yml
when: pid1_name == "init" when: pid1_name == "init"
tags:
- sahara-init
- include: sahara_init_systemd.yml - include: sahara_init_systemd.yml
when: pid1_name == "systemd" when: pid1_name == "systemd"
tags:
- sahara-init
- name: Load service - name: Load service
service: service:

View File

@ -14,9 +14,6 @@
- include: sahara_install_apt.yml - include: sahara_install_apt.yml
when: when:
- ansible_pkg_mgr == 'apt' - ansible_pkg_mgr == 'apt'
tags:
- sahara-install
- sahara-apt-packages
- name: Create developer mode constraint file - name: Create developer mode constraint file
copy: copy:
@ -27,9 +24,6 @@
{% endfor %} {% endfor %}
when: when:
- sahara_developer_mode | bool - sahara_developer_mode | bool
tags:
- sahara-install
- sahara-pip-packages
- name: Clone requirements git repository - name: Clone requirements git repository
git: git:
@ -40,27 +34,18 @@
version: "{{ sahara_requirements_git_install_branch }}" version: "{{ sahara_requirements_git_install_branch }}"
when: when:
- sahara_developer_mode | bool - sahara_developer_mode | bool
tags:
- sahara-install
- sahara-pip-packages
- name: Add constraints to pip_install_options fact for developer mode - name: Add constraints to pip_install_options fact for developer mode
set_fact: set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt" pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt"
when: when:
- sahara_developer_mode | bool - sahara_developer_mode | bool
tags:
- sahara-install
- sahara-pip-packages
- name: Set pip_install_options_fact when not in developer mode - name: Set pip_install_options_fact when not in developer mode
set_fact: set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }}" pip_install_options_fact: "{{ pip_install_options|default('') }}"
when: when:
- not sahara_developer_mode | bool - not sahara_developer_mode | bool
tags:
- sahara-install
- sahara-pip-packages
- name: Install required pip packages - name: Install required pip packages
pip: pip:
@ -71,20 +56,6 @@
until: install_packages|success until: install_packages|success
retries: 5 retries: 5
delay: 2 delay: 2
tags:
- sahara-install
- sahara-pip-packages
- name: Get local venv checksum
stat:
path: "/var/cache/{{ sahara_venv_download_url | basename }}"
get_md5: False
when:
- not sahara_developer_mode | bool
register: local_venv_stat
tags:
- sahara-install
- sahara-pip-packages
- name: Get remote venv checksum - name: Get remote venv checksum
uri: uri:
@ -93,36 +64,20 @@
when: when:
- not sahara_developer_mode | bool - not sahara_developer_mode | bool
register: remote_venv_checksum register: remote_venv_checksum
tags:
- sahara-install
- sahara-pip-packages
# TODO: When project moves to ansible 2 we can pass this a sha256sum which will:
# a) allow us to remove force: yes
# b) allow the module to calculate the checksum of dest file which would
# result in file being downloaded only if provided and dest sha256sum
# checksums differ
- name: Attempt venv download - name: Attempt venv download
get_url: get_url:
url: "{{ sahara_venv_download_url }}" url: "{{ sahara_venv_download_url }}"
dest: "/var/cache/{{ sahara_venv_download_url | basename }}" dest: "/var/cache/{{ sahara_venv_download_url | basename }}"
force: yes checksum: "sha1:{{ remote_venv_checksum.content }}"
ignore_errors: true ignore_errors: true
register: get_venv register: get_venv
when: when:
- not sahara_developer_mode | bool - not sahara_developer_mode | bool
- (local_venv_stat.stat.exists == False or
{{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }})
tags:
- sahara-install
- sahara-pip-packages
- name: Set sahara get_venv fact - name: Set sahara get_venv fact
set_fact: set_fact:
sahara_get_venv: "{{ get_venv }}" sahara_get_venv: "{{ get_venv }}"
tags:
- sahara-install
- sahara-pip-packages
- name: Remove existing venv - name: Remove existing venv
file: file:
@ -130,18 +85,12 @@
state: absent state: absent
when: when:
- sahara_get_venv | changed - sahara_get_venv | changed
tags:
- sahara-install
- sahara-pip-packages
- name: Create sahara venv dir - name: Create sahara venv dir
file: file:
path: "{{ sahara_bin | dirname }}" path: "{{ sahara_bin | dirname }}"
state: directory state: directory
register: sahara_venv_dir register: sahara_venv_dir
tags:
- sahara-install
- sahara-pip-packages
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
@ -153,14 +102,11 @@
- sahara_get_venv | changed or sahara_venv_dir | changed - sahara_get_venv | changed or sahara_venv_dir | changed
notify: notify:
- Restart sahara services - Restart sahara services
tags:
- sahara-install
- sahara-pip-packages
- name: Install pip packages (venv) - name: Install pip packages (venv)
pip: pip:
name: "{{ sahara_pip_packages | join(' ') }}" name: "{{ sahara_pip_packages | join(' ') }}"
state: present state: latest
virtualenv: "{{ sahara_bin | dirname }}" virtualenv: "{{ sahara_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}" extra_args: "{{ pip_install_options_fact }}"
@ -172,9 +118,6 @@
- sahara_get_venv | failed or sahara_developer_mode | bool - sahara_get_venv | failed or sahara_developer_mode | bool
notify: notify:
- Restart sahara services - Restart sahara services
tags:
- sahara-install
- sahara-pip-packages
- name: Update virtualenv path - name: Update virtualenv path
command: > command: >
@ -182,7 +125,3 @@
when: when:
- not sahara_developer_mode | bool - not sahara_developer_mode | bool
- sahara_get_venv | success - sahara_get_venv | success
tags:
- sahara-install
- sahara-pip-packages

View File

@ -36,6 +36,3 @@
notify: notify:
- Restart sahara api - Restart sahara api
- Restart sahara engine - Restart sahara engine
tags:
- sahara-config

View File

@ -16,8 +16,6 @@
name: "{{ sahara_system_group_name }}" name: "{{ sahara_system_group_name }}"
state: "present" state: "present"
system: "yes" system: "yes"
tags:
- sahara-group
- name: Create the sahara system user - name: Create the sahara system user
user: user:
@ -28,8 +26,6 @@
system: "yes" system: "yes"
createhome: "yes" createhome: "yes"
home: "{{ sahara_system_user_home }}" home: "{{ sahara_system_user_home }}"
tags:
- sahara-user
- name: Create sahara dir - name: Create sahara dir
file: file:
@ -43,8 +39,6 @@
- { path: "/etc/sahara" } - { path: "/etc/sahara" }
- { path: "/var/cache/sahara" } - { path: "/var/cache/sahara" }
- { path: "{{ sahara_system_user_home }}" } - { path: "{{ sahara_system_user_home }}" }
tags:
- sahara-dirs
- name: Test for log directory or link - name: Test for log directory or link
shell: | shell: |
@ -57,9 +51,6 @@
register: log_dir register: log_dir
failed_when: false failed_when: false
changed_when: log_dir.rc != 0 changed_when: log_dir.rc != 0
tags:
- sahara-dirs
- sahara-logs
- name: Create sahara log dir - name: Create sahara log dir
file: file:
@ -69,6 +60,3 @@
group: "{{ sahara_system_group_name }}" group: "{{ sahara_system_group_name }}"
mode: "0755" mode: "0755"
when: log_dir.rc != 0 when: log_dir.rc != 0
tags:
- sahara-dirs
- sahara-logs

View File

@ -27,10 +27,6 @@
until: add_service|success until: add_service|success
retries: 5 retries: 5
delay: 2 delay: 2
tags:
- sahara-api-setup
- sahara-service-add
- sahara-setup
# Create an admin user # Create an admin user
- name: Ensure sahara user - name: Ensure sahara user
@ -49,10 +45,6 @@
until: add_service|success until: add_service|success
retries: 5 retries: 5
delay: 10 delay: 10
tags:
- sahara-api-setup
- sahara-service-add
- sahara-setup
# Add a role to the user # Add a role to the user
- name: Ensure sahara user to admin role - name: Ensure sahara user to admin role
@ -71,10 +63,6 @@
until: add_service|success until: add_service|success
retries: 5 retries: 5
delay: 10 delay: 10
tags:
- sahara-api-setup
- sahara-service-add
- sahara-setup
# Create an endpoint # Create an endpoint
- name: Ensure sahara endpoint - name: Ensure sahara endpoint
@ -99,10 +87,6 @@
until: add_service|success until: add_service|success
retries: 5 retries: 5
delay: 10 delay: 10
tags:
- sahara-api-setup
- sahara-service-add
- sahara-setup
# Create proxy domain # Create proxy domain
- name: Ensure sahara_proxy domain - name: Ensure sahara_proxy domain
@ -119,6 +103,3 @@
retries: 5 retries: 5
delay: 10 delay: 10
when: sahara_use_domain_for_proxy_users|bool when: sahara_use_domain_for_proxy_users|bool
tags:
- sahara-proxy-domain-add
- sahara-setup