diff --git a/changelogs/fragments/12339-composer.yml b/changelogs/fragments/12339-composer.yml new file mode 100644 index 0000000000..f7b9a750ba --- /dev/null +++ b/changelogs/fragments/12339-composer.yml @@ -0,0 +1,2 @@ +bugfixes: + - "composer - restore compatibility with older compose versions when using ``working_dir`` (https://github.com/ansible-collections/community.general/issues/12293, https://github.com/ansible-collections/community.general/pull/12339)." diff --git a/plugins/modules/composer.py b/plugins/modules/composer.py index 4191e68a61..15625216f8 100644 --- a/plugins/modules/composer.py +++ b/plugins/modules/composer.py @@ -189,7 +189,7 @@ def composer_command(module, command, arguments=None, options=None): working_dir_option = [] else: global_arg = [] - working_dir_option = ["--working-dir", module.params["working_dir"]] + working_dir_option = [f"--working-dir={module.params['working_dir']}"] if module.params["executable"] is None: php_path = module.get_bin_path("php", True, ["/usr/local/bin"]) diff --git a/tests/unit/plugins/modules/test_composer.yaml b/tests/unit/plugins/modules/test_composer.yaml index b71cc4083f..7a65cf9eb3 100644 --- a/tests/unit/plugins/modules/test_composer.yaml +++ b/tests/unit/plugins/modules/test_composer.yaml @@ -5,24 +5,24 @@ --- anchors: help_install: &help_install - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "help", "install", "--no-interaction", "--format=json"] + command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "install", "--no-interaction", "--format=json"] rc: 0 out: | {"definition": {"options": ["a", "b", "c"]}} err: '' help_create_project: &help_create_project - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "help", "create-project", "--no-interaction", "--format=json"] + command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "create-project", "--no-interaction", "--format=json"] rc: 0 out: | {"definition": {"options": ["a", "b", "c"]}} err: '' run_create_project: &run_create_project - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "create-project", "vendor/package"] + command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "create-project", "vendor/package"] rc: 0 out: '' err: '' help_config: &help_config - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "help", "config", "--no-interaction", "--format=json"] + command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "help", "config", "--no-interaction", "--format=json"] rc: 0 out: | {"definition": {"options": ["a", "b", "c"]}} @@ -38,7 +38,7 @@ test_cases: mocks: run_command: - *help_install - - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "install"] + - command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "install"] rc: 0 out: '' err: '' @@ -99,7 +99,7 @@ test_cases: return_values: ["hash1", "hash2", "hash1", "hash2"] run_command: - *help_config - - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "config", "setting-key", "setting-value"] + - command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "config", "setting-key", "setting-value"] rc: 0 out: '' err: '' @@ -118,7 +118,7 @@ test_cases: return_values: ["hash1", "hash2", "hash1_changed", "hash2"] run_command: - *help_config - - command: ["/testbin/php", "/testbin/composer", "--working-dir", "/var/www/foo", "config", "setting-key", "setting-value"] + - command: ["/testbin/php", "/testbin/composer", "--working-dir=/var/www/foo", "config", "setting-key", "setting-value"] rc: 0 out: '' err: ''