diff --git a/changelogs/fragments/colors.yml b/changelogs/fragments/colors.yml new file mode 100644 index 00000000000..250a9b1982d --- /dev/null +++ b/changelogs/fragments/colors.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible terminal color settings were incorrectly limited to 16 options via 'choices', removing so all 256 can be accessed. diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 9f4c17d494a..52d63a8dcd0 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -226,11 +226,7 @@ COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH: warning: issue a warning but continue ignore: just continue silently default: warning -_COLOR_DEFAULTS: &color - name: placeholder for color settings' defaults - choices: ['black', 'bright gray', 'blue', 'white', 'green', 'bright blue', 'cyan', 'bright green', 'red', 'bright cyan', 'purple', 'bright red', 'yellow', 'bright purple', 'dark gray', 'bright yellow', 'magenta', 'bright magenta', 'normal'] COLOR_CHANGED: - <<: *color name: Color for 'changed' task status default: yellow description: Defines the color to use on 'Changed' task status @@ -238,7 +234,6 @@ COLOR_CHANGED: ini: - {key: changed, section: colors} COLOR_CONSOLE_PROMPT: - <<: *color name: "Color for ansible-console's prompt task status" default: white description: Defines the default color to use for ansible-console @@ -247,7 +242,6 @@ COLOR_CONSOLE_PROMPT: - {key: console_prompt, section: colors} version_added: "2.7" COLOR_DEBUG: - <<: *color name: Color for debug statements default: dark gray description: Defines the color to use when emitting debug messages @@ -255,7 +249,6 @@ COLOR_DEBUG: ini: - {key: debug, section: colors} COLOR_DEPRECATE: - <<: *color name: Color for deprecation messages default: purple description: Defines the color to use when emitting deprecation messages @@ -263,7 +256,6 @@ COLOR_DEPRECATE: ini: - {key: deprecate, section: colors} COLOR_DIFF_ADD: - <<: *color name: Color for diff added display default: green description: Defines the color to use when showing added lines in diffs @@ -272,7 +264,6 @@ COLOR_DIFF_ADD: - {key: diff_add, section: colors} yaml: {key: display.colors.diff.add} COLOR_DIFF_LINES: - <<: *color name: Color for diff lines display default: cyan description: Defines the color to use when showing diffs @@ -280,7 +271,6 @@ COLOR_DIFF_LINES: ini: - {key: diff_lines, section: colors} COLOR_DIFF_REMOVE: - <<: *color name: Color for diff removed display default: red description: Defines the color to use when showing removed lines in diffs @@ -288,7 +278,6 @@ COLOR_DIFF_REMOVE: ini: - {key: diff_remove, section: colors} COLOR_ERROR: - <<: *color name: Color for error messages default: red description: Defines the color to use when emitting error messages @@ -297,7 +286,6 @@ COLOR_ERROR: - {key: error, section: colors} yaml: {key: colors.error} COLOR_HIGHLIGHT: - <<: *color name: Color for highlighting default: white description: Defines the color to use for highlighting @@ -305,7 +293,6 @@ COLOR_HIGHLIGHT: ini: - {key: highlight, section: colors} COLOR_OK: - <<: *color name: Color for 'ok' task status default: green description: Defines the color to use when showing 'OK' task status @@ -313,7 +300,6 @@ COLOR_OK: ini: - {key: ok, section: colors} COLOR_SKIP: - <<: *color name: Color for 'skip' task status default: cyan description: Defines the color to use when showing 'Skipped' task status @@ -321,7 +307,6 @@ COLOR_SKIP: ini: - {key: skip, section: colors} COLOR_UNREACHABLE: - <<: *color name: Color for 'unreachable' host state default: bright red description: Defines the color to use on 'Unreachable' status @@ -329,7 +314,6 @@ COLOR_UNREACHABLE: ini: - {key: unreachable, section: colors} COLOR_VERBOSE: - <<: *color name: Color for verbose messages default: blue description: Defines the color to use when emitting verbose messages. i.e those that show with '-v's. @@ -337,7 +321,6 @@ COLOR_VERBOSE: ini: - {key: verbose, section: colors} COLOR_WARN: - <<: *color name: Color for warning messages default: bright purple description: Defines the color to use when emitting warning messages diff --git a/test/units/config/test3.cfg b/test/units/config/test3.cfg new file mode 100644 index 00000000000..dab929566a1 --- /dev/null +++ b/test/units/config/test3.cfg @@ -0,0 +1,4 @@ +[colors] +unreachable=bright red +verbose=rgb013 +debug=gray10 diff --git a/test/units/config/test_manager.py b/test/units/config/test_manager.py index 3f3347f1cd3..0848276c4b4 100644 --- a/test/units/config/test_manager.py +++ b/test/units/config/test_manager.py @@ -18,6 +18,7 @@ from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode curdir = os.path.dirname(__file__) cfg_file = os.path.join(curdir, 'test.cfg') cfg_file2 = os.path.join(curdir, 'test2.cfg') +cfg_file3 = os.path.join(curdir, 'test3.cfg') ensure_test_data = [ ('a,b', 'list', list), @@ -156,3 +157,16 @@ class TestConfigManager: actual_value = ensure_type(vault_var, value_type) assert actual_value == "vault text" + + +@pytest.mark.parametrize(("key", "expected_value"), ( + ("COLOR_UNREACHABLE", "bright red"), + ("COLOR_VERBOSE", "rgb013"), + ("COLOR_DEBUG", "gray10"))) +def test_256color_support(key, expected_value): + # GIVEN: a config file containing 256-color values with default definitions + manager = ConfigManager(cfg_file3) + # WHEN: get config values + actual_value = manager.get_config_value(key) + # THEN: no error + assert actual_value == expected_value