Bessonov/ansible-role-docker-compose

ERROR! Syntax Error while loading YAML in the playbook with parameters

MaxiReglisse opened this issue · 9 comments

I could not use the example provided in the documentation, because of a syntax error to handle the parameters. Here was the initial playbook:

- hosts: dev
  roles:
     - Bessonov.docker-compose
       # required: desired docker-compose version or 'latest'
       docker_compose_version: 1.16.0
       # optional: executable path
       docker_compose_bin: /usr/local/bin/docker-compose
       # optional: should be installed as root
       docker_compose_as_root: yes

the error message is the following:

ERROR! Syntax Error while loading YAML.
    did not find expected '-' indicator

The error appears to have been in '/usr/local/bin/ansible-admin/playbooks/dev_docker.yml': line 5, column 8, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
       # required: desired docker-compose version or 'latest'
       docker_compose_version: 1.16.0
       ^ here

it is necessary to put the variables in a vars section.

- hosts: dev
  roles:
     - Bessonov.docker-compose
  vars:
     # required: desired docker-compose version or 'latest'
     - docker_compose_version: 1.16.0
     # optional: executable path
     - docker_compose_bin: /usr/local/bin/docker-compose
     # optional: should be installed as root
     - docker_compose_as_root: yes

Hope it helps.

Are you sure about that? Because it's tested here

i am not sure... I just experienced the thing, and I spent more than an hour to find a solution that works for me.
my configuration is perhaps a bit too old...

ansible 2.6.3
python version = 2.7.12
Ubuntu 16.04.5 LTS

Here is my actual/real playbook :

- name: Docker via galaxy
  hosts: dev
  become: true
  roles:
    - bessonov.docker
    - bessonov.docker-compose
  vars:
    # optional: specifies a list with users, which should be added to docker group for non root access to docker
    - docker_engine_allow_non_root: docker
    # required: desired docker-compose version or 'latest'
    - docker_compose_version: latest
    # optional: executable path
    - docker_compose_bin: /usr/local/bin/docker-compose
    # optional: should be installed as root
    - docker_compose_as_root: yes

what do you think about the playbook proposed in ansible-role-bash_aliases ?

I think I took my feet in the carpet as we say in French ... the playbook proposed above is full of confusion. i am sorry...
Here is the new version, thanks to Igor Mukhin

- name: Docker via galaxy
  hosts: dev
  become: true
  vars:
    - bash_aliases_docker:
        - { alias: 'docker_rmv', command: 'docker rm -f $(docker ps -a -q)  && docker volume rm `docker volume ls -q` && docker ps -a | cut -c-12 | xargs docker rm' }
  roles:
    - role: igor_mukhin.bash_aliases
      bash_aliases: "{{ bash_aliases_docker }}"
      bash_aliases_path: "/home/docker/.bash_aliases"
    - role: bessonov.docker
      docker_engine_allow_non_root: docker
    - role: bessonov.docker-compose
      docker_compose_version: latest
      docker_compose_bin: /usr/local/bin/docker-compose
      docker_compose_as_root: yes
    - role: ansible-bashrc
      bashrc_users: docker

it only remains to find a solution to create the user docker! ;)

You don't need a role for that. Just use user module as task.

Feel free to reopen if you issue with ansible-role-docker-compose exists.

well, it seems i cannot reopen the issue...
my opinion is that your playbook with parameters has a syntax error. "role" is missing.

  roles:
     - Bessonov.docker-compose

shoud be

  roles:
     - role: Bessonov.docker-compose

Oh, yeah, you're right! In your example above it does work, but it doesn't work if you have parameters.