--- # Facts may not be available for the Ansible control host, so read the OS # release manually. - name: Check the OS release local_action: module: shell . /etc/os-release && echo $ID changed_when: False register: ip_allocation_os_release - name: Include RedHat family-specific variables include_vars: "RedHat.yml" when: ip_allocation_os_release.stdout in ['centos', 'fedora', 'rhel'] - name: Include Debian family-specific variables include_vars: "Debian.yml" when: ip_allocation_os_release.stdout in ['debian', 'ubuntu'] # 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: installed use: "{{ ip_allocation_package_manager }}" become: True with_items: "{{ ip_allocation_package_dependencies }}" run_once: True - name: Ensure IP addresses are allocated 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 }}"