da04ad
From 528136e7f6c307f035f8db0f14313a213697d2d0 Mon Sep 17 00:00:00 2001
da04ad
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
da04ad
Date: Thu, 8 Sep 2022 17:42:26 +0200
da04ad
Subject: [PATCH] cloud.cfg.tmpl: make sure "centos" settings are identical to
da04ad
 "rhel" (#1639)
da04ad
da04ad
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
da04ad
RH-MergeRequest: 83: cloud.cfg.tmpl: make sure "centos" settings are identical to "rhel" (#1639)
da04ad
RH-Bugzilla: 2115576
da04ad
RH-Acked-by: Camilla Conte <cconte@redhat.com>
da04ad
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
da04ad
RH-Commit: [1/1] f503ce4f79b7d783cd0a4e1ed0977e63a4715031
da04ad
da04ad
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2115576
da04ad
da04ad
commit 7593243a1abe2ccaf4698579720999380a4da73b
da04ad
Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
da04ad
Date:   Wed Sep 7 14:53:26 2022 +0200
da04ad
da04ad
    cloud.cfg.tmpl: make sure "centos" settings are identical to "rhel" (#1639)
da04ad
da04ad
    We have a couple of bugs where centos does not have the default user as rhel.
da04ad
    This PR makes sure the configuration is exactly the same.
da04ad
da04ad
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
da04ad
da04ad
    RHBZ: 2115565
da04ad
    RHBZ: 2115576
da04ad
    Conflicts:
da04ad
            config/cloud.cfg.tmpl: "openmandriva" distro added in the options
da04ad
da04ad
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
da04ad
---
da04ad
 config/cloud.cfg.tmpl                   | 27 +++++++++++++------------
da04ad
 tests/unittests/test_render_cloudcfg.py |  1 +
da04ad
 2 files changed, 15 insertions(+), 13 deletions(-)
da04ad
da04ad
diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
da04ad
index 80ab4f96..08b6efbc 100644
da04ad
--- a/config/cloud.cfg.tmpl
da04ad
+++ b/config/cloud.cfg.tmpl
da04ad
@@ -2,6 +2,7 @@
da04ad
 # The top level settings are used as module
da04ad
 # and system configuration.
da04ad
 {% set is_bsd = variant in ["dragonfly", "freebsd", "netbsd", "openbsd"] %}
da04ad
+{% set is_rhel = variant in ["rhel", "centos"] %}
da04ad
 {% if is_bsd %}
da04ad
 syslog_fix_perms: root:wheel
da04ad
 {% elif variant in ["suse"] %}
da04ad
@@ -32,9 +33,9 @@ disable_root: false
da04ad
 disable_root: true
da04ad
 {% endif %}
da04ad
 
da04ad
-{% if variant in ["almalinux", "alpine", "amazon", "centos", "cloudlinux", "eurolinux",
da04ad
-                  "fedora", "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %}
da04ad
-{% if variant == "rhel" %}
da04ad
+{% if variant in ["almalinux", "alpine", "amazon", "cloudlinux", "eurolinux",
da04ad
+                  "fedora", "miraclelinux", "openEuler", "openmandriva", "rocky", "virtuozzo"] or is_rhel %}
da04ad
+{% if is_rhel %}
da04ad
 mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service,_netdev', '0', '2']
da04ad
 {% else %}
da04ad
 mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
da04ad
@@ -70,7 +71,7 @@ network:
da04ad
   config: disabled
da04ad
 {% endif %}
da04ad
 
da04ad
-{% if variant == "rhel" %}
da04ad
+{% if is_rhel %}
da04ad
 # Default redhat settings:
da04ad
 ssh_deletekeys:   true
da04ad
 ssh_genkeytypes:  ['rsa', 'ecdsa', 'ed25519']
da04ad
@@ -119,16 +120,16 @@ cloud_config_modules:
da04ad
 {% endif %}
da04ad
 {% if variant not in ["photon"] %}
da04ad
  - ssh-import-id
da04ad
-{% if variant not in ["rhel"] %}
da04ad
+{% if not is_rhel %}
da04ad
  - keyboard
da04ad
 {% endif %}
da04ad
  - locale
da04ad
 {% endif %}
da04ad
  - set-passwords
da04ad
-{% if variant in ["rhel"] %}
da04ad
+{% if is_rhel %}
da04ad
  - rh_subscription
da04ad
 {% endif %}
da04ad
-{% if variant in ["rhel", "fedora", "photon"] %}
da04ad
+{% if variant in ["fedora", "openmandriva", "photon"] or is_rhel %}
da04ad
 {% if variant not in ["photon"] %}
da04ad
  - spacewalk
da04ad
 {% endif %}
da04ad
@@ -193,9 +194,9 @@ cloud_final_modules:
da04ad
 # (not accessible to handlers/transforms)
da04ad
 system_info:
da04ad
    # This will affect which distro class gets used
da04ad
-{% if variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "debian",
da04ad
+{% if variant in ["almalinux", "alpine", "amazon", "arch", "cloudlinux", "debian",
da04ad
                   "eurolinux", "fedora", "freebsd", "gentoo", "netbsd", "miraclelinux", "openbsd", "openEuler",
da04ad
-                  "photon", "rhel", "rocky", "suse", "ubuntu", "virtuozzo"] %}
da04ad
+                  "openmandriva", "photon", "rocky", "suse", "ubuntu", "virtuozzo"] or is_rhel %}
da04ad
    distro: {{ variant }}
da04ad
 {% elif variant in ["dragonfly"] %}
da04ad
    distro: dragonflybsd
da04ad
@@ -248,15 +249,15 @@ system_info:
da04ad
          primary: http://ports.ubuntu.com/ubuntu-ports
da04ad
          security: http://ports.ubuntu.com/ubuntu-ports
da04ad
    ssh_svcname: ssh
da04ad
-{% elif variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "eurolinux",
da04ad
-                    "fedora", "gentoo", "miraclelinux", "openEuler", "rhel", "rocky", "suse", "virtuozzo"] %}
da04ad
+{% elif variant in ["almalinux", "alpine", "amazon", "arch", "cloudlinux", "eurolinux",
da04ad
+                    "fedora", "gentoo", "miraclelinux", "openEuler", "openmandriva", "rocky", "suse", "virtuozzo"] or is_rhel %}
da04ad
    # Default user name + that default users groups (if added/used)
da04ad
    default_user:
da04ad
 {% if variant == "amazon" %}
da04ad
      name: ec2-user
da04ad
      lock_passwd: True
da04ad
      gecos: EC2 Default User
da04ad
-{% elif variant == "rhel" %}
da04ad
+{% elif is_rhel %}
da04ad
      name: cloud-user
da04ad
      lock_passwd: true
da04ad
      gecos: Cloud User
da04ad
@@ -275,7 +276,7 @@ system_info:
da04ad
      groups: [adm, sudo]
da04ad
 {% elif variant == "arch" %}
da04ad
      groups: [wheel, users]
da04ad
-{% elif variant == "rhel" %}
da04ad
+{% elif is_rhel %}
da04ad
      groups: [adm, systemd-journal]
da04ad
 {% else %}
da04ad
      groups: [wheel, adm, systemd-journal]
da04ad
diff --git a/tests/unittests/test_render_cloudcfg.py b/tests/unittests/test_render_cloudcfg.py
da04ad
index 9f95d448..1a6e2715 100644
da04ad
--- a/tests/unittests/test_render_cloudcfg.py
da04ad
+++ b/tests/unittests/test_render_cloudcfg.py
da04ad
@@ -69,6 +69,7 @@ class TestRenderCloudCfg:
da04ad
             "amazon": "ec2-user",
da04ad
             "debian": "ubuntu",
da04ad
             "rhel": "cloud-user",
da04ad
+            "centos": "cloud-user",
da04ad
             "unknown": "ubuntu",
da04ad
         }
da04ad
         default_user = system_cfg["system_info"]["default_user"]["name"]
da04ad
-- 
da04ad
2.37.3
da04ad