Merge "Allow skydive keystone service setup from an alternate host"

This commit is contained in:
Zuul 2019-01-21 19:24:49 +00:00 committed by Gerrit Code Review
commit e7a7eba808
3 changed files with 128 additions and 101 deletions

View File

@ -13,6 +13,12 @@
# 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.
# Set the host which will execute the shade modules
# for the skydive openstack service setup. The host must already have
# clouds.yaml properly configured.
skydive_service_setup_host: "{{ openstack_service_setup_host | default(ansible_play_hosts[0]) }}"
skydive_service_setup_host_python_interpreter: "{{ (openstack_service_setup_host is undefined) | ternary('/opt/skydive/bin/python', ansible_python['executable']) }}"
# Set the analyzer port # Set the analyzer port
skydive_analyzer_port: 8082 skydive_analyzer_port: 8082

View File

@ -68,13 +68,35 @@
tags: tags:
- package_install - package_install
- name: Check for openstack deployment # NOTE(cloudnull): Locate a clouds.yaml file on the service setup host or localhost.
- name: Check for OpenStack deployment
block: block:
- name: Slurp clouds file - name: Slurp clouds file
slurp: slurp:
src: "{{ skydive_os_cloud_file }}" src: "{{ skydive_os_cloud_file }}"
register: clouds_file register: clouds_file
delegate_to: "{{ skydive_service_setup_host }}"
rescue:
- name: Slurp clouds file (fallback to localhost)
slurp:
src: "{{ skydive_os_cloud_file }}"
register: clouds_file
delegate_to: "localhost"
failed_when: false
when:
- not (skydive_service_setup_host in ['localhost', '127.0.0.1'])
- name: OpenStack integration notice
debug:
msg: >-
No clouds file found, running without OpenStack integration.
when:
- not (clouds_file is success)
# NOTE(cloudnull): If a clouds file is found the facts for the clouds file will be delegated
# to all hosts throughout the skydive deployment.
- name: Run OpenStack ingetration deployment
block:
- name: Enable OpenStack integration - name: Enable OpenStack integration
set_fact: set_fact:
clouds_yaml: "{{ clouds_file['content'] | b64decode | from_yaml }}" clouds_yaml: "{{ clouds_file['content'] | b64decode | from_yaml }}"
@ -87,12 +109,7 @@
- include_tasks: skydive_keystone.yml - include_tasks: skydive_keystone.yml
run_once: true run_once: true
rescue:
- name: Notice
debug:
msg: >-
OpenStack setup is not possible, running in without it.
when: when:
- not (skydive_openstack_enabled | bool) - clouds_file is success
- include_tasks: skydive_setup.yml - include_tasks: skydive_setup.yml

View File

@ -28,12 +28,18 @@
- default: "skydive_os_auth_url" - default: "skydive_os_auth_url"
cfg: "auth_url" cfg: "auth_url"
- name: Create skydive venv - name: Create service setup environment when localhost is the service setup host
delegate_to: "{{ skydive_service_setup_host }}"
run_once: yes
when:
- skydive_service_setup_host_python_interpreter == '/opt/skydive/bin/python'
block:
- name: Create skydive venv
command: "/usr/bin/virtualenv --no-site-packages --no-setuptools /opt/skydive" command: "/usr/bin/virtualenv --no-site-packages --no-setuptools /opt/skydive"
args: args:
creates: /opt/skydive/bin/pip creates: /opt/skydive/bin/pip
- name: Setup skydive venv - name: Setup skydive venv
pip: pip:
name: name:
- pip - pip
@ -41,22 +47,24 @@
extra_args: "-U" extra_args: "-U"
virtualenv: /opt/skydive virtualenv: /opt/skydive
- name: Ensure the openstacksdk is installed - name: Ensure the openstacksdk is installed
pip: pip:
name: name:
- openstacksdk - openstacksdk
extra_args: "-U" extra_args: "-U"
virtualenv: /opt/skydive virtualenv: /opt/skydive
- name: Capture current ansible python interpreter - name: Show ansible interpreter
set_fact: debug:
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python') }}" var: skydive_service_setup_host_python_interpreter
- name: Set ansible python interpreter to skydive venv - name: Setup the skydive service
set_fact: delegate_to: "{{ skydive_service_setup_host }}"
ansible_python_interpreter: "/opt/skydive/bin/python" run_once: yes
vars:
- name: Add skydive project ansible_python_interpreter: "{{ skydive_service_setup_host_python_interpreter }}"
block:
- name: Add skydive project
os_project: os_project:
cloud: "{{ skydive_os_cloud }}" cloud: "{{ skydive_os_cloud }}"
state: present state: present
@ -70,7 +78,7 @@
retries: 5 retries: 5
delay: 10 delay: 10
- name: Add skydive user - name: Add skydive user
os_user: os_user:
cloud: "{{ skydive_os_cloud }}" cloud: "{{ skydive_os_cloud }}"
state: present state: present
@ -86,7 +94,7 @@
retries: 5 retries: 5
delay: 10 delay: 10
- name: Assign skydive user role - name: Assign skydive user role
os_user_role: os_user_role:
cloud: "{{ skydive_os_cloud }}" cloud: "{{ skydive_os_cloud }}"
state: present state: present
@ -99,7 +107,7 @@
retries: 5 retries: 5
delay: 10 delay: 10
- name: Add skydive service user - name: Add skydive service user
os_user: os_user:
cloud: "{{ skydive_os_cloud }}" cloud: "{{ skydive_os_cloud }}"
state: present state: present
@ -113,7 +121,7 @@
retries: 5 retries: 5
delay: 10 delay: 10
- name: Assign skydive service user role - name: Assign skydive service user role
os_user_role: os_user_role:
cloud: "{{ skydive_os_cloud }}" cloud: "{{ skydive_os_cloud }}"
state: present state: present
@ -125,7 +133,3 @@
until: keystone_api is success until: keystone_api is success
retries: 5 retries: 5
delay: 10 delay: 10
- name: Reset ansible python
set_fact:
ansible_python_interpreter: "{{ old_ansible_python_interpreter }}"