main.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. ---
  2. # Loading vars
  3. - name: Add the OS specific varibles
  4. include_vars: "{{ ansible_os_family }}.yml"
  5. # Install DHCP server
  6. - name: Install the required packages in Redhat derivatives
  7. yum: name={{ dhcp_server_package }} state=installed
  8. when: ansible_os_family == 'RedHat'
  9. - name: Install the required packages in Debian derivatives
  10. apt: name={{ dhcp_server_package }} state=installed update_cache=yes
  11. when: ansible_os_family == 'Debian'
  12. - name: Install the required packages in ArchLinux derivatives
  13. pacman: name={{ dhcp_server_package }} state=installed update_cache=yes
  14. when: ansible_os_family == 'Archlinux'
  15. # Generate configuration
  16. - name: Generate dhcpd.conf
  17. template: src=dhcpd.conf.j2 dest={{ dhcp_server_config }} owner=root group=root mode=0644
  18. notify:
  19. - restart dhcpd
  20. # Generate service configuration
  21. - name: Generate DHCP service conf
  22. template: src=service.conf.{{ ansible_os_family }}.j2 dest={{ dhcp_service_config }} owner=root group=root
  23. when: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'
  24. notify:
  25. - restart dhcpd
  26. # Enable DHCP server
  27. - name: Start the dhcp services DHCP
  28. service: name={{ dhcp_service }} state=started enabled=yes