Skip to content

Commit

Permalink
Remove Setup packagist.com authentication task
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus committed Jul 22, 2019
1 parent 162595f commit bfb1e11
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
6 changes: 6 additions & 0 deletions group_vars/all/helpers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ ssl_enabled: "{{ item.value.ssl is defined and item.value.ssl.enabled | default(
ssl_stapling_enabled: "{{ item.value.ssl is defined and item.value.ssl.stapling_enabled | default(true) }}"
cron_enabled: "{{ site_env.disable_wp_cron and (not item.value.multisite.enabled | default(false) or (item.value.multisite.enabled | default(false) and item.value.multisite.cron | default(true))) }}"
sites_use_ssl: "{{ wordpress_sites.values() | map(attribute='ssl') | selectattr('enabled') | list | count > 0 }}"

# For backward compatibility, to be removed in Trellis v2.
site_packagist_org_authentications:
- { hostname: repo.packagist.com, username: token, password: "{{ vault_wordpress_sites[site].packagist_token | default('') }}" }
site_composer_authentications: "{{ vault_wordpress_sites[site].composer_authentications | default([]) }}"
composer_authentications: "{{ site_packagist_org_authentications + site_composer_authentications }}"
18 changes: 8 additions & 10 deletions roles/deploy/hooks/build-after.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
msg: "Unable to find a `composer.json` file in the root of '{{ deploy_helper.new_release_path }}'. Make sure your repo has a `composer.json` file in its root or edit `repo_subtree_path` for '{{ site }}' in `wordpress_sites.yml` so it points to the directory with a `composer.json` file."
when: not composer_json.stat.exists

- name: Setup packagist.com authentication
composer:
command: config
arguments: --auth http-basic.repo.packagist.com token {{ project.packagist_token }}
working_dir: "{{ deploy_helper.new_release_path }}"
no_log: true
when: project.packagist_token is defined

- name: Setup composer authentications
composer:
command: config
arguments: --auth http-basic.{{ item.hostname }} {{ item.username }} {{ item.password }}
arguments: --auth http-basic.{{ composer_authentication.hostname }} {{ composer_authentication.username }} {{ composer_authentication.password }}
working_dir: "{{ deploy_helper.new_release_path }}"
no_log: true
loop: "{{ vault_wordpress_sites[site].composer_authentications | default([]) }}"
when:
- composer_authentication.hostname is defined and composer_authentication.hostname != ""
- composer_authentication.username is defined and composer_authentication.username != ""
- composer_authentication.password is defined and composer_authentication.password != ""
loop: "{{ composer_authentications }}"
loop_control:
loop_var: composer_authentication

- name: Install Composer dependencies
composer:
Expand Down
4 changes: 4 additions & 0 deletions roles/wordpress-install/tasks/composer-authentications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
arguments: --auth http-basic.{{ composer_authentication.hostname }} {{ composer_authentication.username }} {{ composer_authentication.password }}
working_dir: "{{ working_dir }}"
no_log: true
when:
- composer_authentication.hostname is defined and composer_authentication.hostname != ""
- composer_authentication.username is defined and composer_authentication.username != ""
- composer_authentication.password is defined and composer_authentication.password != ""
loop: "{{ composer_authentications }}"
loop_control:
loop_var: composer_authentication
10 changes: 0 additions & 10 deletions roles/wordpress-install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,10 @@
become: no
with_items: "{{ known_hosts | default([]) }}"

- name: Setup packagist.com authentication
composer:
command: config
arguments: --auth http-basic.repo.packagist.com token {{ item.value.packagist_token }}
working_dir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
no_log: true
when: item.value.packagist_token is defined
with_dict: "{{ wordpress_sites }}"

- include_tasks: tasks/composer-authentications.yml
vars:
site: "{{ item.key }}"
working_dir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
composer_authentications: "{{ vault_wordpress_sites[site].composer_authentications | default([]) }}"
no_log: true
with_dict: "{{ wordpress_sites }}"

Expand Down

0 comments on commit bfb1e11

Please sign in to comment.