Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-2.5] fix: cloud init problems with ubuntu (#1158) #1173

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ansible/roles/providers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@

- include_tasks: misc.yml
when: packer_builder_type and packer_builder_type != ""

- include_tasks: vmware-redhat.yaml
when:
- packer_builder_type is search('vmware') or packer_builder_type is search('vsphere')
- ansible_os_family == "RedHat"
52 changes: 52 additions & 0 deletions ansible/roles/providers/tasks/vmware-redhat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- name: Get package facts
ansible.builtin.package_facts:
manager: "auto"

- name: Set cloud-init version
ansible.builtin.set_fact:
cloud_init_version: "{{ ansible_facts.packages['cloud-init'][0].version }}"

# this program used by ds-identify to determine whether or not the
# VMwareGuestInfo datasource is useable.
- name: Directly install GuestInfo
when: cloud_init_version is version('21.3', '<')
block:

- name: Copy vmware guestinfo datasource
copy:
src: "{{ item }}"
dest: /tmp/
owner: root
group: root
mode: 0755
with_items:
- cloud-init-vmware.sh
- DataSourceVMwareGuestInfo.py

- name: Create ds-check program to verify VMwareGuestInfo datasource
copy:
src: files/dscheck_VMwareGuestInfo.sh
dest: /usr/bin/dscheck_VMwareGuestInfo
owner: root
group: root
mode: 0755

- name: Execute cloud-init-vmware.sh
shell: bash -o errexit -o pipefail /tmp/cloud-init-vmware.sh
environment:
VMWARE_DS_PATH: '/tmp/DataSourceVMwareGuestInfo.py'

- name: Remove cloud-init-vmware.sh
file:
path: /tmp/cloud-init-vmware.sh
state: absent

# sets the datasource_list to VMwareGuestInfo for all OS
# ensure that VMwareGuestInfo overrides existing datasource drop-ins if it exists.
- name: Copy cloud-init config file for vmware
copy:
src: files/etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg
dest: /etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg
owner: root
group: root
mode: 0644
58 changes: 7 additions & 51 deletions ansible/roles/providers/tasks/vmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- cloud-initramfs-dyn-netconf
when: ansible_os_family == "Debian"


- name: Install cloud-init packages
yum:
name: "{{ packages }}"
Expand Down Expand Up @@ -58,63 +59,17 @@
packages: "cloud-init cloud-utils python3-netifaces"
when: ansible_os_family == "VMware Photon OS"

# pip on CentOS needs to be upgraded, but since it's still
# Python 2.7, need < 21.0
- name: Upgrade pip
pip:
name: pip<21.0
extra_args: "{{ '--no-index --find-links=' + pip_packages_remote_filesystem_repo_path if offline_mode_enabled }}"
state: forcereinstall
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == '7'

- name: Copy vmware guestinfo datasource
copy:
src: "{{ item }}"
dest: /tmp/
owner: root
group: root
mode: 0755
with_items:
- cloud-init-vmware.sh
- DataSourceVMwareGuestInfo.py

- name: Copy cloud-init config file for vmware
copy:
src: files/etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg
dest: /etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg
owner: root
group: root
mode: 0644

- name: Remove subiquity-disable-cloudinit-networking.cfg
file:
path: /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
state: absent
when: ansible_os_family != "Flatcar"

- name: Remove 99-installer.cfg
file:
path: /etc/cloud/cloud.cfg.d/99-installer.cfg
state: absent

# this program used by ds-identify to determine whether or not the
# VMwareGuestInfo datasource is useable.
- name: Create ds-check program to verify VMwareGuestInfo datasource
copy:
src: files/dscheck_VMwareGuestInfo.sh
dest: /usr/bin/dscheck_VMwareGuestInfo
owner: root
group: root
mode: 0755

- name: Execute cloud-init-vmware.sh
shell: bash -o errexit -o pipefail /tmp/cloud-init-vmware.sh
environment:
VMWARE_DS_PATH: '/tmp/DataSourceVMwareGuestInfo.py'

- name: Remove cloud-init-vmware.sh
file:
path: /tmp/cloud-init-vmware.sh
state: absent
when: ansible_os_family != "Flatcar"

- name: >-
Remove cloud-init /etc/cloud/cloud.cfg.d/99-disable-networking-config.cfg
Expand Down Expand Up @@ -146,6 +101,7 @@
owner: root
group: root
mode: 0644
when: ansible_os_family != "Flatcar"

- name: Get a list of services
service_facts:
Expand All @@ -158,15 +114,15 @@
when: ('ufw.service' in ansible_facts.services) and (ansible_os_family == "Debian")

# See https://kb.vmware.com/s/article/82229
# From systemd docs:
# "If a valid D-Bus machine ID is already configured for the system,
# From systemd docs:
# "If a valid D-Bus machine ID is already configured for the system,
# the D-Bus machine ID is copied and used to initialize the machine ID in /etc/machine-id"
# This needs to be reset/truncated as well on Ubuntu.
- name: Truncate D-Bus machine-id
file:
path: /var/lib/dbus/machine-id
state: absent
when: ansible_os_family == "Debian"
when: ansible_os_family == "Debian"

- name: Link D-Bus machine-id to /etc/machine-id
file:
Expand Down
Loading