Add posts installation tasks, and follow the standard procedure

This commit is contained in:
Taseer Ahmed 2017-09-22 12:44:16 +05:00
parent 6d66c9c340
commit a5c895448a
5 changed files with 262 additions and 97 deletions

View File

@ -29,4 +29,48 @@ congress_bin: "/openstack/venvs/congress-{{ congress_venv_tag }}/bin"
congress_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/congress.tgz congress_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/congress.tgz
congress_requires_pip_packages: congress_requires_pip_packages:
- virtualenv - virtualenv
## System info
congress_system_user_name: congress
congress_system_group_name: congress
congress_system_shell: /bin/false
congress_system_comment: congress system user
congress_system_user_home: "/var/lib/{{ congress_system_user_name }}"
## Database credentials
congress_db_name: congress
congress_db_user: root
congress_db_login_host: ""
congress_db_login_user: ""
congress_db_login_password: ""
congress_db_user_password: ""
## Service Type and Data
congress_service_region: RegionOne
congress_service_name: congress
congress_service_proto: http
congress_service_type: nfv-orchestration
congress_service_description: "congress service"
congress_service_publicuri: "{{ congress_service_publicuri_proto }}://{{ external_lb_vip_address }}:{{ congress_service_port }}"
congress_service_publicurl: "{{ congress_service_publicuri }}"
congress_service_internaluri: "{{ congress_service_internaluri_proto }}://{{ internal_lb_vip_address }}:{{ congress_service_port }}"
congress_service_internalurl: "{{ congress_service_internaluri }}"
congress_service_adminuri: "{{ congress_service_adminuri_proto }}://{{ internal_lb_vip_address }}:{{ congress_service_port }}"
congress_service_adminurl: "{{ congress_service_adminuri }}"
congress_service_registry_proto: "{{ congress_service_proto }}"
congress_service_publicuri_proto: "{{ openstack_service_publicuri_proto | default(congress_service_proto) }}"
congress_service_adminuri_proto: "{{ openstack_service_adminuri_proto | default(congress_service_proto) }}"
congress_service_internaluri_proto: "{{ openstack_service_internaluri_proto | default(congress_service_proto) }}"
#NOTE: move password to tests/test-vars.yml
congress_service_password: password
## Keystone
congress_service_project_domain_id: default
congress_service_project_name: service
congress_service_user_domain_id: default
congress_service_user_name: congress
congress_keystone_auth_plugin: password
congress_service_in_ldap: false

90
tasks/congress_init.yml Normal file
View File

@ -0,0 +1,90 @@
---
# Copyright 2017, taseer94@gmail.com
# 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: Ensure congress service
keystone:
command: "ensure_service"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
service_name: "{{ congress_service_name }}"
service_type: "{{ congress_service_type }}"
description: "{{ congress_service_description }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
until: add_service|success
retries: 5
delay: 2
# Create an admin user
- name: Ensure congress user
keystone:
command: "ensure_user"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ congress_service_user_name }}"
tenant_name: "{{ congress_service_project_name }}"
password: "{{ congress_service_password }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
when: not congress_service_in_ldap | bool
until: add_service|success
retries: 5
delay: 10
- name: Ensure congress user to admin role
keystone:
command: "ensure_user_role"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ congress_service_user_name }}"
tenant_name: "{{ congress_service_project_name }}"
role_name: "{{ congress_role_name }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
when: not congress_service_in_ldap | bool
until: add_service|success
retries: 5
delay: 10
# Create an endpoint
- name: Ensure congress endpoint
keystone:
command: "ensure_endpoint"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
region_name: "{{ congress_service_region }}"
service_name: "{{ congress_service_name }}"
service_type: "{{ congress_service_type }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
endpoint_list:
- url: "{{ congress_service_publicurl }}"
interface: "public"
- url: "{{ congress_service_internalurl }}"
interface: "internal"
- url: "{{ congress_service_adminurl }}"
interface: "admin"
register: add_service
until: add_service|success
retries: 5
delay: 10

View File

@ -14,74 +14,85 @@
# 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: Install required pip packages - name: clone congress repo
pip: git:
name: "{{ congress_requires_pip_packages | join(' ') }}" repo: "{{ congress_git_repo }}"
state: "{{ congress_package_state }}" dest: /opt/congress
register: install_packages clone: yes
until: install_packages|success
retries: 5
delay: 2
- name: Retrieve checksum for venv download - name: install congress
uri: shell: python setup.py install
url: "{{ congress_venv_download_url | replace('tgz', 'checksum') }}" args:
return_content: yes chdir: /opt/congress
register: congress_venv_checksum
when: not congress_developer_mode | bool
- name: Attempt venv download #- name: Install required pip packages
get_url: # pip:
url: "{{ congress_venv_download_url }}" # name: "{{ congress_requires_pip_packages | join(' ') }}"
dest: "/var/cache/{{ congress_venv_download_url | basename }}" # state: "{{ congress_package_state }}"
checksum: "sha1:{{ congress_venv_checksum.content | trim }}" # register: install_packages
register: congress_get_venv # until: install_packages|success
when: not congress_developer_mode | bool # retries: 5
# delay: 2
- name: Remove existing venv #- name: Retrieve checksum for venv download
file: # uri:
path: "{{ congress_bin | dirname }}" # url: "{{ congress_venv_download_url | replace('tgz', 'checksum') }}"
state: absent # return_content: yes
when: congress_get_venv | changed # register: congress_venv_checksum
# when: not congress_developer_mode | bool
- name: Create congress venv dir #- name: Attempt venv download
file: # get_url:
path: "{{ congress_bin | dirname }}" # url: "{{ congress_venv_download_url }}"
state: directory # dest: "/var/cache/{{ congress_venv_download_url | basename }}"
register: congress_venv_dir # checksum: "sha1:{{ congress_venv_checksum.content | trim }}"
when: not congress_developer_mode | bool # register: congress_get_venv
# when: not congress_developer_mode | bool
- name: Unarchive pre-built venv #- name: Remove existing venv
unarchive: # file:
src: "/var/cache/{{ congress_venv_download_url | basename }}" # path: "{{ congress_bin | dirname }}"
dest: "{{ congress_bin | dirname }}" # state: absent
copy: "no" # when: congress_get_venv | changed
when:
- not congress_developer_mode | bool
- congress_get_venv | changed or congress_venv_dir | changed
- name: Install pip packages #- name: Create congress venv dir
pip: # file:
name: "{{ congress_pip_packages | join(' ') }}" # path: "{{ congress_bin | dirname }}"
state: "{{ congress_package_state }}" # state: directory
virtualenv: "{{ congress_bin | dirname }}" # register: congress_venv_dir
virtualenv_site_packages: "no" # when: not congress_developer_mode | bool
register: install_packages
until: install_packages|success
retries: 5
delay: 2
when: congress_developer_mode | bool
- name: Update virtualenv path #- name: Unarchive pre-built venv
command: > # unarchive:
virtualenv-tools --update-path=auto --reinitialize {{ congress_bin | dirname }} # src: "/var/cache/{{ congress_venv_download_url | basename }}"
when: # dest: "{{ congress_bin | dirname }}"
- not congress_developer_mode | bool # copy: "no"
- congress_get_venv | changed or congress_venv_dir | changed # when:
# - not congress_developer_mode | bool
# - congress_get_venv | changed or congress_venv_dir | changed
- name: Record the venv tag deployed #- name: Install pip packages
ini_file: # pip:
dest: "/etc/ansible/facts.d/openstack_ansible.fact" # name: "{{ congress_pip_packages | join(' ') }}"
section: congress # state: "{{ congress_package_state }}"
option: venv_tag # virtualenv: "{{ congress_bin | dirname }}"
value: "{{ congress_venv_tag }}" # virtualenv_site_packages: "no"
# register: install_packages
# until: install_packages|success
# retries: 5
# delay: 2
# when: congress_developer_mode | bool
#- name: Update virtualenv path
# command: >
# virtualenv-tools --update-path=auto --reinitialize {{ congress_bin | dirname }}
# when:
# - not congress_developer_mode | bool
# - congress_get_venv | changed or congress_venv_dir | changed
#- name: Record the venv tag deployed
# ini_file:
# dest: "/etc/ansible/facts.d/openstack_ansible.fact"
# section: congress
# option: venv_tag
# value: "{{ congress_venv_tag }}"

View File

@ -14,39 +14,31 @@
# 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.
- debug: - name: creating congress database
msg: "This is the post installation script" mysql_db:
name: "{{ congress_db_name }}"
state: present
login_host: "{{ congress_db_login_host }}"
login_user: "{{ congress_db_login_user }}"
login_password: "{{ congress_db_login_password }}"
- name: make configuration directory - name: create congress user access
file: mysql_user:
path: /etc/congress name: "{{ congress_db_user }}"
state: directory password: "{{ congress_db_user_password }}"
login_host: "{{ congress_db_login_host }}"
- name: make snapshot directory login_user: "{{ congress_db_login_user }}"
file: login_password: "{{ congress_db_login_password }}"
path: /etc/congress/snapshot priv: congress.*:ALL
state: directory host: "{{ item }}"
- name: copy files
copy:
src: "/opt/requirements/etc/{{ item }}"
dest: /etc/congress
with_items: with_items:
- api-paste.ini - "%"
- policy.json - "localhost"
- congress.conf.sample
- debug: - name: create congress database schema
msg: "Adding the database" shell: >
/usr/bin/congress-db-manage --config /etc/congress/congress.conf upgrade head
- debug: - name: install congress client
msg: "setting up congress accounts" pip:
name: python-congressclient
- debug:
msg: "setting up congress service endpoints"
- debug:
msg: "Setting up datasource drivers"
- debug:
msg: "Install Congress client in the utility container"

View File

@ -23,4 +23,32 @@
pip: pip:
name: "{{ item }}" name: "{{ item }}"
with_items: with_items:
- virtualenv - virtualenv
- name: create congress group
group:
name: "{{ congress_system_group_name }}"
state: present
- name: create congress user
user:
name: "{{ congress_system_user_name }}"
group: "{{ congress_system_group_name }}"
createhome: no
- name: make congress configuration directory
file:
path: "{{ item }}"
state: directory
with_items:
- /etc/congress
- /etc/congress/snapshot
- name: copy files
copy:
src: "/opt/congress/etc/{{ item }}"
dest: /etc/congress
with_items:
- api-paste.ini
- policy.json
# - congress.conf.sample