Execute network setup against octavia_service_setup_host

In order to reduce the packages required to pip install on to the hosts,
we use service delegation to octavia_service_setup_host so that instead
of installing software on the target host, and putting credentials on
every target host, we isolate the software and credentials to a single
host.

In this patch we make the network tasks execute using clouds.yaml so that
we do not need to expose the credentials in the task (it will leak the
credentials in vebose mode or on failure). We also set the tasks to execute
on octavia_service_setup_host so that we do not need as much software
installed on the target host.

There are any other tasks in the role which need updating before we can
eliminate the octavia_requires_pip_packages, but for the sake of keeping
the patch smaller and easier to review they will be done in follow up
patches.

Change-Id: I07f0907a3841f81c0f76a25ce89de9f1145c35f9
This commit is contained in:
Jesse Pretorius 2018-08-02 09:08:50 +01:00
parent 98f54c5386
commit 02d94949a8
2 changed files with 53 additions and 64 deletions

View File

@ -60,6 +60,7 @@
- octavia-install - octavia-install
- include: octavia_mgmt_network.yml - include: octavia_mgmt_network.yml
run_once: true
when: when:
- octavia_neutron_management_network_uuid is not defined - octavia_neutron_management_network_uuid is not defined
- octavia_neutron_management_network_name is defined - octavia_neutron_management_network_name is defined

View File

@ -13,70 +13,58 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Create mgmt network # We set the python interpreter to the ansible runtime venv if
os_network: # the delegation is to localhost so that we get access to the
auth: # appropriate python libraries in that venv. If the delegation
auth_url: "{{ keystone_service_adminurl }}" # is to another host, we assume that it is accessible by the
username: "{{ octavia_service_user_name }}" # system python instead.
password: "{{ octavia_service_password }}" - name: Setup the network
project_name: "{{ octavia_service_project_name }}" delegate_to: "{{ octavia_service_setup_host }}"
user_domain_name: "{{ octavia_service_user_domain_id }}" vars:
project_domain_name: "{{ octavia_service_project_domain_id }}" ansible_python_interpreter: >-
endpoint_type: "{{ octavia_ansible_endpoint_type }}" {{ (octavia_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable']) }}
region_name: "{{ octavia_service_region }}" block:
validate_certs: "{{ keystone_service_adminuri_insecure }}" - name: Create mgmt network
auth_type: "{{ octavia_keystone_auth_plugin }}" os_network:
state: present cloud: default
name: "{{ octavia_neutron_management_network_name }}" state: present
provider_network_type: "{{ octavia_provider_network_type }}" region_name: "{{ octavia_service_region }}"
provider_physical_network: "{{ octavia_provider_network_name }}" name: "{{ octavia_neutron_management_network_name }}"
provider_segmentation_id: "{{ octavia_provider_segmentation_id | default(omit) }}" provider_network_type: "{{ octavia_provider_network_type }}"
run_once: True provider_physical_network: "{{ octavia_provider_network_name }}"
when: provider_segmentation_id: "{{ octavia_provider_segmentation_id | default(omit) }}"
- octavia_service_net_setup endpoint_type: admin
verify: "{{ not keystone_service_adminuri_insecure }}"
when:
- octavia_service_net_setup | bool
- name: Ensure mgmt subnet exists - name: Ensure mgmt subnet exists
os_subnet: os_subnet:
auth: cloud: default
auth_url: "{{ keystone_service_adminurl }}" state: present
username: "{{ octavia_service_user_name }}" region_name: "{{ octavia_service_region }}"
password: "{{ octavia_service_password }}" network_name: "{{ octavia_neutron_management_network_name }}"
project_name: "{{ octavia_service_project_name }}" name: "{{ octavia_neutron_management_network_name }}-subnet"
user_domain_name: "{{ octavia_service_user_domain_id }}" cidr: "{{ octavia_management_net_subnet_cidr }}"
project_domain_name: "{{ octavia_service_project_domain_id }}" enable_dhcp: "{{ octavia_management_net_dhcp }}"
endpoint_type: "{{ octavia_ansible_endpoint_type }}" allocation_pool_start: "{{ octavia_management_net_subnet_allocation_pools.split('-')[0] | default(omit) }}"
region_name: "{{ octavia_service_region }}" allocation_pool_end: "{{ octavia_management_net_subnet_allocation_pools.split('-')[1] | default(omit) }}"
validate_certs: "{{ keystone_service_adminuri_insecure }}" endpoint_type: admin
auth_type: "{{ octavia_keystone_auth_plugin }}" verify: "{{ not keystone_service_adminuri_insecure }}"
state: present when:
network_name: "{{ octavia_neutron_management_network_name }}" - octavia_service_net_setup | bool
name: "{{ octavia_neutron_management_network_name }}-subnet"
cidr: "{{ octavia_management_net_subnet_cidr }}"
enable_dhcp: "{{ octavia_management_net_dhcp }}"
allocation_pool_start: "{{ octavia_management_net_subnet_allocation_pools.split('-')[0] | default(omit) }}"
allocation_pool_end: "{{ octavia_management_net_subnet_allocation_pools.split('-')[1] | default(omit) }}"
run_once: True
when:
- octavia_service_net_setup
- name: Get neutron network - name: Get neutron network
os_networks_facts: os_networks_facts:
auth: cloud: default
auth_url: "{{ keystone_service_adminurl }}" region_name: "{{ octavia_service_region }}"
username: "{{ octavia_service_user_name }}" name: "{{ octavia_neutron_management_network_name }}"
password: "{{ octavia_service_password }}" endpoint_type: admin
project_name: "{{ octavia_service_project_name }}" verify: "{{ not keystone_service_adminuri_insecure }}"
user_domain_name: "{{ octavia_service_user_domain_id }}"
project_domain_name: "{{ octavia_service_project_domain_id }}"
endpoint_type: "{{ octavia_ansible_endpoint_type }}"
region_name: "{{ octavia_service_region }}"
validate_certs: "{{ keystone_service_adminuri_insecure }}"
auth_type: "{{ octavia_keystone_auth_plugin }}"
name: "{{ octavia_neutron_management_network_name }}"
- name: Set provisioning UUID fact - name: Set provisioning UUID fact
set_fact: set_fact:
octavia_neutron_management_network_uuid: "{{ openstack_networks[0].id }}" octavia_neutron_management_network_uuid: "{{ openstack_networks[0].id }}"
when: when:
- octavia_neutron_management_network_uuid is not defined - octavia_neutron_management_network_uuid is not defined
- octavia_neutron_management_network_name is defined - octavia_neutron_management_network_name is defined