Skip to content

Older Ansible not supported any more? Getting "'ssl_certificate' is undefined" #66

@centic9

Description

@centic9

Trying to run the current version of this role from Galaxy, I get the following when using Ansible 2.0.0 (the latest on base Ubuntu Xenial):

TASK [../../roles/thefinn93.letsencrypt : Create directory for `ssl_certificate` and `ssl_certificate_key`] ***
task path: /opt/svn/Ansible/roles/thefinn93.letsencrypt/tasks/main.yml:86
fatal: [vserver]: FAILED! => {"failed": true, "msg": "ERROR! 'ssl_certificate' is undefined"}

It looks like the with_items is not supported with "when"?

  - name: Create directory for `ssl_certificate` and `ssl_certificate_key`
    file:
      path: '{{ item }}'
      state: directory
      recurse: yes
    when: ssl_certificate is defined and ssl_certificate_key is defined
    with_items:
      - "{{ ssl_certificate|dirname }}"
      - "{{ ssl_certificate_key|dirname }}"

If I change that to the following it seems to work:


  - name: Create directory for `ssl_certificate` and `ssl_certificate_key`
    file:
      path: "{{ ssl_certificate_key|dirname }}"
      state: directory
      recurse: yes
    when: ssl_certificate is defined and ssl_certificate_key is defined

  - name: Create directory for `ssl_certificate` and `ssl_certificate_key`
    file:
      path: "{{ ssl_certificate|dirname }}"
      state: directory
      recurse: yes
    when: ssl_certificate is defined and ssl_certificate_key is defined

  - name: Symlink certificates to `ssl_certificate` and `ssl_certificate_key`
    file:
      src: /etc/letsencrypt/live/{{ letsencrypt_cert_domains[0] }}/fullchain.pem
      dest: "{{ssl_certificate}}"
      state: link
    when: ssl_certificate is defined and ssl_certificate_key is defined

  - name: Symlink certificates to `ssl_certificate` and `ssl_certificate_key`
    file:
      src: /etc/letsencrypt/live/{{ letsencrypt_cert_domains[0] }}/privkey.pem
      dest: "{{ssl_certificate_key}}"
      state: link
    when: ssl_certificate is defined and ssl_certificate_key is defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions