CSIT-1477: add 1n_tx2 VPP Device
[csit.git] / resources / tools / testbed-setup / ansible / roles / common / tasks / main.yaml
index 6844358..96e3f83 100644 (file)
@@ -1,29 +1,61 @@
 ---
 # file: roles/common/tasks/main.yaml
 
-- 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: 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: Ubuntu specific
-  import_tasks: ubuntu.yaml
-  when: ansible_distribution|lower == 'ubuntu'
+- 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
 
-- name: Set hostname
-  hostname:
-      name: '{{ hostname }}'
-  tags: set-hostname
+- meta: flush_handlers
 
-- name: Ensure hostname is in /etc/hosts
+- name: Add permanent proxy settings
   lineinfile:
-    path: '/etc/hosts'
-    regexp: '^{{ ansible_default_ipv4.address }}.+$'
-    line: '{{ ansible_default_ipv4.address }} {{ hostname }}.{{ name_servers_search }}'
-  tags: set-hostname
+    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:
 
 - name: Copy grub file
   template:
-   src: 'files/grub'
+   src: 'files/grub_{{ ansible_machine }}'
    dest: '/etc/default/grub'
    owner: 'root'
    group: 'root'
    mode: '644'
-  notify: ['Update GRUB']
+  notify:
+    - 'Update GRUB'
+    - 'Reboot server'
   tags: copy-grub
 
-- 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
+- meta: flush_handlers