aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/testbed-setup/ansible/roles/common/tasks/main.yaml
blob: 6844358ecaaca43b8839b65e654c4871d0ff6c87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
# 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: Ubuntu specific
  import_tasks: ubuntu.yaml
  when: ansible_distribution|lower == 'ubuntu'

- name: Set hostname
  hostname:
      name: '{{ hostname }}'
  tags: set-hostname

- name: Ensure hostname is in /etc/hosts
  lineinfile:
    path: '/etc/hosts'
    regexp: '^{{ ansible_default_ipv4.address }}.+$'
    line: '{{ ansible_default_ipv4.address }} {{ hostname }}.{{ name_servers_search }}'
  tags: set-hostname

- name: Set sudoers admin
  lineinfile:
    path: '/etc/sudoers'
    state: 'present'
    regexp: '^%admin ALL='
    line: '%admin ALL=(ALL) ALL'
    validate: '/usr/sbin/visudo -cf %s'
  tags: set-sudoers

- name: Set sudoers sudo
  lineinfile:
    path: '/etc/sudoers'
    state: 'present'
    regexp: '^%sudo'
    line: '%sudo ALL=(ALL:ALL) NOPASSWD: ALL'
    validate: '/usr/sbin/visudo -cf %s'
  tags: set-sudoers

- name: Copy grub file
  template:
   src: 'files/grub'
   dest: '/etc/default/grub'
   owner: 'root'
   group: 'root'
   mode: '644'
  notify: ['Update GRUB']
  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