Update cloud-init to register to RHN

This commit is contained in:
Neill Cox 2023-09-25 10:40:59 +10:00
parent fa0bcd1ed7
commit 44629ddf72
2 changed files with 12 additions and 2 deletions

View file

@ -24,7 +24,7 @@ def parse_args():
parser.add_argument(
"--network-data", default="./src/virt-install/network-config.tpl", type=open
)
parser.add_argument("--instance-id", default="aio3")
parser.add_argument("--instance-id", required=True, help="Hostname for the new VM")
parser.add_argument("--output-image", required=True)
parser.add_argument("--image-size", default="100G")
parser.add_argument("--input-image", required=True)
@ -37,6 +37,8 @@ def parse_args():
parser.add_argument("--dns", required=True)
parser.add_argument("--search-domain", required=True)
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("--rhn-user", required=True)
parser.add_argument("rhn-password", required=True)
args = parser.parse_args()

View file

@ -7,9 +7,17 @@ chpasswd: {{expire: False}}
ssh_pwauth: True
ssh_authorized_keys:
- {data.public_key}
bootcmd:
- "nmcli conn delete 'System eth0'"
- "nmcli conn delete 'Wired connection 1'"
- "nmcli con add con-name eth0 ifname eth0 type ethernet ip4 {data.cidr_1} gw4 {data.gateway} ipv4.dns {data.dns}"
- "nmcli con add con-name eth1 ifname eth1 type ethernet ip4 {data.cidr_2} gw4 {data.gateway} ipv4.dns {data.dns}"
runcmd:
- "subscription-manager register --username {args.rh_username} --password '{args.rh_password}'"
- "subscription-manager release --set=8.4"
- "dnf install -y dnf-utils"
- "subscription-manager repos --disable=*"
- "subscription-manager repos --enable=rhel-8-for-x86_64-baseos-eus-rpms --enable=rhel-8-for-x86_64-appstream-eus-rpms --enable=rhel-8-for-x86_64-highavailability-eus-rpms --enable=ansible-2.9-for-rhel-8-x86_64-rpms --enable=openstack-16.2-for-rhel-8-x86_64-rpms --enable=fast-datapath-for-rhel-8-x86_64-rpms"
- "dnf module disable -y container-tools:rhel8"
- "dnf module enable -y container-tools:3.0"
- "dnf update -y"