sailesh1993 / rpms / cloud-init

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