Merge "Configure CaaS SR-IOV and provider networks"
authorLevente Kálé <levente.kale@nokia.com>
Fri, 14 Jun 2019 08:59:26 +0000 (08:59 +0000)
committerGerrit Code Review <gerrit@akraino.org>
Fri, 14 Jun 2019 08:59:26 +0000 (08:59 +0000)
16 files changed:
playbooks/baremetal-install.yml
playbooks/baremetal_setup_http.yml [moved from roles/baremetal_provision/tasks/setup_http.yml with 86% similarity]
playbooks/baremetal_teardown_http.yml [moved from roles/baremetal_provision/tasks/teardown_http.yml with 100% similarity]
roles/baremetal_interface_config/templates/os_net_config.j2
roles/baremetal_provision/defaults/main.yml
roles/baremetal_provision/tasks/convert_qcow_raw.yml
roles/baremetal_provision/tasks/ironic_nodes_create.yml
roles/baremetal_provision/tasks/ironic_nodes_deploy.yml
roles/baremetal_provision/tasks/main.yml
roles/baremetal_provision/tasks/start_console_logging.yml
roles/baremetal_provision/tasks/stop_console_logging.yml
roles/baremetal_provision/tasks/vbmc_port_setup.yml
roles/baremetal_provision/templates/baremetal_nodes.j2 [deleted file]
roles/baremetal_provision/templates/guest-img-nginx.conf.j2
roles/baremetal_provision/templates/meta_data.json.j2
roles/baremetal_provision/templates/user_data.j2

index 26279d0..12c95bd 100644 (file)
@@ -26,7 +26,6 @@
         - hosts|count > 1
         - reinitialized_nodes is not defined or (inventory_hostname not in reinitialized_nodes)
 
-
 - name: Make sure nfs server is toren down before we start
   hosts: baremetal-infra_hosts
   tasks:
 
 - name: NFS server setup
   hosts: baremetal-infra_hosts
+  vars_files:
+    - "/etc/ansible/roles/baremetal_provision/defaults/main.yml"
   tasks:
     - include: baremetal-setup-nfs-server.yaml
+    - include: baremetal_setup_http.yml
       when: hosts|count > 1
 
 - name:  Setup NFS mount points on other controllers where Ironic conductor is running
         - reinitialized_nodes is not defined or (inventory_hostname not in reinitialized_nodes)
 
 - name: Install baremetal nodes for this cloud infra
-  hosts: baremetal-infra_hosts
-  gather_facts: "{{ gather_facts | default(True) }}"
+  hosts: baremetal-nodes
+  gather_facts: False
   max_fail_percentage: 20
+  # TODO: This is just to work around the unavailable ironic_service_adminurl variable
+  vars_files:
+    - /opt/openstack-ansible/inventory/group_vars/ironic_all.yml
   roles:
     - role: baremetal_provision
       when: hosts|count > 1
+      delegate_to: localhost
 
 - name:  Tear down NFS mount points on other controllers where Ironic conductor is running
   hosts: ironic_conductor
@@ -72,5 +78,6 @@
   hosts: baremetal-infra_hosts
   tasks:
     - include: baremetal-rm-nfs-server.yaml
+    - include: baremetal_teardown_http.yml
       when:
         - hosts|count > 1
similarity index 86%
rename from roles/baremetal_provision/tasks/setup_http.yml
rename to playbooks/baremetal_setup_http.yml
index ffe2caa..b34486e 100644 (file)
 
 - name: Create nginx conf file
   template:
-    src: "guest-img-nginx.conf.j2"
+    src: "/etc/ansible/roles/baremetal_provision/templates/guest-img-nginx.conf.j2"
     dest: "/opt/guest-img-nginx/nginx.conf"
 
 - name: Create nginx service for provisioning
   copy:
-    src: "guest-img-nginx.service"
+    src: "/etc/ansible/roles/baremetal_provision/templates/guest-img-nginx.service"
     dest: "/usr/lib/systemd/system/"
 
 - name: start guest-img-nginx.service service
index 11c0d74..8496ab0 100644 (file)
@@ -14,7 +14,6 @@ for pretty printing the same.
 {%- else %}
     {%- set default_mtu = 1500 %}
 {%- endif %}
-{%- set sriov_mtu = 9000 %}
 {%- set max_mtu = 9000 %}
 {%- set host_network_profiles_list = hosts[ansible_hostname]['network_profiles'] %}
 {%- set host_network_profile_value = hostvars[ansible_hostname]['network_profiles'][host_network_profiles_list[0]] %}
@@ -32,7 +31,7 @@ for pretty printing the same.
     {%- if host_interface_net_mapping|length == 1 and host_provider_network_interfaces|length == 1 %}
         {%- if host_interface_net_mapping.keys()[0] == host_provider_network_interfaces.keys()[0] %}
             {%- set single_nic_setup = True %}
-            {%- if CLOUD_TENANT in host_networking.keys() %}
+            {%- if CLOUD_TENANT in host_networking.keys() and 'interface' in host_networking[CLOUD_TENANT] %}
                 {%- set mtu = default_mtu %}
                 {%- if 'mtu' in host_networking[CLOUD_TENANT] %}
                     {%- set mtu = host_networking[CLOUD_TENANT]['mtu'] %}
@@ -59,6 +58,17 @@ for pretty printing the same.
     {%- set host_provider_network_interfaces = {} %}
     {%- set dpdk_in_use = False %}
 {%- endif %}
+{%- set sriov_mtus = {} %}
+{%- if 'sriov_provider_networks' in host_network_profile_value %}
+    {%- for net,iface_info in host_network_profile_value['sriov_provider_networks'].iteritems() %}
+        {%- for tmp,mtu_info in host_networking['provider_networks'].iteritems() if tmp == net %}
+            {%- if 'mtu' in mtu_info %}{% set mtu = mtu_info['mtu'] %}{% else %}{% set mtu = default_mtu %}{% endif %}
+            {%- for iface in iface_info['interfaces'] %}
+                {%- if sriov_mtus.update({iface: mtu}) %}{%- endif %}
+            {%- endfor %}
+        {%- endfor %}
+    {%- endfor %}
+{%- endif %}
 {%- set external_ceph_cidr = None %}
 {%- if config_phase != 'setup' and 'external_ceph' in storage['backends'] %}
     {%- set ext_ceph = storage['backends']['external_ceph'] %}
@@ -124,7 +134,7 @@ for pretty printing the same.
 {%- if not single_nic_setup %}
 
 {#-
-If all infra ifaces on some phys iface are vlan ifaces it is configured here.
+If all infra ifaces on some phys iface are vlan ifaces then phys iface is configured here.
 Otherwise it gets configured normally on infra iface configuration in the next loop.
 -#}
 {%- for iface,infras in host_interface_net_mapping.iteritems() %}
@@ -148,6 +158,19 @@ Otherwise it gets configured normally on infra iface configuration in the next l
             {%- endif %}
         {%- endif %}
     {%- endfor %}
+    {%- if 'bond' in iface %}
+        {%- for key,slaves in host_bonding_interfaces.iteritems() if key == iface %}
+            {%- for slave in slaves %}
+                {%- if slave in sriov_mtus and sriov_mtus[slave] > ifacevars.mtu %}
+                    {%- if ifacevars.update({'mtu': sriov_mtus[slave]}) %}{%- endif %}
+                {%- endif %}
+            {%- endfor %}
+        {%- endfor %}
+    {%- else %}
+        {%- if iface in sriov_mtus and sriov_mtus[iface] > ifacevars.mtu %}
+            {%- if ifacevars.update({'mtu': sriov_mtus[iface]}) %}{%- endif %}
+        {%- endif %}
+    {%- endif %}
     {%- if ifacevars.create %}
         {%- if not loopvar.first_entry %},{%- endif %}
         {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
@@ -156,7 +179,7 @@ Otherwise it gets configured normally on infra iface configuration in the next l
             {%- if 'bond' in iface %}
                 {%- for key,slaves in host_bonding_interfaces.iteritems() if key == iface %}
                     "type": "linux_bond",
-                    {% if ifacevars.mtu > 0 %}"mtu": {{ifacevars['mtu']}},{% endif %}
+                    "mtu": {{ifacevars['mtu']}},
                     {%- if 'linux_bonding_options' in  host_network_profile_value %}
                         "bonding_options": "{{ generate_linux_bonding_options(host_network_profile_value['linux_bonding_options']) }}",
                     {%- endif %}
@@ -165,7 +188,7 @@ Otherwise it gets configured normally on infra iface configuration in the next l
                         {
                         "name": "{{slave}}",
                         "type": "interface",
-                        {% if ifacevars.mtu > 0 %}"mtu": {{ifacevars['mtu']}},{% endif %}
+                        "mtu": {{ifacevars['mtu']}},
                         "use_dhcp": false
                         }
                         {% if not loop.last %},{% endif %}
@@ -176,7 +199,7 @@ Otherwise it gets configured normally on infra iface configuration in the next l
                 {%- if configured_phys_ifaces.append(iface) %}{%- endif %}
                 "type": "interface",
             {%- endif %}
-            {% if ifacevars.mtu > 0 %}"mtu": {{ifacevars['mtu']}},{% endif %}
+            "mtu": {{ifacevars['mtu']}},
             "use_dhcp": false
         }
     {%- endif %}
@@ -196,6 +219,7 @@ Otherwise it gets configured normally on infra iface configuration in the next l
                 "name": "{{bond_key}}",
                 "type": "linux_bond",
                 "members": [ {% for member in bond_value %}
+                    {%- if configured_phys_ifaces.append(member) %}{%- endif %}
                     {
                     "name": "{{ member }}",
                     "type": "interface",
@@ -269,41 +293,96 @@ Otherwise it gets configured normally on infra iface configuration in the next l
     {%- endif %}
 {%- endfor %}
 
+{%- if config_phase != 'setup' %}
+{#- configure caas provider network interfaces -#}
+{%- for iface,value in host_provider_network_interfaces.iteritems() if 'caas' in value['type'] %}
+    {%- if not loopvar.first_entry %},{%- endif %}
+    {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
+    {%- set ifacevars = {'mtu': 0} %}
+    {
+        "name": "{{iface}}",
+        {%- for mapped_net in value['provider_networks'] %}
+            {%- for net,info in host_networking['provider_networks'].iteritems() if net == mapped_net %}
+                {%- if 'mtu' in info %}
+                    {%- if info['mtu'] > ifacevars.mtu %}
+                        {%- if ifacevars.update({'mtu': info['mtu']}) %}{%- endif %}
+                    {%- endif %}
+                {%- elif default_mtu > ifacevars.mtu %}
+                    {%- if ifacevars.update({'mtu': default_mtu}) %}{%- endif %}
+                {%- endif %}
+            {%- endfor %}
+        {%- endfor %}
+        {%- if 'bond' in iface %}
+            {%- for bond,slaves in host_bonding_interfaces.iteritems() if bond == iface %}
+                {%- for slave in slaves %}
+                    {%- if slave in sriov_mtus and sriov_mtus[slave] > ifacevars.mtu %}
+                        {%- if ifacevars.update({'mtu': sriov_mtus[slave]}) %}{%- endif %}
+                    {%- endif %}
+                {%- endfor %}
+                "type": "linux_bond",
+                "mtu": {{ifacevars.mtu}},
+                {%- if 'linux_bonding_options' in  host_network_profile_value %}
+                    "bonding_options": "{{ generate_linux_bonding_options(host_network_profile_value['linux_bonding_options']) }}",
+                {%- endif %}
+                "members": [ {% for slave in slaves %}
+                    {%- if configured_phys_ifaces.append(slave) %}{%- endif %}
+                    {
+                    "name": "{{slave}}",
+                    "type": "interface",
+                    "mtu": {{ifacevars.mtu}},
+                    "use_dhcp": false
+                    }
+                    {% if not loop.last %},{% endif %}
+                {%- endfor %}
+                ],
+            {%- endfor %}
+        {%- else %}
+            {%- if configured_phys_ifaces.append(iface) %}{%- endif %}
+            {%- if iface in sriov_mtus and sriov_mtus[iface] > ifacevars.mtu %}
+                {%- if ifacevars.update({'mtu': sriov_mtus[iface]}) %}{%- endif %}
+            {%- endif %}
+            "type": "interface",
+        {%- endif %}
+        "mtu": {{ifacevars.mtu}},
+        "use_dhcp": false
+    }
+{%- endfor %}
+{%- endif %}{#- if config_phase != 'setup' -#}
+
 {%- endif %}{#- if not single_nic_setup -#}
 
 {%- if config_phase != 'setup' or single_nic_setup %}
 
-{#- configure provider network interfaces -#}
-{%- for key,value in host_provider_network_interfaces|dictsort(true) %}
+{#- configure ovs-* provider network interfaces -#}
+{%- for key,value in host_provider_network_interfaces|dictsort(true) if 'ovs' in value['type'] %}
     {%- set keyloop = loop %}
-    {%- if 'ovs' in value['type'] %}
-        {%- if not loopvar.first_entry %},{%- endif %}
-        {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
-        {%- if value['type'] == 'ovs-dpdk' %}
-            {%- for bond_key,bond_value in host_bonding_interfaces.iteritems() if bond_key == key %}
-                {%- for member in bond_value %}
-                    {%- if member not in ixgbedevs %}
-                        {%- if configured_phys_ifaces.append(member) %}{%- endif %}
-                        {
-                            "name": "{{member}}",
-                            "type": "interface",
-                            "mtu": {{max_mtu}},
-                            "use_dhcp": false
-                        },
-                    {%- endif %}
-                {%- endfor %}
+    {%- if not loopvar.first_entry %},{%- endif %}
+    {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
+    {%- if value['type'] == 'ovs-dpdk' %}
+        {%- for bond_key,bond_value in host_bonding_interfaces.iteritems() if bond_key == key %}
+            {%- for member in bond_value %}
+                {%- if member not in ixgbedevs %}
+                    {%- if configured_phys_ifaces.append(member) %}{%- endif %}
+                    {
+                        "name": "{{member}}",
+                        "type": "interface",
+                        "mtu": {{max_mtu}},
+                        "use_dhcp": false
+                    },
+                {%- endif %}
             {%- endfor %}
-            {%- if 'bond' not in key and key not in ixgbedevs %}
-                {%- if configured_phys_ifaces.append(key) %}{%- endif %}
-                {
-                    "name": "{{key}}",
-                    "type": "interface",
-                    "mtu": {{max_mtu}},
-                    "use_dhcp": false
-                },
-            {%- endif %}
+        {%- endfor %}
+        {%- if 'bond' not in key and key not in ixgbedevs %}
+            {%- if configured_phys_ifaces.append(key) %}{%- endif %}
+            {
+                "name": "{{key}}",
+                "type": "interface",
+                "mtu": {{max_mtu}},
+                "use_dhcp": false
+            },
         {%- endif %}
-        {
+    {%- endif %}
+    {
         "name": "br-pro{{keyloop.index0}}",
         {%- if value['type'] == 'ovs-dpdk' %}
             "type": "ovs_user_bridge",
@@ -434,10 +513,10 @@ Otherwise it gets configured normally on infra iface configuration in the next l
                 {%- endfor %}
             {%- endif %}{#- if single_nic_setup -#}
         ]
-        }
-        {%- for net in value['provider_networks'] %}
-            ,
-            {
+    }
+    {%- for net in value['provider_networks'] %}
+        ,
+        {
             "name": "br-pro{{keyloop.index0}}.{{loop.index0}}",
             {%- if value['type'] == 'ovs-dpdk' %}
                 "type": "ovs_user_bridge",
@@ -453,13 +532,12 @@ Otherwise it gets configured normally on infra iface configuration in the next l
                 "peer": "pro{{keyloop.index0}}-pro{{keyloop.index0}}.{{loop.index0}}"
                 }
             ]
-            }
-        {%- endfor %}
-    {%- endif %}
+        }
+    {%- endfor %}
 {%- endfor %}
 
 {#- configure vxlan bridge for dpdk cloud tenant -#}
-{%- if CLOUD_TENANT in host_networking.keys() and dpdk_in_use %}
+{%- if CLOUD_TENANT in host_networking.keys() and 'interface' in host_networking[CLOUD_TENANT] and dpdk_in_use %}
     {%- set net = host_networking[CLOUD_TENANT] %}
     {%- if not loopvar.first_entry %},{%- endif %}
     {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
@@ -490,22 +568,18 @@ Otherwise it gets configured normally on infra iface configuration in the next l
 
 {#- configure sr-iov ifaces -#}
 {%- if config_phase != 'setup' %}
-{%- if 'sriov_provider_networks' in host_network_profile_value %}
-    {%- for net,net_info in host_network_profile_value['sriov_provider_networks'].iteritems() %}
-        {%- for iface in net_info['interfaces'] %}
-            {%- if iface not in configured_phys_ifaces %}
-                {%- if not loopvar.first_entry %},{%- endif %}
-                {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
-                {
+    {%- for iface,mtu in sriov_mtus.iteritems() %}
+        {%- if iface not in configured_phys_ifaces %}
+            {%- if not loopvar.first_entry %},{%- endif %}
+            {%- if loopvar.update({'first_entry': False}) %}{%- endif %}
+            {
                 "name": "{{iface}}",
                 "type": "interface",
-                "mtu": {{sriov_mtu}},
+                "mtu": {{mtu}},
                 "use_dhcp": false
-                }
-            {%- endif %}
-        {%- endfor %}
+            }
+        {%- endif %}
     {%- endfor %}
-{%- endif %}
 {%- endif %}{#- if config_phase != 'setup' -#}
 ]
 }
index 98bdb9a..0b40904 100644 (file)
@@ -18,8 +18,6 @@
 ## Verbosity Options
 debug: False
 
-net_conn_details: []
-baremetal_ironic_nodes_ids: []
 config_drive_templates:
     - src: "meta_data.json.j2"
       dest: "meta_data.json"
index 34cbbbf..f7146d0 100644 (file)
   command: 'mv /opt/images/guest-image.img.raw /opt/images/guest-image.img'
   when:
     - qemu_img.stdout == " qcow2"
+
+- name: Checking the details of Provisioning images
+  stat:
+    path: "{{ item }}"
+    get_md5: no
+    get_checksum: no
+  with_items:
+    - "/opt/images/guest-image.img"
+  register: stat_list
+  no_log: True
+
+- name: Change ownership of provisioning images
+  file:
+    path: "{{ item.stat.path }}"
+    owner: "ironic"
+    group: "ironic"
+  with_items: "{{stat_list.results}}"
+  when: item.stat.pw_name != 'ironic'
+  no_log: True
index e2f5818..fff4f11 100644 (file)
 # 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: Checking the details of Provisioning images
-  stat:
-    path: "{{ item }}"
-    get_md5: no
-    get_checksum: no
-  with_items:
-    - "/opt/images/guest-image.img"
-  register: stat_list
-  no_log: True
-
-- name: Change ownership of provisioning images
-  file:
-    path: "{{ item.stat.path }}"
-    owner: "ironic"
-    group: "ironic"
-  with_items: "{{stat_list.results}}"
-  when: item.stat.pw_name != 'ironic'
-  no_log: True
-
 - name: Write os_net_config to tmp files
   copy:
-    content: "{{ item.driver_info.power.os_net_config }}"
-    dest: "/tmp/{{item.name}}_config.yaml"
+    content: "{{ ironic_node_details.driver_info.power.os_net_config }}"
+    dest: "/tmp/{{ironic_node_details.name}}_config.yaml"
     mode: 0444
-  with_items: "{{ baremetal_ironic_nodes }}"
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Create baremetal ironic nodes
   environment:
     auth_type: 'None'
     ironic_url: "{{ ironic_service_adminurl }}"
     state: present
-    name: "{{ item.1.name }}"
-    driver: "{{ item.1.driver }}"
-    nics: "{{ item.1.nics }}"
-    properties: "{{ item.1.properties }}"
-    driver_info: "{{ item.1.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+item.1.name+'_config.yaml'), 'ipmi_terminal_port': hosts[item.1.name]['ipmi_terminal_port'] }}, recursive=True ) }}"
-  with_indexed_items: "{{ baremetal_ironic_nodes }}"
+    name: "{{ ironic_node_details.name }}"
+    driver: "{{ ironic_node_details.driver }}"
+    nics: "{{ ironic_node_details.nics }}"
+    properties: "{{ ironic_node_details.properties }}"
+    driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'] }}, recursive=True ) }}"
+    driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'], 'provisioning_server_http_port': golden_image_http_port }}, recursive=True ) }}"
+
   register: baremetal_ironic_nodes_results
   when: installation_phase == "provisioning-started"
-  loop_control:
-    label: "{{ item.1.name }}"
 
-- name: Create list of nodes which are not in active state and not the installation controller.
+- name: Create node datastructure if its not in active state and not the installation controller.
   set_fact:
-    baremetal_ironic_nodes_ids: "{{ baremetal_ironic_nodes_ids  +  [{'uuid': item.uuid, 'name': item.item.1.name}] }}"
-  with_items: "{{ baremetal_ironic_nodes_results.results }}"
+    baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" }
   when:
     - installation_phase == "provisioning-started"
-    - hosts[item.item.1.name]['installation_host'] is undefined
-    - item.provision_state != 'active'
-  no_log: True
+    - hosts[ironic_node_details.name]['installation_host'] is undefined
+    - baremetal_ironic_nodes_results.provision_state != 'active'
 
 - name: Create baremetal ironic nodes
   os_ironic_props:
     endpoint_type: internal
     auth_type: password
     state: present
-    name: "{{ item.1.name }}"
-    driver: "{{ item.1.driver }}"
-    nics: "{{ item.1.nics }}"
-    properties: "{{ item.1.properties }}"
-    driver_info: "{{ item.1.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+item.1.name+'_config.yaml'), 'ipmi_terminal_port': hosts[item.1.name]['ipmi_terminal_port'] }}, recursive=True ) }}"
-  with_indexed_items: "{{ baremetal_ironic_nodes }}"
+    name: "{{ ironic_node_details.name }}"
+    driver: "{{ ironic_node_details.driver }}"
+    nics: "{{ ironic_node_details.nics }}"
+    properties: "{{ ironic_node_details.properties }}"
+    driver_info: "{{ ironic_node_details.driver_info | combine({'power': {'os_net_config': lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml'), 'ipmi_terminal_port': hosts[ironic_node_details.name]['ipmi_terminal_port'], 'provisioning_server_http_port': golden_image_http_port }}, recursive=True ) }}"
   register: baremetal_ironic_nodes_results
-  when: (installation_phase != "provisioning-started" and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and item.1.name in reinitialized_nodes) or (scaled_out_nodes is defined and item.1.name in scaled_out_nodes)
-  loop_control:
-    label: "{{ item.1.name }}"
+  when: (installation_phase != "provisioning-started" and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and ironic_node_details.name in reinitialized_nodes) or (scaled_out_nodes is defined and ironic_node_details.name in scaled_out_nodes)
 
-- name: Create list of nodes which are not in active state and not the installation controller.
+- name: Create node datastructure if its not in active state and not the installation controller.
   set_fact:
-    baremetal_ironic_nodes_ids: "{{ baremetal_ironic_nodes_ids  +  [{'uuid': item.uuid, 'name': item.item.1.name}] }}"
-  with_items: "{{ baremetal_ironic_nodes_results.results }}"
+    baremetal_ironic_node_id: {"uuid": "{{baremetal_ironic_nodes_results.uuid}}", "name": "{{ironic_node_details.name}}" }
   when:
     - installation_phase != "provisioning-started"
-    - (hosts[item.item.1.name]['installation_host'] is undefined and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and item.item.1.name in reinitialized_nodes) or (scaled_out_nodes is defined and item.item.1.name in scaled_out_nodes)
-    - item.provision_state != 'active'
-  no_log: True
+    - (hosts[ironic_node_details.name]['installation_host'] is undefined and reinitialized_nodes is not defined and scaled_out_nodes is not defined) or (reinitialized_nodes is defined and ironic_node_details.name in reinitialized_nodes) or (scaled_out_nodes is defined and ironic_node_details.name in scaled_out_nodes)
+    - baremetal_ironic_nodes_results.provision_state != 'active'
index cb5ba95..1aaef95 100644 (file)
     in_interface: "{{ networking['infra_internal']['interface'] }}"
   when:
     - installation_phase == "provisioning-started"
+    - not virtual_env
+  run_once: true
 
 - name: Power off nodes
   environment:
     OS_AUTH_TOKEN: "fake-token"
     IRONIC_URL: "{{ ironic_service_adminurl }}"
-  command: "/usr/bin/ironic node-set-power-state {{item.uuid}} off"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
+  command: "/usr/bin/ironic node-set-power-state {{baremetal_ironic_node_id.uuid}} off"
   when:
     - not virtual_env
     - installation_phase == "provisioning-started"
   retries: 5
   delay: 10
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Power off nodes
-  command: "openstack --os-cloud default baremetal node power off {{item.uuid}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
+  command: "openstack --os-cloud default baremetal node power off {{baremetal_ironic_node_id.uuid}}"
   when:
     - not virtual_env
     - installation_phase != "provisioning-started"
   retries: 5
   delay: 10
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Ensure nodes are powered off
   environment:
     auth:
     auth_type: 'None'
     ironic_url: "{{ ironic_service_adminurl }}"
-    nodes_details: "{{ baremetal_ironic_nodes_ids }}"
+    nodes_details:
+      - "{{ baremetal_ironic_node_id }}"
     power_state: 'power off'
   until: power_pending_list | length == 0
   retries: 30
   delay: 6
   when:
-    - not virtual_env and baremetal_ironic_nodes_ids | length > 0
+    - not virtual_env
     - installation_phase == "provisioning-started"
-  no_log: True
+  #no_log: True
 
 - name: Ensure nodes are powered off
   os_node_power_check:
     cloud: default
     auth_type: password
     ironic_url: "{{ ironic_service_adminurl }}"
-    nodes_details: "{{ baremetal_ironic_nodes_ids }}"
+    nodes_details:
+      - "{{ baremetal_ironic_node_id }}"
     power_state: 'power off'
     endpoint_type: internal
   until: power_pending_list | length == 0
   retries: 30
   delay: 6
   when:
-    - not virtual_env and baremetal_ironic_nodes_ids | length > 0
+    - not virtual_env
     - installation_phase != "provisioning-started"
-  no_log: True
+  #no_log: True
 
 # Sleep to make sure power is off
 - name: Sleep for 15 seconds
   pause:
     seconds: 15
-  when: not virtual_env and baremetal_ironic_nodes_ids | length > 0
+  when: not virtual_env
 
 - name: Create config-drive directories for all nodes
   file:
-    path: "/var/lib/ironic/confdrive/{{item.name}}/openstack/latest/"
+    path: "/var/lib/ironic/confdrive/{{baremetal_ironic_node_id.name}}/openstack/latest/"
     state: "directory"
     owner: "ironic"
     group: "ironic"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
-  loop_control:
-    label: "{{ item.name }}"
+    mode: "0775"
 
 - name: Generate config-drive files
   config_template:
-    src: "{{ item[1].src }}"
-    dest: "/var/lib/ironic/confdrive/{{item[0].name}}/openstack/latest/{{ item[1].dest }}"
+    src: "{{item.src}}"
+    dest: "/var/lib/ironic/confdrive/{{baremetal_ironic_node_id.name}}/openstack/latest/{{item.dest}}"
     owner: "ironic"
     group: "ironic"
     mode: "0644"
-    config_type: "{{ item[1].config_type }}"
-  with_nested: 
-    - "{{ baremetal_ironic_nodes_ids }}"
+    config_type: "{{item.config_type}}"
+  with_items:
     - "{{ config_drive_templates }}"
-  loop_control:
-    label: "{{ item[0].name }}"
 
 - name: Stat config-drive files to check if they exists
   stat:
-    path: "/var/lib/ironic/confdrive/{{ item.name }}.base64"
+    path: "/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64"
   register: confdrive_stat
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
 
 - name: Prepare Config-drive ISO file
   shell: |
     # Generated ISO
-    genisoimage -o /var/lib/ironic/confdrive/{{ item.item.name }}.iso -ldots -allow-lowercase -allow-multidot -l -publisher 'ironicclient-configdrive 0.1' -quiet -J -r -V config-2 /var/lib/ironic/confdrive/{{ item.item.name }}
+    genisoimage -o /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso -ldots -allow-lowercase -allow-multidot -l -publisher 'ironicclient-configdrive 0.1' -quiet -J -r -V config-2 /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}
     # Zip it!
-    gzip /var/lib/ironic/confdrive/{{ item.item.name }}.iso
+    gzip /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso
     # Encode it to base64
-    base64 -w 0 /var/lib/ironic/confdrive/{{ item.item.name }}.iso.gz > /var/lib/ironic/confdrive/{{ item.item.name }}.base64
-  when: not item.stat.exists
-  with_items: "{{confdrive_stat.results}}"
+    base64 -w 0 /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz > /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
+    chown ironic:ironic /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz
+    chown ironic:ironic /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
+    chmod o+r /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.iso.gz
+    chmod o+r /var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64
+  when: not confdrive_stat.stat.exists
 
 - name: Remove os_net_config temp files
   file:
-    dest: "/tmp/{{item.name}}_config.yaml"
+    dest: "/tmp/{{baremetal_ironic_node_id.name}}_config.yaml"
     state: absent
-  with_items: "{{ baremetal_ironic_nodes }}"
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Calculate md5sum of Golden image
   stat:
     path: "/opt/images/guest-image.img"
     get_md5: yes
   register: golden_img_md5sum
-  when: baremetal_ironic_nodes_ids | length > 0
+  run_once: true
 
 - name: Enable traffic on infra_internal
   iptables:
     in_interface: "{{ networking['infra_internal']['interface'] }}"
   when:
     - installation_phase == "provisioning-started"
+    - not virtual_env
+  run_once: true
+
+- set_fact:
+    initiator_host: "{{ lookup('file', '/etc/hostname') }}"
+
+- set_fact:
+    initiator_host_ip: "{{ hostvars[initiator_host]['networking']['infra_internal']['ip'] }}"
 
 - name: Configure Baremetal deployment
   environment:
     auth:
     auth_type: 'None'
     ironic_url: "{{ ironic_service_adminurl }}"
-    uuid: "{{item.uuid}}"
+    uuid: "{{baremetal_ironic_node_id.uuid}}"
     deploy: False
     state: present
     power: absent
     maintenance: False
     instance_info:
       root_gb: 10
-      image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
+      image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
       image_checksum: "{{golden_img_md5sum.stat.md5}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
-  loop_control:
-    label: "{{ item.name }}"
   when:
     - installation_phase == "provisioning-started"
 
     cloud: default
     endpoint_type: internal
     auth_type: password
-    uuid: "{{item.uuid}}"
+    uuid: "{{baremetal_ironic_node_id.uuid}}"
     deploy: False
     state: present
     power: absent
     maintenance: False
     instance_info:
       root_gb: 10
-      image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
+      image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
       image_checksum: "{{golden_img_md5sum.stat.md5}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
-  loop_control:
-    label: "{{ item.name }}"
   when:
     - installation_phase != "provisioning-started"
 
     ironic_url: "{{ ironic_service_adminurl }}"
     deploy: True
     power: present
-    config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ item.name }}.base64')}}"
-    uuid: "{{item.uuid}}"
+    config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64')}}"
+    uuid: "{{baremetal_ironic_node_id.uuid}}"
     instance_info:
       root_gb: 10
-      image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
+      image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
       image_checksum: "{{golden_img_md5sum.stat.md5}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
-  loop_control:
-    label: "{{ item.name }}"
   when:
     - installation_phase == "provisioning-started"
 
     auth_type: password
     deploy: True
     power: present
-    config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ item.name }}.base64')}}"
-    uuid: "{{item.uuid}}"
+    config_drive: "{{lookup('file', '/var/lib/ironic/confdrive/{{ baremetal_ironic_node_id.name }}.base64')}}"
+    uuid: "{{baremetal_ironic_node_id.uuid}}"
     instance_info:
       root_gb: 10
-      image_source: "http://{{ansible_host}}:{{golden_image_http_port}}/guest-image.img"
+      image_source: "http://{{initiator_host_ip}}:{{golden_image_http_port}}/guest-image.img"
       image_checksum: "{{golden_img_md5sum.stat.md5}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
-  loop_control:
-    label: "{{ item.name }}"
   when:
     - installation_phase != "provisioning-started"
 
     auth:
     auth_type: 'None'
     ironic_url: "{{ ironic_service_adminurl }}"
-    nodes_details: "{{baremetal_ironic_nodes_ids}}"
+    nodes_details:
+      - "{{baremetal_ironic_node_id}}"
   register: baremetal_ironic_node_provisionin_results
   until: provision_pending_list | length == 0
   retries: 360
     cloud: default
     endpoint_type: internal
     auth_type: password
-    nodes_details: "{{baremetal_ironic_nodes_ids}}"
+    nodes_details:
+      - "{{baremetal_ironic_node_id}}"
   register: baremetal_ironic_node_provisionin_results
   until: provision_pending_list | length == 0
   retries: 360
     - installation_phase != "provisioning-started"
     - baremetal_ironic_node_provisionin_results['ansible_facts']['provision_failed_list'] | length > 0
 
+- set_fact:
+    net_conn_details: "{{ ironic_node_details.driver_info.power.os_net_config | json_query('network_config[*].addresses[0].ip_netmask') |  ipaddr('address') }}"
+  when: ironic_node_details.driver_info.power.os_net_config.network_config[0].type != 'ovs_bridge'
+  no_log: True
+
+- set_fact:
+    net_conn_details: "{{ ironic_node_details.driver_info.power.os_net_config | json_query('network_config[*].members[*].addresses[0].ip_netmask')|first | ipaddr('address') }}"
+  when: ironic_node_details.driver_info.power.os_net_config.network_config[0].type == 'ovs_bridge'
+  no_log: True
+
 # JanneS: until looping is a fix for the problem in wait_for module; it does not catch socket error in recv if peer closes the connection.
 - name: Verify remote node ssh ports active. Waiting for 60mins max.
   wait_for:
-     host: "{{ item.node_ip[0] }}"
+     host: "{{ net_conn_details[0] }}"
      port: 22
      search_regex: OpenSSH
      sleep: 5
   register: remote_success
   until: remote_success | success
   retries: 3
-  with_items: "{{net_conn_details}}"
 
 - name: Wait for remote node ssh login. Waiting for 10mins max.
-  become: "{{ ansible_env.SUDO_USER }}"
-  local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ item.node_ip[0] }} "echo success"
+  become: "{{ users.admin_user_name }}"
+  local_action: shell ssh -oBatchMode=yes -4 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ net_conn_details[0] }} "echo success"
   register: user_enabled
-  with_items: "{{net_conn_details}}"
   until: user_enabled.stdout.find("success") != -1
   retries: 90
   delay: 10
-
-- name: Set Ironic maintenance mode to all nodes.
-  os_ironic_node:
-    cloud: default
-    endpoint_type: internal
-    auth_type: password
-    uuid: "{{item.name}}"
-    maintenance: True
-    deploy: False
-  with_items: "{{ baremetal_ironic_nodes }}"
-  loop_control:
-    label: "{{ item.name }}"
-  when:
-    - installation_phase != "provisioning-started"
-
-- name: Set Ironic maintenance mode to all nodes.
-  environment:
-    OS_AUTH_TOKEN: "fake-token"
-    IRONIC_URL: "{{ ironic_service_adminurl }}"
-  os_ironic_node:
-    auth:
-    auth_type: 'None'
-    ironic_url: "{{ ironic_service_adminurl }}"
-    uuid: "{{item.name}}"
-    maintenance: True
-    deploy: False
-  with_items: "{{ baremetal_ironic_nodes }}"
-  loop_control:
-    label: "{{ item.name }}"
-  when:
-    - installation_phase == "provisioning-started"
index 38b4675..04794af 100644 (file)
 
 
 - include: convert_qcow_raw.yml
-
-- name: Convert baremetal_nodes.j2 Jinja2 template to json file
-  template:
-    src: 'baremetal_nodes.j2'
-    dest: '/tmp/baremetal_nodes.json'
-
-- name: Include variables from baremetal_nodes.json
-  include_vars: '/tmp/baremetal_nodes.json'
-
-- name: Remove /tmp/baremetal_nodes.json
-  file:
-    path: "/tmp/baremetal_nodes.json"
-    state: "absent"
-
-- name: Restore baremetal_ironic_nodes variable with ironic_nodes variable
-  set_fact:
-    baremetal_ironic_nodes: "{{ironic_nodes}}"
-  when: baremetal_ironic_nodes is undefined
+  run_once: True
 
 - name: Create vbmc ports for virtual hosts
-  include: vbmc_port_setup.yml
+  include_tasks: vbmc_port_setup.yml
   when: virtual_env
 
-- set_fact:
-    net_conn_details: "{{net_conn_details + [{'node_name': item.name, 'node_ip': item.driver_info.power.os_net_config | json_query('network_config[*].addresses[0].ip_netmask') |  ipaddr('address')}] }}"
-  with_items: "{{ baremetal_ironic_nodes }}"
-  when: item.driver_info.power.os_net_config.network_config[0].type != 'ovs_bridge'
-  no_log: True
-
-- set_fact:
-    net_conn_details: "{{net_conn_details + [{'node_name': item.name, 'node_ip': item.driver_info.power.os_net_config | json_query('network_config[*].members[*].addresses[0].ip_netmask')|first | ipaddr('address')}] }}"
-  with_items: "{{ baremetal_ironic_nodes }}"
-  when: item.driver_info.power.os_net_config.network_config[0].type == 'ovs_bridge'
-  no_log: True
-
-- include: setup_http.yml
-  tags: http_provision
-
 - name: Setup tmux
   copy:
     src: "tmux_setup"
     dest: "/opt/"
 
-- include: ironic_nodes_create.yml
+- include_tasks: ironic_nodes_create.yml
   tags:
     - baremetal-ironic-nodes-create
 
-- include: start_console_logging.yml
+- include_tasks: start_console_logging.yml
   tags:
     - baremetal-ironic-nodes-deploy
   when: virtual_env == false
 
-- include: ironic_nodes_deploy.yml
+- include_tasks: ironic_nodes_deploy.yml
   tags:
     - baremetal-ironic-nodes-deploy
-
-- include: stop_console_logging.yml
+  when: baremetal_ironic_node_id is defined
+
+- name: Set Ironic node in maintenance.
+  os_ironic_node:
+    cloud: default
+    endpoint_type: internal
+    auth_type: password
+    uuid: "{{ironic_node_details.name}}"
+    maintenance: True
+    deploy: False
+  when:
+    - installation_phase != "provisioning-started"
+
+- name: Set Ironic node in maintenance.
+  environment:
+    OS_AUTH_TOKEN: "fake-token"
+    IRONIC_URL: "{{ ironic_service_adminurl }}"
+  os_ironic_node:
+    auth:
+    auth_type: 'None'
+    ironic_url: "{{ ironic_service_adminurl }}"
+    uuid: "{{ironic_node_details.name}}"
+    maintenance: True
+    deploy: False
+  when:
+    - installation_phase == "provisioning-started"
+
+- include_tasks: stop_console_logging.yml
   tags:
     - baremetal-ironic-nodes-deploy
   when: virtual_env == false
-
-- include: teardown_http.yml
-  tags: http_provision
index 061c722..1f3992f 100644 (file)
 # limitations under the License.
 
 - name: Deactivate ipmi sol
-  command: "/usr/bin/ipmitool -I lanplus -H {{hosts[item.name]['hwmgmt']['address']}} -U {{hosts[item.name]['hwmgmt']['user']}} -P {{hosts[item.name]['hwmgmt']['password']}} sol deactivate"
-  with_items: "{{baremetal_ironic_nodes_ids}}"
+  command: "/usr/bin/ipmitool -I lanplus -H {{hosts[ironic_node_details.name]['hwmgmt']['address']}} -U {{hosts[ironic_node_details.name]['hwmgmt']['user']}} -P {{hosts[ironic_node_details.name]['hwmgmt']['password']}} sol deactivate"
   ignore_errors: yes
   no_log: True
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Disable shellinabox console logging for target nodes
   environment:
     OS_AUTH_TOKEN: "fake-token"
     IRONIC_URL: "{{ ironic_service_adminurl }}"
-  command: "ironic node-set-console-mode {{item.name}} false"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
+  command: "ironic node-set-console-mode {{ironic_node_details.name}} false"
   when:
     - installation_phase == "provisioning-started"
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Disable shellinabox console logging for target nodes
-  command: "openstack --os-cloud default baremetal node console disable {{item.name}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
+  command: "openstack --os-cloud default baremetal node console disable {{ironic_node_details.name}}"
   when:
     - installation_phase != "provisioning-started"
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Create directories for tmux
   file:
@@ -54,8 +45,5 @@
   shell: "source /opt/tmux_setup/tmux.inc; tmux_session_start bash /bin/bash"
 
 - name: Start tmux windows for each nodes
-  shell: "source /opt/tmux_setup/tmux.inc; tmux_cmd {{item.name}} /usr/bin/ipmitool -I lanplus -H {{hosts[item.name]['hwmgmt']['address']}} -U {{hosts[item.name]['hwmgmt']['user']}} -P {{hosts[item.name]['hwmgmt']['password']}} sol activate"
+  shell: "source /opt/tmux_setup/tmux.inc; tmux_cmd {{ironic_node_details.name}} /usr/bin/ipmitool -I lanplus -H {{hosts[ironic_node_details.name]['hwmgmt']['address']}} -U {{hosts[ironic_node_details.name]['hwmgmt']['user']}} -P {{hosts[ironic_node_details.name]['hwmgmt']['password']}} sol activate"
   no_log: True
-  with_items: "{{baremetal_ironic_nodes_ids}}"
-  loop_control:
-    label: "{{ item.name }}"
index 1e4cd35..45a6b81 100644 (file)
 # limitations under the License.
 
 - name: Stop tmux console windows
-  shell: "source /opt/tmux_setup/tmux.inc; tmux_kill {{item.name}}"
-  with_items: "{{baremetal_ironic_nodes_ids}}"
+  shell: "source /opt/tmux_setup/tmux.inc; tmux_kill {{ironic_node_details.name}}"
   ignore_errors: yes
-  loop_control:
-    label: "{{ item.name }}"
-
 
 - name: Stop tmux console session
   shell: "source /opt/tmux_setup/tmux.inc; tmux_kill tmux-session-deploy"
   ignore_errors: yes
 
 - name: Deactivate ipmi sol
-  command: "/usr/bin/ipmitool -I lanplus -H {{hosts[item.name]['hwmgmt']['address']}} -U {{hosts[item.name]['hwmgmt']['user']}} -P {{hosts[item.name]['hwmgmt']['password']}} sol deactivate"
-  with_items: "{{baremetal_ironic_nodes_ids}}"
+  command: "/usr/bin/ipmitool -I lanplus -H {{hosts[ironic_node_details.name]['hwmgmt']['address']}} -U {{hosts[ironic_node_details.name]['hwmgmt']['user']}} -P {{hosts[ironic_node_details.name]['hwmgmt']['password']}} sol deactivate"
   ignore_errors: yes
   no_log: True
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Enable shellinabox console logging for target nodes
   environment:
     OS_AUTH_TOKEN: "fake-token"
     IRONIC_URL: "{{ ironic_service_adminurl }}"
-  command: "ironic node-set-console-mode {{item.name}} true"
-  with_items:
-    - "{{ baremetal_ironic_nodes_ids }}"
-    - {"name": "{{installation_controller}}"}
+  command: "ironic node-set-console-mode {{ironic_node_details.name}} true"
   when:
     - installation_phase == "provisioning-started"
-  loop_control:
-    label: "{{ item.name }}"
 
 - name: Enable shellinabox console logging for target nodes
-  command: "openstack --os-cloud default baremetal node console enable {{item.name}}"
-  with_items: "{{ baremetal_ironic_nodes_ids }}"
+  command: "openstack --os-cloud default baremetal node console enable {{ironic_node_details.name}}"
   when:
     - installation_phase != "provisioning-started"
-  loop_control:
-    label: "{{ item.name }}"
index 7061aa3..f5c4776 100644 (file)
     dest: "/etc/virtualbmc/"
 
 - name: Create vbmc nodes
-  command: /usr/bin/vbmc add {{ item.name }} --libvirt-uri "qemu+ssh://root@{{item.driver_info['power']['ssh_address'] | ipwrap}}/system?no_verify=1" --port {{ item.driver_info['power']['ipmi_port'] }}
+  command: /usr/bin/vbmc add {{ ironic_node_details.name }} --libvirt-uri "qemu+ssh://root@{{ironic_node_details.driver_info['power']['ssh_address'] | ipwrap}}/system?no_verify=1" --port {{ ironic_node_details.driver_info['power']['ipmi_port'] }}
   become: True
   become_flags: '-H'
   register: vbmc_out
-  with_items: "{{ baremetal_ironic_nodes }}"
-  failed_when: "vbmc_out.rc != 0 and 'already exists' not in vbmc_out.stderr"
-  loop_control:
-    label: "{{ item.name }}"
+  failed_when: "vbmc_out.rc != 0 and 'exists' not in vbmc_out.stderr"
 
 - name: Start vbmc node ports
-  command: sudo /usr/bin/vbmc start {{ item.name }}
-  with_items: "{{ baremetal_ironic_nodes }}"
-  loop_control:
-    label: "{{ item.name }}"
+  command: sudo /usr/bin/vbmc start {{ ironic_node_details.name }}
+  register: vbmc_start_out
+  failed_when: "vbmc_start_out.rc != 0 and 'already running' not in vbmc_start_out.stderr"
diff --git a/roles/baremetal_provision/templates/baremetal_nodes.j2 b/roles/baremetal_provision/templates/baremetal_nodes.j2
deleted file mode 100644 (file)
index 480d205..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-{#
-This file is written with conditional check and for loop based indentation.
-It improved code readability. The output json is not pretty. Run cat <output.json> | python -m json.tool
-for pretty printing the same.
-#}
-
-{% macro generate_linux_bonding_options(options) -%}
-    {%- set mode_mapping = {'active-backup' : 'active-backup', 'lacp' : '802.3ad'} -%}
-    {%- set default_options = {
-                                'active-backup' : 'miimon=100',
-                                'lacp' : 'lacp_rate=fast miimon=100'
-                              } -%}
-    {%- for i in options.split() -%}
-        {%- set key, value = i.split('=') -%}
-        {%- if key == 'mode' -%}
-            {%- if default_options[value] -%}
-                {{ 'mode=' ~ mode_mapping[value] ~ ' ' ~ default_options[value] }}
-            {%- else -%}
-                {{ 'mode=' ~ mode_mapping[value] }}
-            {%- endif -%}
-        {%- endif -%}
-    {%- endfor -%}
-{%- endmacro %}
-
-{% macro generate_ovs_bonding_options(options) -%}
-    {%- set mode_mapping = {'active-backup' : 'active-backup', 'lacp' : 'balance-slb', 'lacp-layer34' : 'balance-tcp'} -%}
-    {%- set default_options = {
-                                'active-backup' : '',
-                                'lacp' : 'lacp=active other_config:lacp-time=fast other_config:bond-detect-mode=carrier',
-                                'lacp-layer34' : 'lacp=active other_config:lacp-time=fast other_config:bond-detect-mode=carrier'
-                              } -%}
-    {%- for i in options.split() -%}
-        {%- set key, value = i.split('=') -%}
-        {%- if key == 'mode' -%}
-            {%- if default_options[value] -%}
-                {{ 'bond_mode=' ~ mode_mapping[value] ~ ' ' ~ default_options[value] }}
-            {%- else -%}
-                {{ 'bond_mode=' ~ mode_mapping[value] }}
-            {%- endif -%}
-        {%- endif -%}
-    {%- endfor -%}
-{%- endmacro %}
-
-{% macro add_static_routes(routes) -%}
-    [
-    {%- for route in routes %}
-        {
-            "ip_netmask": "{{ route.to }}", "next_hop": "{{ route.via }}"
-        } {% if not loop.last %},{% endif %}
-    {%- endfor %}
-    ]
-{%- endmacro %}
-
-{%- set nfs_server_ip = hostvars[installation_controller]['networking']['infra_external']['ip'] %}
-{
-"ironic_nodes": [
-{% for host_key,host_value in hosts.iteritems() %}
-
-{%- set host_networking = hostvars[host_key]['networking'] %}
-{%- set host_network_profiles_list = hosts[host_key]['network_profiles'] %}
-{%- set host_network_profile_value = hostvars[host_key]['network_profiles'][host_network_profiles_list[0]] %}
-{%- set host_interface_net_mapping = host_network_profile_value['interface_net_mapping'] %}
-{%- set host_hdd_mapping = hostvars[host_key]['by_path_disks'] %}
-
-{%- set infra_bond = {'in_use': false} %}
-{%- if 'bonding_interfaces' in host_network_profile_value %}
-    {%- set host_bonding_interfaces = host_network_profile_value['bonding_interfaces'] %}
-{%- endif %}
-
-{%- set single_nic_setup = False %}
-{%- if 'provider_network_interfaces' in host_network_profile_value %}
-    {%- set host_provider_network_interfaces = host_network_profile_value['provider_network_interfaces'] %}
-    {%- if host_interface_net_mapping|length == 1 and host_provider_network_interfaces|length == 1 %}
-        {%- if host_interface_net_mapping.keys()[0] == host_provider_network_interfaces.keys()[0] %}
-            {%- set single_nic_setup = True %}
-        {%-endif %}
-    {%-endif %}
-{%-endif %}
-
-{%- set mtu = 1500 %}
-{%- if 'mtu' in host_networking['infra_internal'] %}
-    {%- set mtu = host_networking['infra_internal']['mtu'] %}
-{%- elif 'mtu' in host_networking %}
-    {%- set mtu = host_networking['mtu'] %}
-{%- endif %}
-
-{%- set phys_iface = {'mtu': 1500} %}
-{%- if 'vlan' in host_networking['infra_internal'] %}
-    {%- for iface,infras in host_interface_net_mapping.iteritems() %}
-        {%- if "infra_internal" in infras %}
-            {%- for infra in infras %}
-                {%- set tmp_mtu = 0 %}
-                {%- if 'mtu' in host_networking[infra] %}
-                    {%- set tmp_mtu = host_networking[infra]['mtu'] %}
-                {%- elif 'mtu' in host_networking %}
-                    {%- set tmp_mtu = host_networking['mtu'] %}
-                {%- endif %}
-                {%- if infra == 'cloud_tenant' %}
-                    {%- set tmp_mtu = tmp_mtu + 50 %}
-                {%- endif %}
-                {%- if tmp_mtu > phys_iface.mtu %}
-                    {%- if phys_iface.update({'mtu': tmp_mtu}) %}{%- endif %}
-                {%- endif %}
-            {%- endfor %}
-        {%- endif %}
-    {%- endfor %}
-{%- endif %}
-
-    {
-    "name": "{{ host_key }}",
-    "network_interface": "noop",
-    "nics":  [ {%- if 'mgmt_mac' in host_value %}
-                   {%- for mac_members in host_value['mgmt_mac'] %}
-                       {
-                       "mac": "{{ mac_members }}"
-                       }
-                       {%- if not loop.last %},{%- endif %}
-                   {%- endfor %}
-               {%- else: %}
-                   {
-                   "mac": "{{ hw_inventory_details[host_key]['mgmt_mac'] }}"
-                   }
-               {%- endif %}
-             ],
-    "driver_info": { "power": {
-        "os_net_config": {
-            "network_config": [
-            {%- if 'interface' in host_networking['infra_internal'] %}
-                {%- if not single_nic_setup %}
-                {%- if 'bonding_interfaces' in host_network_profile_value %}
-                    {%- for net_key,net_value in host_interface_net_mapping.iteritems() %}
-                        {%- if "bond" in net_key and "infra_internal" in net_value %}
-                        {
-                            "name": "{{net_key}}",
-                            "type": "linux_bond",
-                            "members": [
-                            {%- for member in host_bonding_interfaces[net_key] %}
-                            {
-                                {%- if 'bond' in host_networking['infra_internal']['interface'] %}
-                                    "mtu": {{mtu}},
-                                {%- else %}
-                                    "mtu": {{phys_iface['mtu']}},
-                                {%- endif %}
-                                "name": "{{ member }}",
-                                "type": "interface",
-                                "use_dhcp": false
-                            }    {%- if not loop.last %},{%- endif %}
-                            {% endfor %} ],
-                            {%- if 'linux_bonding_options' in host_network_profile_value %}
-                                "bonding_options": "{{ generate_linux_bonding_options(host_network_profile_value['linux_bonding_options']) }}",
-                            {%- endif %}
-                            {%- if 'bond' in host_networking['infra_internal']['interface'] %}
-                                "addresses": [ { "ip_netmask": "{{ host_networking['infra_internal']['ip'] }}/{{host_networking['infra_internal']['mask']}}" } ],
-                                "mtu": {{mtu}},
-                                {%- if 'routes' in host_networking['infra_internal'] %}
-                                    {%- set routes = host_networking['infra_internal']['routes'] %}
-                                    "routes": {{ add_static_routes(routes) }},
-                                {%- endif %}
-                            {%- else %}
-                                "mtu": {{phys_iface['mtu']}},
-                            {%- endif %}
-                            "use_dhcp": false
-                            {%- if infra_bond.update({'in_use': true}) %}{%- endif %}
-                        },
-                        {%- endif %}
-                    {%- endfor %}
-                {%- endif %}
-                {%- if 'vlan' in host_networking['infra_internal'] %}
-                    {
-                    "type": "vlan",
-                    "addresses": [ { "ip_netmask": "{{ host_networking['infra_internal']['ip'] }}/{{host_networking['infra_internal']['mask']}}" } ],
-                    "vlan_id": {{ host_networking['infra_internal']['vlan'] }},
-                    {%- for net_key,net_value in host_interface_net_mapping.iteritems() %}
-                        {%- if "infra_internal" in net_value %}
-                            "device": "{{net_key}}",
-                        {%- endif %}
-                    {%- endfor %}
-                    "mtu": {{mtu}},
-                    {%- if 'routes' in host_networking['infra_internal'] %}
-                        {%- set routes = host_networking['infra_internal']['routes'] %}
-                        "routes": {{ add_static_routes(routes) }},
-                    {%- endif %}
-                    "use_dhcp": false
-                    }
-                    {%- if not infra_bond.in_use %}
-                        ,
-                        {
-                        {%- for net_key,net_value in host_interface_net_mapping.iteritems() %}
-                            {%- if "infra_internal" in net_value %}
-                                "name": "{{net_key}}",
-                            {%- endif %}
-                        {%- endfor %}
-                        "type": "interface",
-                        "mtu": {{phys_iface['mtu']}},
-                        "use_dhcp": false
-                        }
-                    {%- endif %}
-                {%- elif not infra_bond.in_use %}
-                    {
-                    "name": "{{host_networking['infra_internal']['interface']}}",
-                    "type": "interface",
-                    "addresses": [ { "ip_netmask": "{{ host_networking['infra_internal']['ip'] }}/{{host_networking['infra_internal']['mask']}}" } ],
-                    "mtu": {{mtu}},
-                    {%- if 'routes' in host_networking['infra_internal'] %}
-                        {%- set routes = host_networking['infra_internal']['routes'] %}
-                        "routes": {{ add_static_routes(routes) }},
-                     {%- endif %}
-                    "use_dhcp": false
-                    }
-                {%- endif %}
-                {%- else %}{#- if not single_nic_setup -#}
-                    {
-                    "name": "br-pro0",
-                    "type": "ovs_bridge",
-                    "members": [
-                        {
-                        "mtu": {{phys_iface['mtu']}},
-                        {%- set iface = host_interface_net_mapping.keys()[0] %}
-                        {%- if 'bond' in iface %}
-                            {%- for bond_iface,bond_value in host_bonding_interfaces.iteritems() if bond_iface == iface %}
-                                {%- if 'ovs_bonding_options' in  host_network_profile_value %}
-                                    "ovs_options": "{{ generate_ovs_bonding_options(host_network_profile_value['ovs_bonding_options']) }}",
-                                {%- endif %}
-                                "name": "{{iface}}",
-                                "type": "ovs_bond",
-                                "members": [ {% for member in bond_value %}
-                                    {
-                                    "name": "{{ member }}",
-                                    "type": "interface",
-                                    "mtu": {{phys_iface['mtu']}},
-                                    "use_dhcp": false
-                                    }
-                                    {% if not loop.last %},{% endif %}
-                                {%- endfor %}
-                                ],
-                            {%- endfor %}
-                        {%- else %}
-                            "name": "{{iface}}",
-                            "type": "interface",
-                        {%- endif %}
-                        "use_dhcp": false
-                        }
-                        ,
-                        {
-                        {%- set infra = host_networking['infra_internal'] %}
-                        "type": "vlan",
-                        "vlan_id": {{ infra['vlan'] }},
-                        "addresses": [ { "ip_netmask": "{{ infra['ip'] }}/{{infra['mask']}}" } ],
-                        "mtu": {{mtu}},
-                        {%- if 'routes' in infra %}
-                            {%- set routes = infra['routes'] %}
-                            "routes": {{ add_static_routes(routes) }},
-                        {%- endif %}
-                        "use_dhcp": false
-                        }
-                    ]
-                    }
-                {%- endif %}{#- if not single_nic_setup -#}
-            {%- endif %}
-            ]
-        },
-    "provisioning_server": "{{nfs_server_ip}}",
-    "provisioning_server_http_port": "{{golden_image_http_port}}",
-    "virtmedia_deploy_iso": "file:///opt/images/ironic-deploy.iso",
-    {% if virtual_env == true %}
-        "ssh_address": "{{ host_value['hwmgmt']['address'] }}",
-        "ssh_key_contents": "{{ '{{' }} lookup('file', '/etc/userconfig/id_rsa') {{ '}}' }}",
-        "ssh_username": "{{ host_value['hwmgmt']['user'] }}",
-        "ipmi_address": "{{hostvars[installation_controller]['networking']['infra_internal']['ip']}}",
-        "ipmi_username": "admin",
-        "ipmi_password": "password",
-        "ipmi_port": "{{ hosts[host_key]['vbmc_port'] }}"
-        } },
-        "driver": "ssh_virtmedia",
-        "properties": { "capabilities": "boot_option:local", "cpu_arch": "x86_64", "cpus": 8, "disk_size": 40, "ram": 16384, "root_device":{ "by_path": "{{ host_hdd_mapping['os']}}" } }
-    {%- else %}
-        "ipmi_address": "{{ host_value['hwmgmt']['address'] }}",
-        "ipmi_password": "{{ host_value['hwmgmt']['password'] }}",
-        "ipmi_username": "{{ host_value['hwmgmt']['user'] }}",
-        "product_family": "{{ hw_inventory_details[host_key]['product_family'] }}",
-        "vendor": "{{ hw_inventory_details[host_key]['vendor'] }}"
-    }
-},
-        "driver": "ipmi_virtmedia",
-        "properties": { "capabilities": "boot_option:local", "cpu_arch": "x86_64", "cpus": 8, "disk_size": 40, "ram": 16384, "root_device":{ {% if host_hdd_mapping['os'] != "/dev/sda" %} "by_path": "{{ host_hdd_mapping['os']}}" {% else %} "name": "{{ host_hdd_mapping['os']}}" {% endif %} } }
-    {% endif %}
-    }
-    {% if not loop.last %},{% endif %}
-{%- endfor %}
-]
-}
index 1985655..9134aa3 100644 (file)
@@ -1,3 +1,20 @@
+# Copyright 2019 Nokia
+
+# 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.
+
+error_log /var/log/guest-img-nginx-error.log;
+pid /run/guest-img-nginx.pid;
+
 http{
     server {
             listen {{golden_image_http_port}};
index 6c47cb3..03814f7 100644 (file)
@@ -1,8 +1,8 @@
 {
     "availability_zone": "",
-    "hostname": "{{item[0].name}}",
+    "hostname": "{{ironic_node_details.name}}",
     "launch_index": 0,
-    "name": "{{item[0].name}}",
+    "name": "{{ironic_node_details.name}}",
     "uuid": ""
 }
 
index 16dbace..69b6967 100644 (file)
@@ -17,7 +17,7 @@ users:
   - name: "{{users.admin_user_name}}"
     sudo: ['ALL=(ALL) NOPASSWD:ALL']
     ssh-authorized-keys:
-      - "{{ lookup('file', ansible_env.PWD + '/.ssh/id_rsa.pub') }}"
+      - "{{ lookup('file', home_dir + '/.ssh/id_rsa.pub') }}"
     passwd: {{users.admin_user_password}}
     lock_passwd: False
 
@@ -29,6 +29,6 @@ Content-Disposition: attachment; filename="boothook.sh"
 
 #!/bin/bash
 mkdir -p /etc/os-net-config/
-echo '{{lookup('file', '/tmp/'+item[0].name+'_config.yaml')}}' > /etc/os-net-config/config.yaml
+echo '{{lookup('file', '/tmp/'+ironic_node_details.name+'_config.yaml')}}' > /etc/os-net-config/config.yaml
 /usr/bin/os-net-config
 --===============9156907225490855809==--