Ansible testbed setup for Taishan testbed
[csit.git] / resources / tools / testbed-setup / ansible / roles / common / tasks / main.yaml
1 ---
2 # file: roles/common/tasks/main.yaml
3
4 - name: Ubuntu specific
5   import_tasks: ubuntu.yaml
6   when: ansible_distribution|lower == 'ubuntu'
7
8 - name: Set hostname
9   hostname:
10       name: '{{ hostname }}'
11   tags: set-hostname
12
13 - name: Ensure hostname is in /etc/hosts
14   lineinfile:
15     path: '/etc/hosts'
16     regexp: '^{{ ansible_default_ipv4.address }}.+$'
17     line: '{{ ansible_default_ipv4.address }} {{ hostname }}.linuxfoundation.org'
18   tags: set-hostname
19
20 - name: Set sudoers admin
21   lineinfile:
22     path: '/etc/sudoers'
23     state: 'present'
24     regexp: '^%admin ALL='
25     line: '%admin ALL=(ALL) ALL'
26     validate: '/usr/sbin/visudo -cf %s'
27   tags: set-sudoers
28
29 - name: Set sudoers sudo
30   lineinfile:
31     path: '/etc/sudoers'
32     state: 'present'
33     regexp: '^%sudo'
34     line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
35     validate: '/usr/sbin/visudo -cf %s'
36   tags: set-sudoers
37
38 - name: Copy grub file
39   template:
40    src: 'files/grub'
41    dest: '/etc/default/grub'
42    owner: 'root'
43    group: 'root'
44    mode: '644'
45   notify: ['Update GRUB']
46   tags: copy-grub