-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Photon OS autoinstall (#221)
* Support Photon OS autoinstall Signed-off-by: Qi Zhang <qiz@vmware.com>
- Loading branch information
1 parent
7a6b2dc
commit da242fb
Showing
69 changed files
with
717 additions
and
791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"hostname": "photon-autoinstall-machine", | ||
"password": { | ||
"crypted": true, | ||
"text": "{{ vm_password_hash }}" | ||
}, | ||
"disk": "/dev/{{ boot_disk_name }}", | ||
"packagelist_file": "packages_ova.json", | ||
"arch": "x86_64", | ||
"additional_packages": ["vim","gawk","sudo"], | ||
"install_linux_esx": true, | ||
"eject_cdrom": true, | ||
"postinstall": [ | ||
"#!/bin/sh", | ||
{% if new_user is defined and new_user != 'root' %} | ||
"useradd -p '{{ vm_password_hash }}' -m {{ new_user }}", | ||
"echo '{{ ssh_public_key }}' >/home/{{ new_user }}/.ssh/authorized_keys", | ||
"echo '{{ new_user }} ALL=(ALL) NOPASSWD:ALL' >/etc/sudoers.d/{{ new_user }}", | ||
{% endif %} | ||
"tdnf --disablerepo=photon-updates install -y sg3_utils tar", | ||
"sed -r -i 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/g' /etc/ssh/sshd_config", | ||
"systemctl stop iptables", | ||
"systemctl disable iptables", | ||
"echo '{{ autoinstall_complete_msg }}' >/dev/ttyS0" | ||
], | ||
"public_key": "{{ ssh_public_key }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2022 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Download file from ESXi datastore | ||
# Parameters: | ||
# src_datastore: the datastore name of the file. e.g. datastore1 | ||
# src_file_path: the relative file path in datastore. e.g. vm_name/vmware.log | ||
# dest_file_path: the downloaded file path at localhost. e.g. /tmp/downloaded_vmware.log | ||
# download_file_timeout: timeout in seconds for downloading datastore file. Default is 300s. | ||
|
||
- include_tasks: esxi_check_delete_datastore_file.yml | ||
vars: | ||
file_in_datastore_ops: file | ||
file_in_datastore: "{{ src_datastore }}" | ||
file_in_datastore_path: "{{ src_file_path }}" | ||
file_in_datastore_failed_ignore: False | ||
|
||
- name: "Check datastore file URL exists" | ||
assert: | ||
that: | ||
- ds_file_result.url is defined | ||
- ds_file_result.url | ||
fail_msg: "There is no URL for downloading '{{ src_file_path }}' from datastore '{{ src_datastore }}'" | ||
|
||
- name: "Set fact of downloading URL for the src datastore file" | ||
set_fact: | ||
datastore_file_url: "{{ ds_file_result.url }}" | ||
|
||
- name: "Download datastore file" | ||
get_url: | ||
url: "{{ datastore_file_url }}" | ||
dest: "{{ dest_file_path }}" | ||
url_username: "{{ vsphere_host_user }}" | ||
url_password: "{{ vsphere_host_user_password }}" | ||
validate_certs: "{{ validate_certs | default(False) }}" | ||
mode: "0644" | ||
timeout: "{{ download_file_timeout | default(300) }}" | ||
register: datastore_file_download_result | ||
|
||
- name: "Print datastore file download result" | ||
debug: var=datastore_file_download_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2022 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Upload a local file to ESXi datastore | ||
# Parameters | ||
# src_file_path: the file path on localhost. e.g. /tmp/temp_file | ||
# dest_datastore: the datastore name where to upload file. e.g. datastore1 | ||
# dest_file_path: the relative file path on ESXi server on datastore. e.g. vm_name/uploaded_file_name | ||
# upload_file_timeout: timeout in seconds to upload the file. Default is 300s. | ||
|
||
- name: "Upload local file to ESXi datastore" | ||
community.vmware.vsphere_copy: | ||
hostname: "{{ vsphere_host_name }}" | ||
username: "{{ vsphere_host_user }}" | ||
password: "{{ vsphere_host_user_password }}" | ||
validate_certs: "{{ validate_certs | default(False) }}" | ||
datacenter: "{{ vsphere_host_datacenter }}" | ||
datastore: "{{ dest_datastore | default(datastore) }}" | ||
src: "{{ src_file_path }}" | ||
path: "{{ dest_file_path }}" | ||
timeout: "{{ upload_file_timeout | default(300) }}" | ||
register: upload_file_result | ||
|
||
- name: "Print the result of uploading file to ESXi datastore" | ||
debug: var=upload_file_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2022 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Mount a NFS storage or an ISO image on local machine | ||
# Parameters: | ||
# mount_src: The mount point source, which could be an ISO image path or NFS server path | ||
# mount_path: The local path to mount the source | ||
# mount_fstype: The fstype of mount point, such as nfs, iso9660, etc | ||
# mount_opts: options for mounting filesystem | ||
# | ||
- name: "Mount {{ mount_src }} to {{ mount_path }} on localhost" | ||
mount: | ||
path: "{{ mount_path }}" | ||
src: "{{ mount_src }}" | ||
opts: "{{ mount_opts | default('ro,nolock') }}" | ||
fstab: "/tmp/temp.fstab" | ||
fstype: "{{ mount_fstype }}" | ||
boot: false | ||
state: mounted | ||
register: mount_result | ||
become: yes | ||
|
||
- name: "Display the mount result" | ||
debug: var=mount_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2022 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Unmount a NFS storage or an ISO image from local machine | ||
# Parameters: | ||
# mount_path: The local mount point | ||
# | ||
- name: "Unmount {{ mount_path }} on localhost" | ||
mount: | ||
path: "{{ mount_path }}" | ||
fstab: "/tmp/temp.fstab" | ||
state: absent | ||
become: yes | ||
register: unmount_result | ||
|
||
- name: "Display the unmount result" | ||
debug: var=unmount_result |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.