Skip to content

Commit

Permalink
Merge pull request #813 from roots/ansible-2.3
Browse files Browse the repository at this point in the history
Ansible 2.3 compatibility
  • Loading branch information
fullyint authored Apr 15, 2017
2 parents f948df1 + 28eb441 commit 1f165ea
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### HEAD
* Ansible 2.3 compatibility ([#813](https://github.com/roots/trellis/pull/813))
* Remove potentially dangerous `db_import` option ([#825](https://github.com/roots/trellis/pull/825))

### 1.0.0-rc.1: April 7th, 2017
Expand Down
2 changes: 1 addition & 1 deletion roles/connection/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- block:
- name: Set remote user for each host
set_fact:
ansible_user: "{{ ansible_user | default(('root' in connection_status.stdout_lines) | ternary('root', admin_user)) }}"
ansible_user: "{{ ansible_user | default((connection_status.stdout_lines | intersect(['root', '\e[0;32mroot']) | count) | ternary('root', admin_user)) }}"
check_mode: no

- name: Announce which user was selected
Expand Down
5 changes: 2 additions & 3 deletions roles/letsencrypt/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sites_using_letsencrypt: "[{% for name, site in wordpress_sites.iteritems() if site.ssl.enabled and site.ssl.provider | default('manual') == 'letsencrypt' %}'{{ name }}',{% endfor %}]"
letsencrypt_enabled: "{{ sites_using_letsencrypt | count }}"
site_uses_letsencrypt: "{{ ssl_enabled and item.value.ssl.provider | default('manual') == 'letsencrypt' }}"
missing_hosts: "{{ site_uses_letsencrypt | ternary(site_hosts, []) | difference((current_hosts.results | selectattr('item.key', 'equalto', item.key) | selectattr('stdout_lines', 'defined') | sum(attribute='stdout_lines', start=[]) | map('trim') | list | join(' ')).split(' ')) }}"
site_uses_letsencrypt: ssl_enabled and item.value.ssl.provider | default('manual') == 'letsencrypt'
missing_hosts: "{{ site_hosts | difference((current_hosts.results | selectattr('item.key', 'equalto', item.key) | selectattr('stdout_lines', 'defined') | sum(attribute='stdout_lines', start=[]) | map('trim') | list | join(' ')).split(' ')) }}"
letsencrypt_cert_ids: "{ {% for item in (generate_cert_ids | default({'results':[{'skipped':True}]})).results if not item | skipped %}'{{ item.item.key }}':'{{ item.stdout }}', {% endfor %} }"

acme_tiny_repo: 'https://github.com/diafygi/acme-tiny.git'
Expand Down
8 changes: 6 additions & 2 deletions roles/letsencrypt/tasks/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
src: nginx-challenge-site.conf.j2
dest: "{{ nginx_path }}/sites-available/letsencrypt-{{ item.key }}.conf"
register: challenge_site_confs
when: missing_hosts | count
when:
- site_uses_letsencrypt
- missing_hosts | count
with_dict: "{{ wordpress_sites }}"

- name: Enable Nginx sites
Expand All @@ -27,7 +29,9 @@
dest: "{{ nginx_path }}/sites-enabled/letsencrypt-{{ item.key }}.conf"
state: link
register: challenge_sites_enabled
when: missing_hosts | count
when:
- site_uses_letsencrypt
- missing_hosts | count
with_dict: "{{ wordpress_sites }}"
notify: disable temporary challenge sites

Expand Down
2 changes: 1 addition & 1 deletion roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
args:
chdir: "{{ nginx_path }}/ssl"
creates: "{{ nginx_path }}/ssl/dhparams.pem"
when: true in [{% for key, site in wordpress_sites.iteritems() %}{{ site.ssl.enabled }},{% endfor %}]
when: wordpress_sites.values() | map(attribute='ssl') | selectattr('enabled') | list | count
notify: reload nginx
tags: [diffie-hellman]

Expand Down
2 changes: 1 addition & 1 deletion roles/users/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
name: "{{ item.name }}"
group: "{{ item.groups[0] }}"
groups: "{{ item.groups | join(',') }}"
password: '{% for user in vault_users | default([]) if user.name == item.name and user.password is defined %}{{ user.password | password_hash("sha512", user.salt | default("") | truncate(16, true, "") | regex_replace("[^\.\/a-zA-Z0-9]", "x")) }}{% else %}{{ None }}{% endfor %}'
password: '{% for user in vault_users | default([]) if user.name == item.name and user.password is defined %}{{ user.password | password_hash("sha512", (user.salt | default(""))[:16] | regex_replace("[^\.\/a-zA-Z0-9]", "x")) }}{% else %}{{ None }}{% endfor %}'
state: present
shell: /bin/bash
update_password: always
Expand Down
2 changes: 1 addition & 1 deletion roles/wordpress-install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
command: rsync -ac --info=NAME /tmp/{{ item.key }}.env {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/.env
with_dict: "{{ wordpress_sites }}"
register: env_file
changed_when: env_file.stdout == "{{ item.key }}.env"
changed_when: env_file.stdout == item.key + '.env'

- name: Add known_hosts
known_hosts:
Expand Down
4 changes: 2 additions & 2 deletions roles/wp-cli/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
args:
warn: false
register: wp_cli
changed_when: wp_cli.stdout == "wp-cli{{ wp_cli_version }}.phar"
changed_when: wp_cli.stdout == 'wp-cli-' + wp_cli_version + '.phar'

- name: Retrieve WP-CLI tab completions
command: curl -4Ls {{ wp_cli_completion_url }} -o /tmp/wp-completion-{{ wp_cli_version }}.bash
Expand All @@ -22,4 +22,4 @@
args:
warn: false
register: wp_cli_completion
changed_when: wp_cli_completion.stdout == "wp-completion-{{ wp_cli_version }}.bash"
changed_when: wp_cli_completion.stdout == 'wp-completion-' + wp_cli_version + '.bash'
2 changes: 1 addition & 1 deletion server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
- { role: logrotate, tags: [logrotate] }
- { role: composer, tags: [composer] }
- { role: wp-cli, tags: [wp-cli] }
- { role: letsencrypt, tags: [letsencrypt], when: letsencrypt_enabled }
- { role: letsencrypt, tags: [letsencrypt], when: sites_using_letsencrypt | count }
- { role: wordpress-setup, tags: [wordpress, wordpress-setup, letsencrypt] }

0 comments on commit 1f165ea

Please sign in to comment.