diff --git a/ansible/action_plugins/tenks_schedule.py b/ansible/action_plugins/tenks_schedule.py index 275f8ba..62973dd 100644 --- a/ansible/action_plugins/tenks_schedule.py +++ b/ansible/action_plugins/tenks_schedule.py @@ -43,11 +43,14 @@ class ActionModule(ActionBase): hostname of the hypervisor to which they are scheduled. """ result = super(ActionModule, self).run(tmp, task_vars) + # Initialise our return dict. + result['result'] = {} del tmp # tmp no longer has any effect self._validate_vars(task_vars) nodes = [] idx = 0 + hypervisor_names = task_vars['hypervisor_vars'].keys() for typ, cnt in six.iteritems(task_vars['specs']): for _ in six.moves.range(cnt): node = deepcopy(task_vars['node_types'][typ]) @@ -59,12 +62,15 @@ class ActionModule(ActionBase): vol['name'] = "%s%d" % (task_vars['vol_name_prefix'], vol_idx) nodes.append(node) + # Perform round-robin scheduling with node index modulo number + # of hypervisors. + hyp_name = hypervisor_names[idx % len(hypervisor_names)] + try: + result['result'][hyp_name].append(node) + except KeyError: + # This hypervisor doesn't yet have any scheduled nodes. + result['result'][hyp_name] = [node] idx += 1 - - # TODO(w-miller): currently we just arbitrarily schedule all nodes to - # the first hypervisor. Improve this algorithm to make it more - # sophisticated. - result['result'] = {task_vars['hypervisor_vars'].keys()[0]: nodes} return result def _validate_vars(self, task_vars): diff --git a/ansible/deploy_hosts.yml b/ansible/deploy_hosts.yml index a8cbbdf..a5e59ed 100644 --- a/ansible/deploy_hosts.yml +++ b/ansible/deploy_hosts.yml @@ -24,4 +24,5 @@ name: virtualbmc-daemon vars: vbmcd_virtualenv_path: "{{ virtualenv_path }}" - vbmcd_python_upper_contraints_url: "{{ python_upper_constraints_url }}" + vbmcd_python_upper_constraints_url: >- + {{ python_upper_constraints_url }} diff --git a/ansible/group_vars/all b/ansible/group_vars/all new file mode 100644 index 0000000..6eee2da --- /dev/null +++ b/ansible/group_vars/all @@ -0,0 +1,9 @@ +--- +# Path to virtualenv used to install Python requirements. If a virtualenv does +# not exist at this location, one will be created. +virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}" + +# The URL of the upper constraints file to pass to pip when installing Python +# packages. +python_upper_constraints_url: >- + https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt diff --git a/ansible/group_vars/hypervisors b/ansible/group_vars/hypervisors index 4b7eb96..dc6dcad 100644 --- a/ansible/group_vars/hypervisors +++ b/ansible/group_vars/hypervisors @@ -6,15 +6,6 @@ physnet_mappings: {} system_requirements: - python-virtualenv -# Path to virtualenv used to install Python requirements. If a virtualenv does -# not exist at this location, one will be created. -virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}" - -# The URL of the upper constraints file to pass to pip when installing Python -# packages. -python_upper_constraints_url: >- - https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt - # Naming scheme for bridges created by tenks for physical networks is # {{ bridge_prefix + i }}, where `i` is the index of the physical network in # physnet_mappings (sorted alphabetically by key). diff --git a/ansible/physical_network.yml b/ansible/physical_network.yml index f806a55..4f30b95 100644 --- a/ansible/physical_network.yml +++ b/ansible/physical_network.yml @@ -13,7 +13,8 @@ source_type: direct - name: Get source interface details - command: ip -details link show {{ source_interface }} + # NOTE(w-miller): The `ip` command may not be in $PATH, so use the full path. + command: /usr/sbin/ip -details link show {{ source_interface }} register: if_details changed_when: false @@ -69,6 +70,7 @@ type=patch options:peer={{ veth_prefix + tenks_bridge + veth_bridge_source_suffix }} + become: true - name: Create patch port on source bridge openvswitch_port: @@ -79,9 +81,11 @@ type=patch options:peer={{ veth_prefix + tenks_bridge + veth_bridge_ovs_suffix }} + become: true - name: Plug source interface into Tenks bridge when: source_type == 'direct' openvswitch_port: bridge: "{{ tenks_bridge }}" port: "{{ source_interface }}" + become: true diff --git a/ansible/roles/ironic-enrolment/tasks/main.yml b/ansible/roles/ironic-enrolment/tasks/main.yml index 8196d24..875f4b7 100644 --- a/ansible/roles/ironic-enrolment/tasks/main.yml +++ b/ansible/roles/ironic-enrolment/tasks/main.yml @@ -1,7 +1,17 @@ --- +# This is useful to get a uniquely generated temporary path. +- name: Create temporary file for pip requirements + tempfile: + register: req_file + +- name: Copy requirements file to temporary location + copy: + src: requirements.txt + dest: "{{ req_file.path }}" + - name: Ensure Python requirements are installed pip: - requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}" + requirements: "{{ req_file.path }}" extra_args: >- -c {{ ironic_python_upper_constraints_url }} virtualenv: "{{ ironic_virtualenv_path }}" diff --git a/ansible/roles/virtualbmc-daemon/tasks/main.yml b/ansible/roles/virtualbmc-daemon/tasks/main.yml index c850a50..1071e17 100644 --- a/ansible/roles/virtualbmc-daemon/tasks/main.yml +++ b/ansible/roles/virtualbmc-daemon/tasks/main.yml @@ -6,11 +6,21 @@ loop: "{{ vbmcd_packages }}" become: true +# This is useful to get a uniquely generated temporary path. +- name: Create temporary file for pip requirements + tempfile: + register: req_file + +- name: Copy requirements file to temporary location + copy: + src: requirements.txt + dest: "{{ req_file.path }}" + - name: Ensure Python requirements are installed pip: - requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}" + requirements: "{{ req_file.path }}" extra_args: >- - -c {{ vbmcd_python_upper_contraints_url }} + -c {{ vbmcd_python_upper_constraints_url }} virtualenv: "{{ vbmcd_virtualenv_path }}" - name: Ensure Virtual BMC systemd service is configured