--- - block: - name: Include OS family-specific variables include_vars: "{{ hostvars.localhost.ansible_os_family }}.yml" # Note: Currently we install these using the system package manager rather than # pip to a virtualenv. This is because Yum is required elsewhere and cannot # easily be installed in a virtualenv. - name: Ensure package dependencies are installed local_action: module: package name: "{{ item }}" state: present use: "{{ ip_allocation_package_manager }}" become: True with_items: "{{ ip_allocation_package_dependencies }}" run_once: True when: - hostvars.localhost.ansible_os_family == 'RedHat' - hostvars.localhost.ansible_distribution_major_version | int == 7 - name: Ensure IP addresses are allocated vars: # NOTE(mgoddard): Use the Python interpreter used to run ansible-playbook, # since this has Python dependencies available to it (PyYAML). On CentOS 7 # we use the system Python to ensure that we can import SELinux bindings. ansible_python_interpreter: >- {{ '/usr/libexec/platform-python' if hostvars.localhost.ansible_os_family == 'RedHat' and hostvars.localhost.ansible_distribution_major_version | int == 7 else ansible_playbook_python }} local_action: module: ip_allocation allocation_file: "{{ ip_allocation_filename }}" hostname: "{{ ip_allocation_hostname }}" net_name: "{{ item.net_name }}" cidr: "{{ item.cidr }}" allocation_pool_start: "{{ item.allocation_pool_start | default(omit) }}" allocation_pool_end: "{{ item.allocation_pool_end | default(omit) }}" with_items: "{{ ip_allocations }}"