Fix the central repository to work with CentOS

Add interface drop for CentOS (Will need to be extended to allow
multiple interfaces)
Add network config files based on ansible_os_family.
Add nodepool tasks for CentOS
Add a default network file for both CentOS and Ubuntu

Change-Id: Ideb84f153fbd9f8f83ff39042f139b25719b39d8
This commit is contained in:
Andy McCrae 2016-09-02 10:56:30 +00:00 committed by Andy McCrae
parent 8593608e88
commit 44547e2696
8 changed files with 45 additions and 21 deletions

View File

@ -34,6 +34,12 @@
when: when:
- ansible_os_family == 'Debian' - ansible_os_family == 'Debian'
- name: install the epel repo rpm from a remote repo
yum:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
state: "present"
when: ansible_pkg_mgr == 'yum'
- name: Set the files to copy into the container cache for OpenStack-CI instances - name: Set the files to copy into the container cache for OpenStack-CI instances
set_fact: set_fact:
lxc_container_cache_files: lxc_container_cache_files:
@ -46,3 +52,4 @@
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive" uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
when: when:
- ansible_pkg_mgr == 'apt' - ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool

View File

@ -16,7 +16,7 @@
mysql_db: mysql_db:
login_user: "root" login_user: "root"
login_password: "secrete" login_password: "secrete"
login_host: "localhost" login_host: "127.0.0.1"
name: "{{ db_name }}" name: "{{ db_name }}"
state: "present" state: "present"
delegate_to: "{{ groups['galera_all'][0] }}" delegate_to: "{{ groups['galera_all'][0] }}"
@ -25,7 +25,7 @@
mysql_user: mysql_user:
login_user: "root" login_user: "root"
login_password: "secrete" login_password: "secrete"
login_host: "localhost" login_host: "127.0.0.1"
name: "{{ db_name }}" name: "{{ db_name }}"
password: "{{ db_password }}" password: "{{ db_password }}"
host: "{{ item }}" host: "{{ item }}"

View File

@ -5,6 +5,6 @@ iface br-mgmt inet static
bridge_fd 0 bridge_fd 0
# Notice the bridge port is the vlan tagged interface # Notice the bridge port is the vlan tagged interface
bridge_ports none bridge_ports none
address 10.100.101.1 address 10.1.0.1
netmask 255.255.255.0 netmask 255.255.255.0
offload-sg off offload-sg off

View File

@ -0,0 +1,8 @@
DEVICE=br-mgmt
TYPE=Bridge
IPADDR=10.1.0.1
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=no
DELAY=0

View File

@ -22,6 +22,11 @@
shell: "{{ playbook_dir }}/iptables-clear.sh" shell: "{{ playbook_dir }}/iptables-clear.sh"
- set_fact: - set_fact:
lxc_container_ssh_key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}" lxc_container_ssh_key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}"
- name: Ensure roots new public ssh key is in authorized_keys
authorized_key:
user: root
key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}"
manage_dir: no
roles: roles:
- role: "lxc_hosts" - role: "lxc_hosts"
lxc_net_address: 10.100.100.1 lxc_net_address: 10.100.100.1
@ -35,32 +40,44 @@
tags: tags:
- networking-dir-create - networking-dir-create
- name: Copy network configuration - name: Copy network configuration (Debian)
template: template:
src: "{{ network_conf_filename }}" src: "{{ network_conf_filename }}"
dest: /etc/network/interfaces.d/test_interfaces.cfg dest: /etc/network/interfaces.d/test_interfaces.cfg
register: network_interfaces register: network_interfaces_deb
when: when:
- network_conf_filename is defined - network_conf_filename is defined
- ansible_pkg_mgr == 'apt'
- name: Copy network configuration (RedHat)
template:
src: "{{ network_conf_filename }}"
dest: /etc/sysconfig/network-scripts/ifcfg-br-mgmt
register: network_interfaces_rhel
when:
- network_conf_filename is defined
- ansible_pkg_mgr == 'yum'
- name: Ensure our interfaces.d configuration files are loaded automatically - name: Ensure our interfaces.d configuration files are loaded automatically
lineinfile: lineinfile:
dest: /etc/network/interfaces dest: /etc/network/interfaces
line: "source /etc/network/interfaces.d/*.cfg" line: "source /etc/network/interfaces.d/*.cfg"
when:
- ansible_pkg_mgr == 'apt'
tags: tags:
- networking-interfaces-load - networking-interfaces-load
- name: Shut down the network interfaces - name: Shut down the network interfaces
command: "ifdown {{ item }}" command: "ifdown {{ item }}"
when: when:
- network_interfaces | changed - (network_interfaces_rhel | changed) or (network_interfaces_deb | changed)
- network_conf_filename is defined - network_conf_filename is defined
with_items: bridges with_items: bridges
- name: Start the network interfaces - name: Start the network interfaces
command: "ifup {{ item }}" command: "ifup {{ item }}"
when: when:
- network_interfaces | changed - (network_interfaces_rhel | changed) or (network_interfaces_deb | changed)
- network_conf_filename is defined - network_conf_filename is defined
with_items: bridges with_items: bridges
@ -69,16 +86,6 @@
- name: Add iptables rules for lxc natting - name: Add iptables rules for lxc natting
command: /usr/local/bin/lxc-system-manage iptables-create command: /usr/local/bin/lxc-system-manage iptables-create
#TODO (evrardjp) - cleanup to latest standard:
- name: Install pip packages
command: /usr/local/bin/pip install {{ item }}
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items:
- lxc-python2
- name: Add iptables rules for lxc natting - name: Add iptables rules for lxc natting
command: /usr/local/bin/lxc-system-manage iptables-create command: /usr/local/bin/lxc-system-manage iptables-create

View File

@ -224,3 +224,6 @@ tempest_service_available_swift: False
openrc_os_password: "{{ keystone_auth_admin_password }}" openrc_os_password: "{{ keystone_auth_admin_password }}"
openrc_os_domain_name: "Default" openrc_os_domain_name: "Default"
openrc_os_auth_url: "http://{{ hostvars[groups['keystone_all'][0]]['ansible_ssh_host'] }}:5000/v3" openrc_os_auth_url: "http://{{ hostvars[groups['keystone_all'][0]]['ansible_ssh_host'] }}:5000/v3"
# Network configuration settings
network_conf_filename: "{{ ansible_os_family | lower }}-network-interfaces.cfg.j2"

View File

@ -1,8 +1,8 @@
[all] [all]
localhost ansible_connection=local ansible_become=True localhost ansible_connection=local ansible_become=True
infra1 ansible_ssh_host=10.100.101.2 ansible_host=10.100.101.2 ansible_become=True ansible_user=root infra1 ansible_ssh_host=10.1.0.2 ansible_host=10.1.0.2 ansible_become=True ansible_user=root
keystone1 ansible_ssh_host=10.100.101.3 ansible_host=10.100.101.3 ansible_become=True ansible_user=root keystone1 ansible_ssh_host=10.1.0.3 ansible_host=10.1.0.3 ansible_become=True ansible_user=root
keystone2 ansible_ssh_host=10.100.101.4 ansible_host=10.100.101.4 ansible_become=True ansible_user=root keystone2 ansible_ssh_host=10.1.0.4 ansible_host=10.1.0.4 ansible_become=True ansible_user=root
[all_containers] [all_containers]
infra1 infra1

View File

@ -163,7 +163,6 @@ setenv =
commands = commands =
{[testenv:ansible]commands} {[testenv:ansible]commands}
ansible-playbook -i {toxinidir}/tests/inventory \ ansible-playbook -i {toxinidir}/tests/inventory \
-e "network_conf_filename=tests/tests-network-interfaces.cfg.j2" \
{toxinidir}/tests/test.yml -vvvv {toxinidir}/tests/test.yml -vvvv