
Rather than installing pip packages on to the host system, we can just execute the script and it will use the ansible runtime venv. This works for Ocata onwards. Any earlier releases can either pre-install the right packages, or implement the change to the script shebang in a fork. Change-Id: I88eb4c1bc9fe3a38803c5f0f5d1725dbed74dac7
150 lines
4.8 KiB
YAML
150 lines
4.8 KiB
YAML
---
|
|
# Copyright 2017, 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 witing, 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: Setup deploy host
|
|
hosts: deploy_hosts
|
|
gather_facts: "{{ gather_facts | default(true) }}"
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
tags:
|
|
- deploy-osa
|
|
tasks:
|
|
- name: Gather variables for each operating system
|
|
include_vars: "{{ item }}"
|
|
with_first_found:
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_distribution | lower }}.yml"
|
|
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}.yml"
|
|
tags:
|
|
- always
|
|
|
|
# Example read-write git checkout from github
|
|
- name: Get OSA
|
|
git:
|
|
repo: "{{ osa_repo | default('https://git.openstack.org/openstack/openstack-ansible') }}"
|
|
dest: /opt/openstack-ansible
|
|
version: "{{ osa_branch | default('master') }}"
|
|
force: true
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Create base directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "root"
|
|
group: "root"
|
|
mode: "0755"
|
|
with_items:
|
|
- /etc/openstack_deploy
|
|
- /etc/openstack_deploy/conf.d
|
|
- /etc/openstack_deploy/env.d
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Create Basic configs
|
|
shell: cp -R etc/openstack_deploy/* /etc/openstack_deploy
|
|
args:
|
|
chdir: /opt/openstack-ansible
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Drop osa config
|
|
template:
|
|
src: "osa/openstack_user_config.yml"
|
|
dest: /etc/openstack_deploy/openstack_user_config.yml
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Drop osa user variables
|
|
template:
|
|
src: "osa/user_mnaio_variables.yml"
|
|
dest: /etc/openstack_deploy/user_mnaio_variables.yml
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Drop config to disable serial throttle settings
|
|
template:
|
|
src: "osa/user_unserial_variables.yml"
|
|
dest: /etc/openstack_deploy/user_unserial_variables.yml
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
- osa_disable_serial | default(false) | bool
|
|
|
|
- name: Ensure the user_variables file is populated
|
|
lineinfile:
|
|
path: /etc/openstack_deploy/user_variables.yml
|
|
regexp: '^{{ item }}'
|
|
line: '{{ item }}'
|
|
create: yes
|
|
with_items:
|
|
- '---'
|
|
- 'osa_ops_mnaio: true'
|
|
|
|
- name: Bootstrap ansible
|
|
command: bash ./scripts/bootstrap-ansible.sh
|
|
args:
|
|
chdir: /opt/openstack-ansible
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Create passwords
|
|
command: ./scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml
|
|
args:
|
|
chdir: /opt/openstack-ansible
|
|
when:
|
|
- pre_config_osa | default(true) | bool
|
|
|
|
- name: Config Tmux
|
|
lineinfile:
|
|
path: /root/.tmux.conf
|
|
regexp: '^set-option'
|
|
line: 'set-option -g history-limit 20000'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: yes
|
|
|
|
- name: Run OSA
|
|
command: "{{ item }}"
|
|
args:
|
|
chdir: /opt/openstack-ansible/playbooks
|
|
with_items:
|
|
- tmux new-session -d -s build-osa
|
|
- tmux select-pane -t 0
|
|
- tmux send-keys "ulimit -n 10240" C-m
|
|
- tmux send-keys "openstack-ansible setup-hosts.yml setup-infrastructure.yml setup-openstack.yml" C-m
|
|
when:
|
|
- inventory_hostname == groups['deploy_hosts'][0]
|
|
- run_osa | default(true) | bool
|
|
|
|
- name: Finished notice
|
|
debug:
|
|
msg: |
|
|
OSA deploy running. To check on the state of this deployment, login
|
|
to the {{ groups['deploy_hosts'][0] }} VM and attach to the "build-osa" tmux session.
|
|
when:
|
|
- run_osa | default(true) | bool
|