Create common task for nodepool specific tasks
Change-Id: Ib8b76b539e27872fec1b2208595c07ce3dfb360e Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
fa97bad06b
commit
2266ba91ec
48
common-tasks/test-set-nodepool-vars.yml
Normal file
48
common-tasks/test-set-nodepool-vars.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
# Copyright 2016, 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 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: Check if this is an OpenStack-CI nodepool instance
|
||||
stat:
|
||||
path: /etc/nodepool/provider
|
||||
register: nodepool
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Determine the existing Ubuntu repo URL
|
||||
shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list'
|
||||
register: ubuntu_repo_url
|
||||
changed_when: false
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Set apt repo facts based on discovered information
|
||||
set_fact:
|
||||
lxc_container_template_main_apt_repo: "{{ ubuntu_repo_url.stdout }}"
|
||||
lxc_container_template_security_apt_rep: "{{ ubuntu_repo_url.stdout }}"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
|
||||
- name: Set the files to copy into the container cache for OpenStack-CI instances
|
||||
set_fact:
|
||||
lxc_container_cache_files:
|
||||
- { src: '/etc/pip.conf', dest: '/etc/pip.conf' }
|
||||
when:
|
||||
- nodepool.stat.exists | bool
|
||||
|
||||
- name: Set Ubuntu Cloud Archive repo URL based on discovered information
|
||||
set_fact:
|
||||
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
@ -17,18 +17,4 @@
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Check if this is an OpenStack-CI nodepool instance
|
||||
stat:
|
||||
path: /etc/nodepool/provider
|
||||
register: nodepool
|
||||
delegate_to: localhost
|
||||
- name: Determine the existing Ubuntu repo URL (only on OpenStack-CI)
|
||||
shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list'
|
||||
register: ubuntu_repo_url
|
||||
changed_when: false
|
||||
when: ansible_pkg_mgr == 'apt' and nodepool.stat.exists == True
|
||||
delegate_to: localhost
|
||||
- name: Set Ubuntu Cloud Archive repo URL based on discovered information
|
||||
set_fact:
|
||||
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
|
||||
when: ansible_pkg_mgr == 'apt' and nodepool.stat.exists == True
|
||||
- include: "common-tasks/test-set-nodepool-vars.yml"
|
||||
|
@ -17,6 +17,7 @@
|
||||
hosts: localhost
|
||||
pre_tasks:
|
||||
- include: "common-tasks/test-force-package-cache-update.yml"
|
||||
- include: "common-tasks/test-set-nodepool-vars.yml"
|
||||
- name: Clear iptables rules
|
||||
shell: "{{ playbook_dir }}/iptables-clear.sh"
|
||||
- name: Ensure roots new public ssh key is in authorized_keys
|
||||
@ -26,26 +27,6 @@
|
||||
manage_dir: no
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}"
|
||||
- name: Check if this is an OpenStack-CI nodepool instance
|
||||
stat:
|
||||
path: /etc/nodepool/provider
|
||||
register: nodepool
|
||||
- name: Set the files to copy into the container cache for OpenStack-CI instances
|
||||
set_fact:
|
||||
lxc_container_cache_files:
|
||||
- { src: '/etc/pip.conf', dest: '/etc/pip.conf' }
|
||||
when: nodepool.stat.exists | bool
|
||||
- name: Determine the existing Ubuntu repo configuration
|
||||
when: ansible_os_family == 'Debian'
|
||||
shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list'
|
||||
register: ubuntu_repo
|
||||
changed_when: false
|
||||
- name: Set apt repo facts based on discovered information
|
||||
when: ansible_os_family == 'Debian'
|
||||
set_fact:
|
||||
lxc_container_template_main_apt_repo: "{{ ubuntu_repo.stdout }}"
|
||||
lxc_container_template_security_apt_rep: "{{ ubuntu_repo.stdout }}"
|
||||
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
post_tasks:
|
||||
@ -61,6 +42,8 @@
|
||||
src: "{{ network_conf_filename }}"
|
||||
dest: /etc/network/interfaces.d/test_interfaces.cfg
|
||||
register: network_interfaces
|
||||
when:
|
||||
- network_conf_filename is defined
|
||||
|
||||
- name: Ensure our interfaces.d configuration files are loaded automatically
|
||||
lineinfile:
|
||||
@ -71,12 +54,16 @@
|
||||
|
||||
- name: Shut down the network interfaces
|
||||
command: "ifdown {{ item }}"
|
||||
when: network_interfaces | changed
|
||||
when:
|
||||
- network_interfaces | changed
|
||||
- network_conf_filename is defined
|
||||
with_items: bridges
|
||||
|
||||
- name: Start the network interfaces
|
||||
command: "ifup {{ item }}"
|
||||
when: network_interfaces | changed
|
||||
when:
|
||||
- network_interfaces | changed
|
||||
- network_conf_filename is defined
|
||||
with_items: bridges
|
||||
|
||||
- name: Add iptables rule to ensure ssh checksum is correct
|
||||
@ -97,7 +84,5 @@
|
||||
- name: Add iptables rules for lxc natting
|
||||
command: /usr/local/bin/lxc-system-manage iptables-create
|
||||
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
vars_files:
|
||||
- test-vars.yml
|
||||
|
Loading…
Reference in New Issue
Block a user