[AIR-209] Remove privilege escalation
This PS removes privilege escalation from the roles so that these roles can be used in a developer environment Change-Id: I44ddc18532ee75b0d398896d470ecf949ad4496a
This commit is contained in:
parent
c9e3feceae
commit
f3cbed1d96
@ -1,7 +1,6 @@
|
|||||||
- hosts: primary
|
- hosts: primary
|
||||||
roles:
|
roles:
|
||||||
- role: libvirt-network
|
- role: libvirt-network
|
||||||
become: true
|
|
||||||
vars:
|
vars:
|
||||||
network_action: create
|
network_action: create
|
||||||
libvirt_network:
|
libvirt_network:
|
||||||
@ -21,7 +20,6 @@
|
|||||||
address: "172.22.0.1"
|
address: "172.22.0.1"
|
||||||
netmask: "255.255.255.0"
|
netmask: "255.255.255.0"
|
||||||
- role: libvirt-network
|
- role: libvirt-network
|
||||||
become: true
|
|
||||||
vars:
|
vars:
|
||||||
network_action: rebuild
|
network_action: rebuild
|
||||||
libvirt_network:
|
libvirt_network:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
- hosts: primary
|
- hosts: primary
|
||||||
roles:
|
roles:
|
||||||
- role: libvirt-pool
|
- role: libvirt-pool
|
||||||
become: true
|
|
||||||
vars:
|
vars:
|
||||||
libvirt_pool:
|
libvirt_pool:
|
||||||
path: /var/lib/libvirt/airship
|
path: /var/lib/libvirt/airship
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
- hosts: primary
|
- hosts: primary
|
||||||
roles:
|
roles:
|
||||||
- role: libvirt-domain
|
- role: libvirt-domain
|
||||||
become: true
|
|
||||||
vars:
|
vars:
|
||||||
libvirt_domain:
|
libvirt_domain:
|
||||||
state: running
|
state: running
|
||||||
@ -16,7 +15,6 @@
|
|||||||
interfaces:
|
interfaces:
|
||||||
- network: 'provision-network'
|
- network: 'provision-network'
|
||||||
- role: libvirt-domain
|
- role: libvirt-domain
|
||||||
become: true
|
|
||||||
vars:
|
vars:
|
||||||
libvirt_domain:
|
libvirt_domain:
|
||||||
state: running
|
state: running
|
||||||
|
@ -17,6 +17,5 @@
|
|||||||
vars:
|
vars:
|
||||||
libvirt_volume: "{{ vol }}"
|
libvirt_volume: "{{ vol }}"
|
||||||
volume_action: "{{ vol.action }}"
|
volume_action: "{{ vol.action }}"
|
||||||
ansible_become: true
|
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vol
|
loop_var: vol
|
@ -16,7 +16,6 @@
|
|||||||
name: libvirt-pool
|
name: libvirt-pool
|
||||||
vars:
|
vars:
|
||||||
libvirt_pool: "{{ item }}"
|
libvirt_pool: "{{ item }}"
|
||||||
ansible_become: true
|
|
||||||
with_items: "{{ airship_gate_libvirt_pools }}"
|
with_items: "{{ airship_gate_libvirt_pools }}"
|
||||||
|
|
||||||
- name: create networks
|
- name: create networks
|
||||||
@ -24,7 +23,6 @@
|
|||||||
name: libvirt-network
|
name: libvirt-network
|
||||||
with_items: "{{ airship_gate_libvirt_networks }}"
|
with_items: "{{ airship_gate_libvirt_networks }}"
|
||||||
vars:
|
vars:
|
||||||
ansible_become: true
|
|
||||||
libvirt_network: "{{ item }}"
|
libvirt_network: "{{ item }}"
|
||||||
network_action: create
|
network_action: create
|
||||||
|
|
||||||
@ -37,12 +35,10 @@
|
|||||||
size: "{{ chosen_flavor.ephemeral_disk_size }}"
|
size: "{{ chosen_flavor.ephemeral_disk_size }}"
|
||||||
pool: "{{ airship_gate_names.pool }}"
|
pool: "{{ airship_gate_names.pool }}"
|
||||||
volume_action: create
|
volume_action: create
|
||||||
ansible_become: true
|
|
||||||
- name: Create target volumes
|
- name: Create target volumes
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-volume
|
name: libvirt-volume
|
||||||
vars:
|
vars:
|
||||||
ansible_become: true
|
|
||||||
libvirt_volume:
|
libvirt_volume:
|
||||||
name: "{{ airship_gate_names.target_volume_prefix }}-{{ vm_index }}"
|
name: "{{ airship_gate_names.target_volume_prefix }}-{{ vm_index }}"
|
||||||
size: "{{ chosen_flavor.target_disk_size }}"
|
size: "{{ chosen_flavor.target_disk_size }}"
|
||||||
@ -57,7 +53,6 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: libvirt-domain
|
name: libvirt-domain
|
||||||
vars:
|
vars:
|
||||||
ansible_become: true
|
|
||||||
libvirt_domain:
|
libvirt_domain:
|
||||||
state: shutdown
|
state: shutdown
|
||||||
name: "{{ airship_gate_names.target_vm_prefix }}-{{ vm_index }}"
|
name: "{{ airship_gate_names.target_vm_prefix }}-{{ vm_index }}"
|
||||||
@ -79,7 +74,6 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: libvirt-domain
|
name: libvirt-domain
|
||||||
vars:
|
vars:
|
||||||
ansible_become: true
|
|
||||||
libvirt_domain:
|
libvirt_domain:
|
||||||
state: shutdown
|
state: shutdown
|
||||||
name: "{{ airship_gate_names.ephemeral_vm }}"
|
name: "{{ airship_gate_names.ephemeral_vm }}"
|
||||||
|
@ -10,13 +10,10 @@
|
|||||||
vars:
|
vars:
|
||||||
network_action: "{{ item.network_action }}"
|
network_action: "{{ item.network_action }}"
|
||||||
libvirt_network: "{{ item }}"
|
libvirt_network: "{{ item }}"
|
||||||
ansible_become: true
|
|
||||||
with_items: "{{ libvirt_networks }}"
|
with_items: "{{ libvirt_networks }}"
|
||||||
- name: create pool
|
- name: create pool
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-pool
|
name: libvirt-pool
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: Create defined volumes
|
- name: Create defined volumes
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-volume
|
name: libvirt-volume
|
||||||
@ -24,20 +21,16 @@
|
|||||||
vars:
|
vars:
|
||||||
libvirt_volume: "{{ vol }}"
|
libvirt_volume: "{{ vol }}"
|
||||||
volume_action: "{{ vol.action }}"
|
volume_action: "{{ vol.action }}"
|
||||||
ansible_become: true
|
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vol
|
loop_var: vol
|
||||||
- name: create libvirt domains
|
- name: create libvirt domains
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-domain
|
name: libvirt-domain
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: save information about domain
|
- name: save information about domain
|
||||||
virt:
|
virt:
|
||||||
command: info
|
command: info
|
||||||
name: "{{ libvirt_domain.name }}"
|
name: "{{ libvirt_domain.name }}"
|
||||||
register: domain_info
|
register: domain_info
|
||||||
become: true
|
|
||||||
- name: debug domain-info
|
- name: debug domain-info
|
||||||
debug:
|
debug:
|
||||||
var: domain_info
|
var: domain_info
|
||||||
|
@ -29,6 +29,15 @@
|
|||||||
- dnsmasq
|
- dnsmasq
|
||||||
- ebtables
|
- ebtables
|
||||||
state: present
|
state: present
|
||||||
|
- name: Add user "{{ ansible_user }}" to libvirt group
|
||||||
|
become: true
|
||||||
|
user:
|
||||||
|
name: "{{ ansible_user }}"
|
||||||
|
groups:
|
||||||
|
- libvirt
|
||||||
|
append: yes
|
||||||
|
- name: Reset ssh connection to allow user changes to affect "{{ ansible_user }}"
|
||||||
|
meta: reset_connection
|
||||||
- name: Start libvirtd
|
- name: Start libvirtd
|
||||||
service:
|
service:
|
||||||
name: libvirtd
|
name: libvirtd
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
- "network_args.hosts | list"
|
- "network_args.hosts | list"
|
||||||
|
|
||||||
- name: add dhcp hosts to network
|
- name: add dhcp hosts to network
|
||||||
|
environment:
|
||||||
|
LIBVIRT_DEFAULT_URI: qemu:///system
|
||||||
shell: >-
|
shell: >-
|
||||||
virsh net-update {{ network_args.name }} \
|
virsh net-update {{ network_args.name }} \
|
||||||
add --section ip-dhcp-host \
|
add --section ip-dhcp-host \
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
loop_var: libvirt_network
|
loop_var: libvirt_network
|
||||||
vars:
|
vars:
|
||||||
ansible_become: true
|
|
||||||
network_action: "{{ libvirt_network.network_action }}"
|
network_action: "{{ libvirt_network.network_action }}"
|
||||||
- name: install required packages
|
- name: install required packages
|
||||||
apt:
|
apt:
|
||||||
@ -23,7 +22,6 @@
|
|||||||
virt_net:
|
virt_net:
|
||||||
command: info
|
command: info
|
||||||
register: libvirt_networks_info
|
register: libvirt_networks_info
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: debug network list
|
- name: debug network list
|
||||||
debug:
|
debug:
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure libvirt dir storage pool directories exist
|
|
||||||
file:
|
|
||||||
path: "{{ libvirt_pool.path }}"
|
|
||||||
owner: "{{ libvirt_pool.owner | default(omit) }}"
|
|
||||||
group: "{{ libvirt_pool.group | default(omit) }}"
|
|
||||||
mode: "{{ libvirt_pool.mode | default(omit) }}"
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Ensure libvirt storage pools are defined
|
- name: Ensure libvirt storage pools are defined
|
||||||
virt_pool:
|
virt_pool:
|
||||||
name: "{{ libvirt_pool.name }}"
|
name: "{{ libvirt_pool.name }}"
|
||||||
command: define
|
command: define
|
||||||
xml: "{{ libvirt_pool.xml | default(libvirt_pool_template_default) }}"
|
xml: "{{ libvirt_pool.xml | default(libvirt_pool_template_default) }}"
|
||||||
|
register: pool_info
|
||||||
|
|
||||||
|
- name: Ensure libvirt storage pools are built
|
||||||
|
virt_pool:
|
||||||
|
name: "{{ libvirt_pool.name }}"
|
||||||
|
command: build
|
||||||
|
when: pool_info.changed
|
||||||
|
|
||||||
- name: Ensure libvirt storage pools are active
|
- name: Ensure libvirt storage pools are active
|
||||||
virt_pool:
|
virt_pool:
|
||||||
|
@ -7,12 +7,9 @@
|
|||||||
- name: create pool
|
- name: create pool
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-pool
|
name: libvirt-pool
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: get pool information
|
- name: get pool information
|
||||||
virt_pool:
|
virt_pool:
|
||||||
command: info
|
command: info
|
||||||
become: true
|
|
||||||
register: storage_pools
|
register: storage_pools
|
||||||
|
|
||||||
- name: check if pool is available and is at given directory
|
- name: check if pool is available and is at given directory
|
||||||
|
@ -32,8 +32,11 @@
|
|||||||
- image_scheme not in libvirt_remote_scheme_list
|
- image_scheme not in libvirt_remote_scheme_list
|
||||||
|
|
||||||
- name: "Create volume"
|
- name: "Create volume"
|
||||||
|
environment:
|
||||||
|
LIBVIRT_DEFAULT_URI: qemu:///system
|
||||||
command: >-
|
command: >-
|
||||||
virsh vol-create-as "{{ libvirt_volume.pool }}" \
|
virsh vol-create-as \
|
||||||
|
--pool "{{ libvirt_volume.pool }}" \
|
||||||
--name "{{ libvirt_volume.name }}" \
|
--name "{{ libvirt_volume.name }}" \
|
||||||
--capacity "{{ libvirt_volume.size }}" \
|
--capacity "{{ libvirt_volume.size }}" \
|
||||||
--format "{{ libvirt_volume.format | default('qcow2') }}"
|
--format "{{ libvirt_volume.format | default('qcow2') }}"
|
||||||
@ -48,15 +51,25 @@
|
|||||||
- "'exists already' not in libvirt_create_volume.stdout"
|
- "'exists already' not in libvirt_create_volume.stdout"
|
||||||
|
|
||||||
- name: "Upload volume from downloaded image"
|
- name: "Upload volume from downloaded image"
|
||||||
|
environment:
|
||||||
|
LIBVIRT_DEFAULT_URI: qemu:///system
|
||||||
command: >-
|
command: >-
|
||||||
virsh vol-upload --pool "{{ libvirt_volume.pool }}" --vol "{{ libvirt_volume.name }}" --file "{{ image_dest }}"
|
virsh vol-upload \
|
||||||
|
--pool "{{ libvirt_volume.pool }}" \
|
||||||
|
--vol "{{ libvirt_volume.name }}" \
|
||||||
|
--file "{{ image_dest }}"
|
||||||
when:
|
when:
|
||||||
- "libvirt_volume.image is defined"
|
- "libvirt_volume.image is defined"
|
||||||
- "libvirt_create_volume.rc == 0"
|
- "libvirt_create_volume.rc == 0"
|
||||||
|
|
||||||
- name: "Resize volume after uploading from image"
|
- name: "Resize volume after uploading from image"
|
||||||
|
environment:
|
||||||
|
LIBVIRT_DEFAULT_URI: qemu:///system
|
||||||
command: >-
|
command: >-
|
||||||
virsh vol-resize --vol "{{ libvirt_volume.name }}" --pool "{{ libvirt_volume.pool }}" --capacity "{{ libvirt_volume.size }}"
|
virsh vol-resize \
|
||||||
|
--vol "{{ libvirt_volume.name }}" \
|
||||||
|
--pool "{{ libvirt_volume.pool }}" \
|
||||||
|
--capacity "{{ libvirt_volume.size }}"
|
||||||
when:
|
when:
|
||||||
- "libvirt_create_volume.rc == 0"
|
- "libvirt_create_volume.rc == 0"
|
||||||
- "libvirt_volume.image is defined"
|
- "libvirt_volume.image is defined"
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
- name: create pool
|
- name: create pool
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-pool
|
name: libvirt-pool
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: Create defined volumes
|
- name: Create defined volumes
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-volume
|
name: libvirt-volume
|
||||||
@ -16,14 +14,14 @@
|
|||||||
vars:
|
vars:
|
||||||
libvirt_volume: "{{ vol }}"
|
libvirt_volume: "{{ vol }}"
|
||||||
volume_action: "{{ vol.action }}"
|
volume_action: "{{ vol.action }}"
|
||||||
ansible_become: true
|
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vol
|
loop_var: vol
|
||||||
- name: save volume list
|
- name: save volume list
|
||||||
|
environment:
|
||||||
|
LIBVIRT_DEFAULT_URI: qemu:///system
|
||||||
command: virsh vol-list --pool {{ libvirt_pool.name }}
|
command: virsh vol-list --pool {{ libvirt_pool.name }}
|
||||||
register: libvirt_pool_list
|
register: libvirt_pool_list
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: true
|
|
||||||
- name: verify volumes exist
|
- name: verify volumes exist
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
@ -31,3 +29,4 @@
|
|||||||
with_items: "{{ libvirt_volumes }}"
|
with_items: "{{ libvirt_volumes }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vol
|
loop_var: vol
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
- name: create pool
|
- name: create pool
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-pool
|
name: libvirt-pool
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: Create defined volumes
|
- name: Create defined volumes
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-volume
|
name: libvirt-volume
|
||||||
@ -16,14 +14,11 @@
|
|||||||
vars:
|
vars:
|
||||||
libvirt_volume: "{{ vol }}"
|
libvirt_volume: "{{ vol }}"
|
||||||
volume_action: "{{ vol.action }}"
|
volume_action: "{{ vol.action }}"
|
||||||
ansible_become: true
|
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vol
|
loop_var: vol
|
||||||
- name: create libvirt domains
|
- name: create libvirt domains
|
||||||
include_role:
|
include_role:
|
||||||
name: libvirt-domain
|
name: libvirt-domain
|
||||||
vars:
|
|
||||||
ansible_become: true
|
|
||||||
- name: install sushy-tools
|
- name: install sushy-tools
|
||||||
include_role:
|
include_role:
|
||||||
name: redfish-emulator
|
name: redfish-emulator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user