summaryrefslogtreecommitdiff
path: root/roles/install-cloud-init/tasks/main.yml
blob: ae6f67b90be53d49114a6c31f2d28d18070b443c (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
63
64
65
66
67
- name: Get Debian version
  become: true
  command: chroot {{ vyos_install_root }} awk 'match($0, /VERSION=.*\((\w+)\)/, version) { print version[1] }' /etc/os-release
  register: debian_version
- name: Set VyOS branch name crux
  set_fact:
    vyos_branch: "crux"
  when: vyos_version is regex("^1\.2.*$")
- name: Set VyOS branch name equuleus
  set_fact:
    vyos_branch: "equuleus"
  when: vyos_version is regex("^1\.3.*$")
- name: Put debian.list
  become: true
  template:
    src: "templates/debian.list.j2"
    dest: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list"
- name: backup resolv.conf
  become: true
  command: mv {{ vyos_install_root }}/etc/resolv.conf /tmp/resolv.conf
- name: add nameserver settings to chroot
  become: true
  copy:
    src: "files/resolv.conf"
    dest: "{{ vyos_install_root }}/etc/resolv.conf"
- name: apt-get update
  become: true
  command: chroot {{ vyos_install_root }} apt-get update
- name: Install cloud-init
  become: true
  command: chroot {{ vyos_install_root }} apt-get -t {{ vyos_branch | default('current') }} install -y cloud-init cloud-utils
- name: apt-get clean
  become: true
  command: chroot {{ vyos_install_root }} apt-get clean
- name: delete apt lists from cache
  become: true
  command: chroot {{ vyos_install_root }} rm -rf /var/lib/apt/lists/
- name: Delete debian.list
  become: true
  file:
    path: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list"
    state: absent
- name: Create cfg.d dir
  become: true
  file:
    path: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/"
    state: directory
    mode: 0755
- name: Put datasource_list.cfg
  become: true
  template:
    src: 90_dpkg.cfg.j2
    dest: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/90_dpkg.cfg"
- name: run dpkg-reconfigure cloud-init
  become: true
  command: chroot {{ vyos_install_root }} dpkg-reconfigure -f noninteractive cloud-init
- name: Disable config-stage modules
  become: true
  copy:
    src: "files/90_disable_config_stage.cfg"
    dest: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/90_disable_config_stage.cfg"
  when:
    - cloud_init_disable_config is defined
    - cloud_init_disable_config == "true"
- name: restore original resolv.conf
  become: true
  command: mv /tmp/resolv.conf {{ vyos_install_root }}/etc/resolv.conf