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