43 lines
1.1 KiB
YAML
43 lines
1.1 KiB
YAML
---
|
|
# this role installs the bridge and reboots.
|
|
# optionally it creates a new inventory file on the jenkins host
|
|
# if the appropriate variable is declared
|
|
|
|
# check interfaces
|
|
- name: check interfaces for vmpbr0
|
|
shell: ip -o -4 ad
|
|
register: ip_ad_output
|
|
|
|
- name: install bridge
|
|
when: '"vmpbr0" not in ip_ad_output.stdout'
|
|
include_tasks: create_bridge.yaml
|
|
|
|
# Create new inventory file
|
|
- name: create inventory file
|
|
when: create_inventory | bool
|
|
block:
|
|
- name: get bridge IP
|
|
shell: ip -o -4 ad li | grep {{ bridge_name }} | awk '{print $4}' | cut -d '/' -f 1
|
|
register: bridge_ip_output
|
|
|
|
- name: set bridge_address variable
|
|
set_fact:
|
|
bridge_address: "{{ bridge_ip_output.stdout_lines[0] }}"
|
|
|
|
- name: show bridge address
|
|
debug:
|
|
msg:
|
|
- "{{ bridge_address }}"
|
|
|
|
- name: Network Bridge - Create new inventory file on jenkins server
|
|
delegate_to: localhost
|
|
template:
|
|
src: inventory.j2
|
|
dest: "/var/jenkins_home/ansible/.inv/inventory-{{ STAGE_TWO_HASH }}.yml"
|
|
|
|
- name: Reboot
|
|
when: '"vmpbr0" not in ip_ad_output.stdout'
|
|
command: "reboot now"
|
|
ignore_errors: yes
|
|
|
|
... |