From e51b00edca321b6b911e9787e828c6c301dda221 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 6 Dec 2019 11:01:55 -0800 Subject: [PATCH] lorax-composer: Change cockpit.socket examples to cockpit The RHEL7 version of Anaconda only allows .service units to be used with the kickstart services command. Update the documentation, examples, and tests to reflect this. Related: rhbz#1718473 --- docs/lorax-composer.rst | 11 ++++++--- tests/pylorax/results/custom-base.dict | 2 +- tests/pylorax/results/custom-base.toml | 2 +- tests/pylorax/test_compose.py | 34 +++++++++++++------------- tests/pylorax/test_recipes.py | 18 +++++++------- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/docs/lorax-composer.rst b/docs/lorax-composer.rst index f666e301..bb778583 100644 --- a/docs/lorax-composer.rst +++ b/docs/lorax-composer.rst @@ -314,13 +314,16 @@ image to work correctly, and cannot be overridden. eg. ``ami`` requires boot. Blueprint services are added to, not replacing, the list already in the templates, if any. -The service names are systemd service units. You may specify any systemd unit -file accepted by ``systemctl enable`` eg. ``cockpit.socket``:: - [customizations.services] - enabled = ["sshd", "cockpit.socket", "httpd"] + enabled = ["sshd", "cockpit", "httpd.service"] disabled = ["postfix", "telnetd"] +.. note:: + + The service names are systemd service units. You can only specify the unit + name, eg. ``httpd``, or the full service name, eg. ``httpd.service`` -- but + not other systemd unit files. Note that this is different from newer + releases where you can specify any systemd unit file. Adding Output Types ------------------- diff --git a/tests/pylorax/results/custom-base.dict b/tests/pylorax/results/custom-base.dict index de022939..67be64fa 100644 --- a/tests/pylorax/results/custom-base.dict +++ b/tests/pylorax/results/custom-base.dict @@ -1 +1 @@ -{'name': 'custom-base', 'description': 'A base system with customizations', 'version': '0.0.1', 'modules': [], 'packages': [{'name': 'bash', 'version': '4.4.*'}], 'groups': [], 'customizations': {'hostname': 'custombase', 'sshkey': [{'user': 'root', 'key': 'A SSH KEY FOR ROOT'}], 'kernel': {'append': 'nosmt=force'}, 'user': [{'name': 'admin', 'description': 'Administrator account', 'password': '$6$CHO2$3rN8eviE2t50lmVyBYihTgVRHcaecmeCk31L...', 'key': 'PUBLIC SSH KEY', 'home': '/srv/widget/', 'shell': '/usr/bin/bash', 'groups': ['widget', 'users', 'wheel'], 'uid': 1200, 'gid': 1200}], 'group': [{'name': 'widget', 'gid': 1130}], 'timezone': {'timezone': 'US/Eastern', 'ntpservers': ['0.north-america.pool.ntp.org', '1.north-america.pool.ntp.org']}, 'locale': {'languages': ['en_US.UTF-8'], 'keyboard': 'us'}, 'firewall': {'ports': ['22:tcp', '80:tcp', 'imap:tcp', '53:tcp', '53:udp'], 'services': {'enabled': ['ftp', 'ntp', 'dhcp'], 'disabled': ['telnet']}}, 'services': {'enabled': ['sshd', 'cockpit.socket', 'httpd'], 'disabled': ['postfix', 'telnetd']}}} +{'name': 'custom-base', 'description': 'A base system with customizations', 'version': '0.0.1', 'modules': [], 'packages': [{'name': 'bash', 'version': '4.4.*'}], 'groups': [], 'customizations': {'hostname': 'custombase', 'sshkey': [{'user': 'root', 'key': 'A SSH KEY FOR ROOT'}], 'kernel': {'append': 'nosmt=force'}, 'user': [{'name': 'admin', 'description': 'Administrator account', 'password': '$6$CHO2$3rN8eviE2t50lmVyBYihTgVRHcaecmeCk31L...', 'key': 'PUBLIC SSH KEY', 'home': '/srv/widget/', 'shell': '/usr/bin/bash', 'groups': ['widget', 'users', 'wheel'], 'uid': 1200, 'gid': 1200}], 'group': [{'name': 'widget', 'gid': 1130}], 'timezone': {'timezone': 'US/Eastern', 'ntpservers': ['0.north-america.pool.ntp.org', '1.north-america.pool.ntp.org']}, 'locale': {'languages': ['en_US.UTF-8'], 'keyboard': 'us'}, 'firewall': {'ports': ['22:tcp', '80:tcp', 'imap:tcp', '53:tcp', '53:udp'], 'services': {'enabled': ['ftp', 'ntp', 'dhcp'], 'disabled': ['telnet']}}, 'services': {'enabled': ['sshd', 'cockpit', 'httpd'], 'disabled': ['postfix', 'telnetd']}}} diff --git a/tests/pylorax/results/custom-base.toml b/tests/pylorax/results/custom-base.toml index e21161b5..b27d5393 100644 --- a/tests/pylorax/results/custom-base.toml +++ b/tests/pylorax/results/custom-base.toml @@ -47,5 +47,5 @@ enabled = ["ftp", "ntp", "dhcp"] disabled = ["telnet"] [customizations.services] -enabled = ["sshd", "cockpit.socket", "httpd"] +enabled = ["sshd", "cockpit", "httpd"] disabled = ["postfix", "telnetd"] diff --git a/tests/pylorax/test_compose.py b/tests/pylorax/test_compose.py index e493b957..a7f154c4 100644 --- a/tests/pylorax/test_compose.py +++ b/tests/pylorax/test_compose.py @@ -435,7 +435,7 @@ version = "0.0.1" [customizations.services] """ enable_services = """ -enabled = ["sshd", "cockpit.socket", "httpd"] +enabled = ["sshd", "cockpit", "httpd"] """ disable_services = """ disabled = ["postfix", "telnetd"] @@ -449,7 +449,7 @@ disabled = ["postfix", "telnetd"] recipe = recipe_from_toml(blueprint2_data) self.assertEqual(get_services(recipe), - {"enabled": ["cockpit.socket", "httpd", "sshd"], "disabled": []}) + {"enabled": ["cockpit", "httpd", "sshd"], "disabled": []}) recipe = recipe_from_toml(blueprint3_data) self.assertEqual(get_services(recipe), @@ -457,28 +457,28 @@ disabled = ["postfix", "telnetd"] recipe = recipe_from_toml(blueprint4_data) self.assertEqual(get_services(recipe), - {"enabled": ["cockpit.socket", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}) + {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}) def test_services_cmd(self): """Test services_cmd function""" self.assertEqual(services_cmd("", {"enabled": [], "disabled": []}), "") - self.assertEqual(services_cmd("", {"enabled": ["cockpit.socket", "httpd", "sshd"], "disabled": []}), - 'services --enabled="cockpit.socket,httpd,sshd"') + self.assertEqual(services_cmd("", {"enabled": ["cockpit", "httpd", "sshd"], "disabled": []}), + 'services --enabled="cockpit,httpd,sshd"') self.assertEqual(services_cmd("", {"enabled": [], "disabled": ["postfix", "telnetd"]}), 'services --disabled="postfix,telnetd"') - self.assertEqual(services_cmd("", {"enabled": ["cockpit.socket", "httpd", "sshd"], + self.assertEqual(services_cmd("", {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}), - 'services --disabled="postfix,telnetd" --enabled="cockpit.socket,httpd,sshd"') - self.assertEqual(services_cmd("services --enabled=pop3", {"enabled": ["cockpit.socket", "httpd", "sshd"], + 'services --disabled="postfix,telnetd" --enabled="cockpit,httpd,sshd"') + self.assertEqual(services_cmd("services --enabled=pop3", {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}), - 'services --disabled="postfix,telnetd" --enabled="cockpit.socket,httpd,pop3,sshd"') - self.assertEqual(services_cmd("services --disabled=imapd", {"enabled": ["cockpit.socket", "httpd", "sshd"], + 'services --disabled="postfix,telnetd" --enabled="cockpit,httpd,pop3,sshd"') + self.assertEqual(services_cmd("services --disabled=imapd", {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}), - 'services --disabled="imapd,postfix,telnetd" --enabled="cockpit.socket,httpd,sshd"') - self.assertEqual(services_cmd("services --enabled=pop3 --disabled=imapd", {"enabled": ["cockpit.socket", "httpd", "sshd"], + 'services --disabled="imapd,postfix,telnetd" --enabled="cockpit,httpd,sshd"') + self.assertEqual(services_cmd("services --enabled=pop3 --disabled=imapd", {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}), - 'services --disabled="imapd,postfix,telnetd" --enabled="cockpit.socket,httpd,pop3,sshd"') + 'services --disabled="imapd,postfix,telnetd" --enabled="cockpit,httpd,pop3,sshd"') def test_get_default_services(self): """Test get_default_services function""" @@ -489,7 +489,7 @@ version = "0.0.1" [customizations.services] """ enable_services = """ -enabled = ["sshd", "cockpit.socket", "httpd"] +enabled = ["sshd", "cockpit", "httpd"] """ disable_services = """ disabled = ["postfix", "telnetd"] @@ -682,7 +682,7 @@ enabled = ["ftp", "ntp", "dhcp"] disabled = ["telnet"] [customizations.services] -enabled = ["sshd", "cockpit.socket", "httpd"] +enabled = ["sshd", "cockpit", "httpd"] disabled = ["postfix", "telnetd"] """ tz_dict = {"timezone": "US/Samoa", "ntpservers": ["0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"]} @@ -704,7 +704,7 @@ disabled = ["postfix", "telnetd"] "enabled": ["ftp", "ntp", "dhcp"], "disabled": ["telnet"]}, line_limit=6)) self.assertEqual(sum([1 for l in result.splitlines() if l.startswith("firewall")]), 1) self.assertTrue(self._checkServices(result, - {"enabled": ["cockpit.socket", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}, + {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}, line_limit=6)) self.assertEqual(sum([1 for l in result.splitlines() if l.startswith("services")]), 1) @@ -761,7 +761,7 @@ disabled = ["postfix", "telnetd"] errors.append(("firewall for compose_type %s failed: More than 1 entry" % compose_type, result)) if not self._checkServices(result, - {"enabled": ["cockpit.socket", "httpd", "sshd"], + {"enabled": ["cockpit", "httpd", "sshd"], "disabled": ["postfix", "telnetd"]}): errors.append(("services for compose_type %s failed" % compose_type, result)) if sum([1 for l in result.splitlines() if l.startswith("services")]) != 1: diff --git a/tests/pylorax/test_recipes.py b/tests/pylorax/test_recipes.py index d484330e..31358818 100644 --- a/tests/pylorax/test_recipes.py +++ b/tests/pylorax/test_recipes.py @@ -96,8 +96,8 @@ class BasicRecipeTest(unittest.TestCase): self.custom_firewall3 = {'firewall': {'services': {'enabled': ['ftp', 'ntp', 'dhcp'], 'disabled': ['telnet']}}} self.custom_firewall4 = {'firewall': {'services': {'enabled': ['ftp', 'ntp', 'dhcp']}}} self.custom_firewall5 = {'firewall': {'services': {'disabled': ['telnet']}}} - self.custom_services1 = {'services': {'enabled': ['sshd', 'cockpit.socket', 'httpd'], 'disabled': ['postfix', 'telnetd']}} - self.custom_services2 = {'services': {'enabled': ['sshd', 'cockpit.socket', 'httpd']}} + self.custom_services1 = {'services': {'enabled': ['sshd', 'cockpit', 'httpd'], 'disabled': ['postfix', 'telnetd']}} + self.custom_services2 = {'services': {'enabled': ['sshd', 'cockpit', 'httpd']}} self.custom_services3 = {'services': {'disabled': ['postfix', 'telnetd']}} self.old_custom.update(self.custom_sshkey1) @@ -115,7 +115,7 @@ class BasicRecipeTest(unittest.TestCase): 'old': None}, {'new': {'Customizations.locale': {'keyboard': 'us', 'languages': ['en_US.UTF-8']}}, 'old': None}, - {'new': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit.socket', 'httpd']}}, + {'new': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit', 'httpd']}}, 'old': None}, {'new': {'Customizations.timezone': {'ntpservers': ['0.north-america.pool.ntp.org', '1.north-america.pool.ntp.org'], 'timezone': 'US/Eastern'}}, @@ -235,7 +235,7 @@ class BasicRecipeTest(unittest.TestCase): new_custom = old_custom.copy() new_custom.update(self.custom_services1) new_recipe = recipes.Recipe("test-recipe", "A recipe used for testing", "0.3.1", [], [], [], customizations=new_custom) - result = [{'new': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit.socket', 'httpd']}}, + result = [{'new': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit', 'httpd']}}, 'old': None}] self.assertEqual(recipes.customizations_diff(old_recipe, new_recipe), result) @@ -247,8 +247,8 @@ class BasicRecipeTest(unittest.TestCase): new_custom = self.old_custom.copy() new_custom.update(self.custom_services2) new_recipe = recipes.Recipe("test-recipe", "A recipe used for testing", "0.3.1", [], [], [], customizations=new_custom) - result = [{'old': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit.socket', 'httpd']}}, - 'new': {'Customizations.services': {'enabled': ['sshd', 'cockpit.socket', 'httpd']}}}] + result = [{'old': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit', 'httpd']}}, + 'new': {'Customizations.services': {'enabled': ['sshd', 'cockpit', 'httpd']}}}] self.assertEqual(recipes.customizations_diff(old_recipe, new_recipe), result) # Test removing enabled @@ -259,7 +259,7 @@ class BasicRecipeTest(unittest.TestCase): new_custom = self.old_custom.copy() new_custom.update(self.custom_services3) new_recipe = recipes.Recipe("test-recipe", "A recipe used for testing", "0.3.1", [], [], [], customizations=new_custom) - result = [{'old': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit.socket', 'httpd']}}, + result = [{'old': {'Customizations.services': {'disabled': ['postfix', 'telnetd'], 'enabled': ['sshd', 'cockpit', 'httpd']}}, 'new': {'Customizations.services': {'disabled': ['postfix', 'telnetd']}}}] self.assertEqual(recipes.customizations_diff(old_recipe, new_recipe), result) @@ -916,11 +916,11 @@ description = "test recipe" version = "0.0.1" [customizations.services] -enabled = ["sshd", "cockpit.socket", "httpd"] +enabled = ["sshd", "cockpit", "httpd"] disabled = ["postfix", "telnetd"] """ ks = self._blueprint_to_ks(blueprint_data) - self.assertEqual(sorted(ks.handler.services.enabled), ["cockpit.socket", "httpd", "sshd"]) + self.assertEqual(sorted(ks.handler.services.enabled), ["cockpit", "httpd", "sshd"]) self.assertEqual(sorted(ks.handler.services.disabled), ["postfix", "telnetd"]) def test_user(self):