Ansible: Mellanox install
[csit.git] / resources / tools / testbed-setup / ansible / roles / common / tasks / main.yaml
1 ---
2 # file: roles/common/tasks/main.yaml
3
4 - name: Ensure the system exists in Cobbler
5   cobbler_system:
6     host: '{{ cobbler_hostname }}'
7     port: 60080
8     interfaces:
9       br1:
10         ipaddress: '{{ ansible_default_ipv4.address }}'
11         macaddress: '{{ ansible_default_ipv4.macaddress }}'
12     name: '{{ hostname }}'
13     password: '{{ cobbler_password }}'
14     properties:
15       hostname: '{{ hostname }}'
16       gateway: '{{ ansible_default_ipv4.gateway }}'
17       profile: '{{ cobbler_profile }}'
18       name_servers: '{{ name_servers }}'
19       name_servers_search: '{{ name_servers_search }}'
20       kickstart: '/var/lib/cobbler/kickstarts/{{ cobbler_profile }}.seed'
21       kernel_options: '"interface={{ ansible_default_ipv4.interface }}"'
22       netboot_enabled: yes
23     username: '{{ cobbler_username }}'
24     use_ssl: no
25     validate_certs: no
26   when: provision_enabled
27   delegate_to: localhost
28   tags: cobbler-include
29
30 - name: Commit Cobbler changes
31   cobbler_sync:
32     host: '{{ cobbler_hostname }}'
33     port: 60080
34     password: '{{ cobbler_password }}'
35     username: '{{ cobbler_username }}'
36     use_ssl: no
37     validate_certs: no
38   run_once: yes
39   when: provision_enabled
40   delegate_to: localhost
41   register: __included_in_cobbler
42   notify:
43     - 'Boot from network'
44     - 'Reboot server'
45   tags: cobbler-include
46
47 - meta: flush_handlers
48
49 - name: Copy netplan network config file
50   template:
51     src: 'files/netplan_config'
52     dest: '/etc/netplan/01-netcfg.yaml'
53     owner: 'root'
54     group: 'root'
55     mode: '0644'
56   tags: copy-interface-file
57
58 - name: Add permanent proxy settings
59   lineinfile:
60     path: '/etc/environment'
61     state: 'present'
62     line: '{{ item.key }}={{ item.value }}'
63   with_dict: '{{ proxy_env }}'
64   when: proxy_env is defined
65
66 - name: Install distribution - release - machine prerequisites
67   include_tasks: '{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml'
68   tags: [ install-csit-dependencies, copy-apt-sources ]
69
70 - name: Set sudoers admin
71   lineinfile:
72     path: '/etc/sudoers'
73     state: 'present'
74     regexp: '^%admin ALL='
75     line: '%admin ALL=(ALL) ALL'
76     validate: '/usr/sbin/visudo -cf %s'
77   tags: set-sudoers
78
79 - name: Set sudoers sudo
80   lineinfile:
81     path: '/etc/sudoers'
82     state: 'present'
83     regexp: '^%sudo'
84     line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
85     validate: '/usr/sbin/visudo -cf %s'
86   tags: set-sudoers
87
88 - name: Copy grub file
89   template:
90    src: 'files/grub_{{ ansible_machine }}'
91    dest: '/etc/default/grub'
92    owner: 'root'
93    group: 'root'
94    mode: '644'
95   notify:
96     - 'Update GRUB'
97     - 'Reboot server'
98   tags: copy-grub
99
100 - name: Mellanox Install - Driver
101   import_tasks: mellanox.yaml
102   tags: mellanox-install
103
104 - meta: flush_handlers