----\r
-# file: roles/common/tasks/main.yaml\r
-\r
-- name: Ubuntu specific\r
- import_tasks: ubuntu_x86_64.yaml\r
- when: ansible_distribution|lower == 'ubuntu' and ansible_machine == 'x86_64'\r
-\r
-- name: Set hostname\r
- hostname:\r
- name: '{{ hostname }}'\r
- tags: set-hostname\r
-\r
-- name: Ensure hostname is in /etc/hosts\r
- lineinfile:\r
- path: '/etc/hosts'\r
- regexp: '^{{ ansible_default_ipv4.address }}.+$'\r
- line: '{{ ansible_default_ipv4.address }} {{ hostname }}.linuxfoundation.org'\r
- tags: set-hostname\r
-\r
-- name: Set sudoers\r
- lineinfile:\r
- path: '/etc/sudoers'\r
- state: 'present'\r
- regexp: '^%admin ALL='\r
- line: '%admin ALL=(ALL) ALL'\r
- validate: '/usr/sbin/visudo -cf %s'\r
- tags: set-sudoers\r
-\r
-- name: Set sudoers\r
- lineinfile:\r
- path: '/etc/sudoers'\r
- state: 'present'\r
- regexp: '^%sudo'\r
- line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'\r
- validate: '/usr/sbin/visudo -cf %s'\r
- tags: set-sudoers\r
-\r
-- name: Copy grub file\r
- template:\r
- src: 'files/grub'\r
- dest: '/etc/default/grub'\r
- owner: 'root'\r
- group: 'root'\r
- mode: '644'\r
- notify: ['Update GRUB']\r
- tags: copy-grub\r
+---
+# file: roles/common/tasks/main.yaml
+
+- name: Ensure the system exists in Cobbler
+ cobbler_system:
+ host: '{{ cobbler_hostname }}'
+ port: 60080
+ interfaces:
+ br1:
+ ipaddress: '{{ ansible_default_ipv4.address }}'
+ macaddress: '{{ ansible_default_ipv4.macaddress }}'
+ name: '{{ hostname }}'
+ password: '{{ cobbler_password }}'
+ properties:
+ hostname: '{{ hostname }}'
+ gateway: '{{ ansible_default_ipv4.gateway }}'
+ profile: '{{ cobbler_profile }}'
+ name_servers: '{{ name_servers }}'
+ name_servers_search: '{{ name_servers_search }}'
+ kickstart: '/var/lib/cobbler/kickstarts/{{ cobbler_profile }}.seed'
+ kernel_options: '"interface={{ ansible_default_ipv4.interface }}"'
+ netboot_enabled: yes
+ username: '{{ cobbler_username }}'
+ use_ssl: no
+ validate_certs: no
+ when: provision_enabled
+ delegate_to: localhost
+ tags: cobbler-include
+
+- name: Commit Cobbler changes
+ cobbler_sync:
+ host: '{{ cobbler_hostname }}'
+ port: 60080
+ password: '{{ cobbler_password }}'
+ username: '{{ cobbler_username }}'
+ use_ssl: no
+ validate_certs: no
+ run_once: yes
+ when: provision_enabled
+ delegate_to: localhost
+ register: __included_in_cobbler
+ notify:
+ - 'Boot from network'
+ - 'Reboot server'
+ tags: cobbler-include
+
+- meta: flush_handlers
+
+- name: Copy netplan network config file
+ template:
+ src: 'files/netplan_config'
+ dest: '/etc/netplan/01-netcfg.yaml'
+ owner: 'root'
+ group: 'root'
+ mode: '0644'
+ tags: copy-interface-file
+
+- name: Add permanent proxy settings
+ lineinfile:
+ path: '/etc/environment'
+ state: 'present'
+ line: '{{ item.key }}={{ item.value }}'
+ with_dict: '{{ proxy_env }}'
+ when: proxy_env is defined
+
+- name: Install distribution - release - machine prerequisites
+ include_tasks: '{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml'
+ tags: [ install-csit-dependencies, copy-apt-sources ]
+
+- name: Set sudoers admin
+ lineinfile:
+ path: '/etc/sudoers'
+ state: 'present'
+ regexp: '^%admin ALL='
+ line: '%admin ALL=(ALL) ALL'
+ validate: '/usr/sbin/visudo -cf %s'
+ tags: set-sudoers
+
+- name: Set sudoers sudo
+ lineinfile:
+ path: '/etc/sudoers'
+ state: 'present'
+ regexp: '^%sudo'
+ line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
+ validate: '/usr/sbin/visudo -cf %s'
+ tags: set-sudoers
+
+- name: Copy grub file
+ template:
+ src: 'files/grub_{{ ansible_machine }}'
+ dest: '/etc/default/grub'
+ owner: 'root'
+ group: 'root'
+ mode: '644'
+ notify:
+ - 'Update GRUB'
+ - 'Reboot server'
+ tags: copy-grub
+
+- meta: flush_handlers