X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Ftestbed-setup%2Fansible%2Froles%2Fcommon%2Ftasks%2Fmain.yaml;h=96e3f83e1b681812f198a743e90b10581d2c14f7;hp=e16a6a7356c4870ac4c5c30048098a82025d9e07;hb=46efda9bd3a32cfe9944cb421ae3e2a3978bf9fc;hpb=3a14297dca576dd7e2c9f09d84bf0f5cf58c1938 diff --git a/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml index e16a6a7356..96e3f83e1b 100644 --- a/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml +++ b/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml @@ -1,46 +1,90 @@ ---- -# file: roles/common/tasks/main.yaml - -- name: Ubuntu specific - import_tasks: ubuntu_x86_64.yaml - when: ansible_distribution|lower == 'ubuntu' and ansible_machine == 'x86_64' - -- name: Set hostname - hostname: - name: '{{ hostname }}' - tags: set-hostname - -- name: Ensure hostname is in /etc/hosts - lineinfile: - path: '/etc/hosts' - regexp: '^{{ ansible_default_ipv4.address }}.+$' - line: '{{ ansible_default_ipv4.address }} {{ hostname }}.linuxfoundation.org' - tags: set-hostname - -- name: Set sudoers - 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 - 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' - dest: '/etc/default/grub' - owner: 'root' - group: 'root' - mode: '644' - notify: ['Update GRUB'] - tags: copy-grub +--- +# 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: 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' + +- 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