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