Skip to content

Commit

Permalink
Adding optional port for file server. (#238)
Browse files Browse the repository at this point in the history
This allows user to have his file server running on non-standard port.
Signed-off-by: Mohammed Zeeshan Ahmed <[email protected]>

fix #221

Signed-off-by: Mohammed Zeeshan Ahmed <[email protected]>
  • Loading branch information
mohammedzee1000 authored Jan 24, 2024
1 parent 637eca9 commit b716379
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/set-variables-group-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
**Variable Name** | **Description** | **Example**
:--- | :--- | :---
**env.file_server.ip** | IPv4 address for the file server that will be used to pass config files and<br /> iso to KVM host LPAR(s) and bastion VM during their first boot. | 192.168.10.201
**env.file_server.port** | The port on which the file server is listening. Will be embedded into all<br /> download urls. Defaults to protocol default port. Keep empty `''` to use <br /> default port | 10000
**env.file_server.user** | Username to connect to the file server. Must have sudo and SSH access. | user1
**env.file_server.pass** | Password to connect to the file server as above user. | user1pa$s!
**env.file_server.protocol** | Protocol used to serve the files, either 'ftp' or 'http' | http
Expand Down
1 change: 1 addition & 0 deletions inventories/default/group_vars/all.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ env:
# Section 3 - File Server
file_server:
ip: #X
port: '' # please keep empty string to use default port
user: #X
pass: #X
protocol: #X
Expand Down
2 changes: 1 addition & 1 deletion roles/create_bastion/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
--autostart \
--memory={{ env.bastion.resources.ram }} \
--vcpus={{ env.bastion.resources.vcpu }} \
--location {{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }} \
--location {{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }} \
--disk pool={{ env.cluster.networking.metadata_name }}-vdisk,size={{ env.bastion.resources.disk_size }} \
--network network={{ env.bridge_name }} \
--graphics none \
Expand Down
6 changes: 3 additions & 3 deletions roles/create_bastion/templates/bastion-ks.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ text --non-interactive
firstboot --enable

# Use network installation
url --url={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }}
url --url={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}

# Add yum repositories
repo --install --name="AppStream" --baseurl={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }}/AppStream/
repo --install --name="BaseOS" --baseurl={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }}/BaseOS/
repo --install --name="AppStream" --baseurl={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}/AppStream/
repo --install --name="BaseOS" --baseurl={{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}/BaseOS/

# Keyboard layouts
keyboard --vckeymap={{ env.keyboard }} --xlayouts='{{ env.keyboard }}'
Expand Down
8 changes: 4 additions & 4 deletions roles/create_bastion_hypershift/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ssh_key: "{{ ssh_output.stdout_lines[0] }}"

- name: Create Directory for images and bastion.ks
file:
file:
path: /home/libvirt/images/
recurse: true
state: directory
Expand Down Expand Up @@ -50,16 +50,16 @@
- name: Create qemu image for bastion
command: qemu-img create -f qcow2 /home/libvirt/images/{{ hypershift.hcp.hosted_cluster_name }}-bastion.qcow2 100G

- name: Create bastion
- name: Create bastion
shell: |
virt-install \
virt-install \
--name {{ hypershift.hcp.hosted_cluster_name }}-bastion \
--memory 4096 \
--vcpus sockets=1,cores=4,threads=1 \
--disk /home/libvirt/images/{{ hypershift.hcp.hosted_cluster_name }}-bastion.qcow2,format=qcow2,bus=virtio,cache=none \
--os-variant "rhel{{hypershift.bastion_parms.os_variant}}" \
--network network:{{ env.bridge_name }} \
--location '{{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }}/' \
--location '{{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}/' \
--rng=/dev/urandom --initrd-inject /home/libvirt/bastion.ks \
--extra-args="ks=file:/bastion.ks ip={{ hypershift.bastion_hypershift }}::{{hypershift.bastion_parms.gateway}}:{{hypershift.bastion_parms.subnet_mask}}:{{ hypershift.bastion_parms.hostname }}.{{ hypershift.bastion_parms.base_domain }}:{{ hypershift.bastion_parms.interface }}:none console=ttysclp0 nameserver={{hypershift.bastion_parms.nameserver}}" \
--noautoconsole \
Expand Down
2 changes: 1 addition & 1 deletion roles/create_kvm_host/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cpc_name: "{{ cpc_name }}"
name: "{{ lpar.name }}"
properties:
boot_ftp_host: "{{ env.file_server.ip }}"
boot_ftp_host: "{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}"
boot_ftp_username: "{{ env.file_server.user }}"
boot_ftp_password: "{{ env.file_server.pass }}"
boot_ftp_insfile: "{{ env.file_server.cfgs_dir }}/{{ networking.hostname }}/kvm_host.ins"
Expand Down
2 changes: 1 addition & 1 deletion roles/disconnected_mirror_images/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
remote_src: yes
loop:
- "{{ disconnected.mirroring.client_download.ocp_download_url }}{{ disconnected.mirroring.client_download.ocp_client_tgz }}"
- "{{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}/{{ disconnected.mirroring.file_server.clients_dir }}/{{ disconnected.mirroring.file_server.oc_mirror_tgz }}"
- "{{ env.file_server.protocol }}://{{ env.file_server.user + ':' + env.file_server.pass + '@' if env.file_server.protocol == 'ftp' else '' }}{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ disconnected.mirroring.file_server.clients_dir }}/{{ disconnected.mirroring.file_server.oc_mirror_tgz }}"
- name: Copy kubectl, oc, and oc-mirror binaries to /usr/local/sbin
tags: mirror_artifacts
become: true
Expand Down
2 changes: 1 addition & 1 deletion roles/update_cfgs/templates/kvm_host.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dd if=/dev/zero of=/dev/mapper/mpathh bs=512 count=10
reboot

# Use network installation
url --url=ftp://{{env.file_server.user}}:{{env.file_server.pass}}@{{env.file_server.ip}}/{{ env.file_server.iso_mount_dir }}
url --url=ftp://{{env.file_server.user}}:{{env.file_server.pass}}@{{env.file_server.ip}}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}

# Use text mode install
text
Expand Down
4 changes: 2 additions & 2 deletions roles/update_cfgs/templates/kvm_host.prm.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ro ramdisk_size=40000
ip={{ networking.ip }}::{{ networking.gateway }}:{{ lpar.networking.subnet_cidr }}:{{ networking.hostname}}:{{ networking.device1 }}:none
nameserver={{ networking.nameserver1 }} {{ ( 'nameserver=' + networking.nameserver2 ) if networking.nameserver2 is defined else '' }}
inst.repo=ftp://{{ env.file_server.user }}:{{ env.file_server.pass }}@{{ env.file_server.ip }}/{{ env.file_server.iso_mount_dir }}
inst.ks=ftp://{{ env.file_server.user }}:{{ env.file_server.pass }}@{{ env.file_server.ip }}/{{ env.file_server.cfgs_dir }}/{{ networking.hostname }}/kvm_host.cfg
inst.repo=ftp://{{ env.file_server.user }}:{{ env.file_server.pass }}@{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.iso_mount_dir }}
inst.ks=ftp://{{ env.file_server.user }}:{{ env.file_server.pass }}@{{ env.file_server.ip }}{{ ':' + env.file_server.port if env.file_server.port | default('') | length > 0 else '' }}/{{ env.file_server.cfgs_dir }}/{{ networking.hostname }}/kvm_host.cfg
inst.cmdline

0 comments on commit b716379

Please sign in to comment.