Open geerlingguy opened 4 years ago
Files identified in the description:
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @dmtrs @resmo click here for bot help
Workaround: you can add a stat
to check if the composer.json
file already exists:
- name: Check if Drupal project already exists.
stat:
path: "{{ drupal_core_path }}/composer.json"
register: drupal_composer_json
- name: Create Drupal project.
composer:
command: create-project
arguments: drupal/recommended-project "{{ drupal_core_path }}"
working_dir: "{{ drupal_core_path }}"
no_dev: true
become_user: www-data
when: not drupal_composer_json.stat.exists
If the composer is overtime during the download, some files will still be generated, and the project directory is not empty when running again
+label waiting_on_contributor
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
SUMMARY
I'm switching over to using the
composer
module for some of my PHP projects, and one thing I noticed is that there's no simple way of making thecomposer
module idempotent when usingcreate-project
:When I run that, the first time, it creates the project without issue, but after that, it tries running the command again, regardless of whether the project already exists, and I get an error:
I propose that we maybe check if a
composer.json
file is already present in the directory when thecommand
is set tocreate-project
, and if so, skip the task? Or maybe add aforce
option if you want to let users still force it if a project is already there. Could also add a warning in the output if skipped due to existingcomposer.json
.ISSUE TYPE
COMPONENT NAME
plugins/modules/packaging/language/composer.py
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
macOS 10.15.5
STEPS TO REPRODUCE
On an Ubuntu system with Apache and Composer installed:
Run the tasks a second time, and observe the result.
EXPECTED RESULTS
On second run, the create-project task would be skipped and playbook would not fail.
ACTUAL RESULTS
On second run, the create-project task fails with: