CSIT-1437 Create portable host-setup document
[csit.git] / resources / tools / testbed-setup / ansible / roles / common / tasks / main.yaml
1 ---
2 # file: roles/common/tasks/main.yaml
3
4 - name: Add permanent proxy settings
5   lineinfile:
6     path: "/etc/environment"
7     state: "present"
8     line: "{{ item.key }}={{ item.value }}"
9   with_dict: "{{ proxy_env }}"
10   when: proxy_env is defined
11
12 - name: Ubuntu specific
13   import_tasks: ubuntu.yaml
14   when: ansible_distribution|lower == 'ubuntu'
15
16 - name: Set hostname
17   hostname:
18       name: '{{ hostname }}'
19   tags: set-hostname
20
21 - name: Ensure hostname is in /etc/hosts
22   lineinfile:
23     path: '/etc/hosts'
24     regexp: '^{{ ansible_default_ipv4.address }}.+$'
25     line: '{{ ansible_default_ipv4.address }} {{ hostname }}.{{ domain }}'
26   tags: set-hostname
27
28 - name: Set sudoers admin
29   lineinfile:
30     path: '/etc/sudoers'
31     state: 'present'
32     regexp: '^%admin ALL='
33     line: '%admin ALL=(ALL) ALL'
34     validate: '/usr/sbin/visudo -cf %s'
35   tags: set-sudoers
36
37 - name: Set sudoers sudo
38   lineinfile:
39     path: '/etc/sudoers'
40     state: 'present'
41     regexp: '^%sudo'
42     line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
43     validate: '/usr/sbin/visudo -cf %s'
44   tags: set-sudoers
45
46 - name: Copy grub file
47   template:
48    src: 'files/grub'
49    dest: '/etc/default/grub'
50    owner: 'root'
51    group: 'root'
52    mode: '644'
53   notify: ['Update GRUB']
54   tags: copy-grub
55
56 - name: Add permanent proxy settings
57   lineinfile:
58     path: "/etc/environment"
59     state: "present"
60     line: "{{ item.key }}={{ item.value }}"
61   with_dict: "{{ proxy_env }}"
62   when: proxy_env is defined