Initial commit
[ta/infra-ansible.git] / roles / initial_poweroff_hosts / tasks / poweroff_virtual_node.yml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - debug:
18     msg: "Processing domain: {{domain_name}}"
19
20 - name: Get VM info
21   vars:
22     ansible_ssh_private_key_file: /etc/userconfig/id_rsa
23     ansible_user: root
24   virt:
25     uri: "qemu:///system"
26     command: get_xml 
27     name: "{{domain_name}}"
28   delegate_to: "{{hosts[installation_controller]['hwmgmt']['address']}}"
29   register: vm_info_result
30
31 - name: Create domain xml files
32   copy:
33     content: "{{vm_info_result.get_xml}}"
34     dest: "/tmp/{{domain_name}}.xml"
35     mode: 0440
36
37 - name: Get mac addresses
38   xml_parse_macs:
39     xml_file: "/tmp/{{domain_name}}.xml"
40   register: macs_result
41
42 - name: Remove domain xml files
43   file:
44     path: "/tmp/{{domain_name}}.xml"
45     state: absent
46
47 - include: mac_matcher.yml
48   vars: 
49     node: "{{node_item}}"
50   with_dict: "{{nodes_to_power_off}}"
51   loop_control:
52     loop_var: node_item