3e7e5a00fa0e31b6910576de45d148eaa4cf3631
[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: Install CSIT PIP requirements
71   pip:
72     name:
73       - 'docopt==0.6.2'
74       - 'ecdsa==0.13'
75       - 'enum34==1.1.2'
76       - 'ipaddress==1.0.16'
77       - 'paramiko==1.16.0'
78       - 'pexpect==4.6.0'
79       - 'pycrypto==2.6.1'
80       - 'pykwalify==1.5.0'
81       - 'pypcap==1.1.5'
82       - 'python-dateutil==2.4.2'
83       - 'PyYAML==3.11'
84       - 'requests==2.9.1'
85       - 'robotframework==2.9.2'
86       - 'scapy==2.3.1'
87       - 'scp==0.10.2'
88       - 'six==1.12.0'
89       - 'dill==0.2.8.2'
90       - 'numpy==1.14.5'
91       - 'aenum==2.1.2'
92   tags: install-pip
93
94 - name: Install CSIT PIP requirements - SciPy workaround
95   pip:
96     name:
97       - 'scipy==1.1.0'
98   tags: install-pip
99
100 - name: Set sudoers admin
101   lineinfile:
102     path: '/etc/sudoers'
103     state: 'present'
104     regexp: '^%admin ALL='
105     line: '%admin ALL=(ALL) ALL'
106     validate: '/usr/sbin/visudo -cf %s'
107   tags: set-sudoers
108
109 - name: Set sudoers sudo
110   lineinfile:
111     path: '/etc/sudoers'
112     state: 'present'
113     regexp: '^%sudo'
114     line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
115     validate: '/usr/sbin/visudo -cf %s'
116   tags: set-sudoers
117
118 - name: Copy grub file
119   template:
120    src: 'files/grub_{{ ansible_machine }}'
121    dest: '/etc/default/grub'
122    owner: 'root'
123    group: 'root'
124    mode: '644'
125   notify:
126     - 'Update GRUB'
127     - 'Reboot server'
128   tags: copy-grub
129
130 - name: Mellanox Install - Driver
131   import_tasks: mellanox.yaml
132   tags: mellanox-install
133
134 - meta: flush_handlers