sailesh1993 / rpms / cloud-init

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