Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template error while templating string: unexpected ''.''. #34

Open
patsevanton opened this issue May 1, 2022 · 0 comments
Open

template error while templating string: unexpected ''.''. #34

patsevanton opened this issue May 1, 2022 · 0 comments

Comments

@patsevanton
Copy link

Hello! Thanks for role docker
I try configure tag in log-opts for get result like this:

{
"log-driver": "json-file",
"log-opts": {
"tag": "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
}
}

Playbook

---
- hosts: javaindocker
  become: true
  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=true cache_valid_time=600
      when: ansible_os_family == 'Debian'
    - name: install pip3
      apt: name=python3-pip state=present
    - name: Install multi python packages with version specifiers
      pip:
        name:
          - docker
          - docker-compose
  roles:
    - role: ansible-role-docker

Inventory

all:
  children:
    javaindocker:
      hosts:
        "javaindocker":
          ansible_host: "xxx"
  vars:
    docker_options:
      "log-driver": "json-file"
      "log-opts":
          "tag": "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
          "max-size": "100m"

error:

TASK [ansible-role-docker : Docker | Deploy Config | Set the Docker configuration] *****************************************************************************************************
Sunday 01 May 2022  14:16:17 +0600 (0:00:00.954)       0:02:37.514 ************
fatal: [javaindocker]: FAILED! =>
  msg: 'An unhandled exception occurred while templating ''{''log-driver'': ''json-file'', ''log-opts'': {''tag'': ''{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}'', ''max-size'': ''100m''}}''. Error was a <class ''ansible.errors.AnsibleError''>, original message: template error while templating string: unexpected ''.''. String: {{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant