From 1236d9343ec16b4166f923bd62e3153ad86fd350 Mon Sep 17 00:00:00 2001 From: Andrey Shestakov Date: Thu, 15 Dec 2016 15:07:19 +0200 Subject: [PATCH] Allow deploy-dynamic on remote host This change allows deploy nodes on remote server with installed Ironic. Change-Id: If0625ee5a4a2271452305bb3e079ad075b9c71b1 --- README.rst | 24 +++++++++++++++++++ playbooks/deploy-dynamic.yaml | 9 +++---- .../tasks/main.yml | 4 ++-- .../tasks/main.yml | 8 +++---- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 32a6e616c..49dc547ec 100644 --- a/README.rst +++ b/README.rst @@ -359,6 +359,18 @@ source, and then executing the enrollment playbook.:: export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json ansible-playbook -vvvv -i inventory/bifrost_inventory.py enroll-dynamic.yaml +When ironic is installed on remote server, a regular ansible inventory +with a target server should be added to ansible. This can be achieved by +specifying a directory with files, each file in that directory will be part of +the ansible inventory. Refer to ansible documentation +http://docs.ansible.com/ansible/intro_dynamic_inventory.html#using-inventory-directories-and-multiple-inventory-sources + +:: + + export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json + rm inventory/*.example + ansible-playbook -vvvv -i inventory/ enroll-dynamic.yaml + Note that enrollment is a one-time operation. The Ansible module *does not* synchronize data for existing nodes. You should use the ironic CLI to do this manually at the moment. @@ -382,6 +394,18 @@ To utilize the newer dynamic inventory based deployment:: export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json ansible-playbook -vvvv -i inventory/bifrost_inventory.py deploy-dynamic.yaml +When ironic is installed on remote server, a regular ansible inventory +with a target server should be added to ansible. This can be achieved by +specifying a directory with files, each file in that directory will be part of +the ansible inventory. Refer to ansible documentation +http://docs.ansible.com/ansible/intro_dynamic_inventory.html#using-inventory-directories-and-multiple-inventory-sources + +:: + + export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json + rm inventory/*.example + ansible-playbook -vvvv -i inventory/ deploy-dynamic.yaml + Note:: Before running the above command, ensure that the value for `ssh_public_key_path` in diff --git a/playbooks/deploy-dynamic.yaml b/playbooks/deploy-dynamic.yaml index 8cb10cffd..aa027b408 100644 --- a/playbooks/deploy-dynamic.yaml +++ b/playbooks/deploy-dynamic.yaml @@ -1,13 +1,10 @@ --- -- hosts: localhost - connection: local - name: "Collect facts" - become: no - gather_facts: yes - hosts: baremetal name: "Create configuration drive files and deploy machines from inventory" become: no - connection: local + gather_facts: no roles: - role: bifrost-configdrives-dynamic + delegate_to: "{{ groups['target'][0] if groups['target'] is defined else 'localhost' }}" - role: bifrost-deploy-nodes-dynamic + delegate_to: "{{ groups['target'][0] if groups['target'] is defined else 'localhost' }}" diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index de6790118..4e5ed7349 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -22,7 +22,7 @@ when: ssh_public_key is undefined - name: "Make temporary folder to build configdrive" - local_action: command mktemp -d + command: mktemp -d register: variable_configdrive_location - name: "Make metadata folder - /openstack/{{ metadata_version }}" @@ -80,7 +80,7 @@ name: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/content/" - name: "Write network Debian style interface template" - local_action: template src=interfaces.j2 dest={{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/content/0000 + template: src=interfaces.j2 dest={{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/content/0000 when: write_interfaces_file | bool == true - name: "Check if mkisofs is available" diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index d3e0c6fdb..c4339413b 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -17,6 +17,9 @@ # the pass-through could mean that the user could deploy # things that are not directly accessible or reasonable # to be inspected. +- name: "Obtain setup facts" + setup: + - name: "If in noauth mode, unset authentication parameters." set_fact: auth_type: None @@ -44,7 +47,6 @@ owner: root group: root mode: 0644 - delegate_to: localhost when: inventory_dhcp | bool == true become: yes - name: "Setup DNS address for nodes." @@ -54,7 +56,6 @@ owner: root group: root mode: 0644 - delegate_to: localhost when: inventory_dns | bool == true become: yes - name: "Sending dnsmasq HUP" @@ -74,10 +75,9 @@ instance_info: "{{ instance_info }}" wait: "{{ wait_for_node_deploy }}" timeout: " {{ wait_timeout | default(1800) }}" - delegate_to: localhost when: instance_info is defined and instance_info | to_json != '{}' - name: "Collect the checksum of the deployment image." - local_action: stat path={{deploy_image}} + stat: path={{deploy_image}} register: test_deploy_image when: instance_info is not defined or ( instance_info is defined and instance_info | to_json == '{}' ) - name: "Error if deploy_image is not present, and instance_info is not defined"