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

Support import_playbook #109

Closed
timdiels opened this issue Apr 11, 2019 · 1 comment · Fixed by #268 · May be fixed by #178
Closed

Support import_playbook #109

timdiels opened this issue Apr 11, 2019 · 1 comment · Fixed by #268 · May be fixed by #178
Labels
bug Something isn't working
Milestone

Comments

@timdiels
Copy link

timdiels commented Apr 11, 2019

Using import_playbook: causes There was an error during execution: 'hosts'. I suspect it's looking for a hosts: on - import_playbook:. I suggest either printing an error that it isn't supported or adding support for it. I'll work around it by turning the playbook into a role or tasks file.

build_test.yml:

- import_playbook: test.yml
  vars:
    ansible_bender:
      base_image: python:3.5-stretch
      target_image:
        name: test_img

test.yml:

- hosts: all
  tasks:
    - debug:
        msg: hi

Running ansible-bender:

$ ansible-bender -v build test_build.yml
14:35:02.769 utils.py          INFO   running command: "['ansible-playbook', '--version']"
14:35:03.334 utils.py          INFO   running command: "['ansible-playbook', '-c', 'local', '-i', '/tmp/ab96owsyrm/i', '-e', 'ansible_python_interpreter=/.../.virtualenvs/ansible-bender/bin/python', '.test_build-20190411143502768844-afiunkadkq.yaml']"
14:35:04.772 utils.py          INFO   running command: "['podman', 'version']"
14:35:04.817 utils.py          INFO   running command: "['buildah', 'version']"
14:35:04.852 utils.py          INFO   running command: "['podman', 'image', 'exists', 'python:3.5-stretch']"
14:35:04.986 utils.py          INFO   running command: "['podman', 'run', '--rm', 'python:3.5-stretch', 'true']"
14:35:08.050 utils.py          INFO   running command: "['buildah', 'inspect', '-t', 'image', 'python:3.5-stretch']"
14:35:08.211 utils.py          INFO   running command: "['podman', 'run', '--rm', 'python:3.5-stretch', 'ls', '/usr/bin/python3']"
14:35:11.403 buildah_builder.py INFO   using python interpreter /usr/bin/python3
14:35:11.403 utils.py          INFO   running command: "['buildah', 'from', '--name', 'test_img-20190411-143504761617-cont', '2bf898387bbd9f15e7f50eb4c1c491cd2dff636fd204f40a7f05e9aabd97375e']"
14:35:13.564 core.py           INFO   creating inventory file /tmp/abw5caf2xq/inventory
14:35:13.566 utils.py          INFO   running command: "['buildah', 'rm', 'test_img-20190411-143504761617-cont']"
There was an error during execution: 'hosts'

Environment:

$ pip freeze
ansible-bender==0.5.2.dev1+g29c8d01
attrs==19.1.0
jsonschema==3.0.1
pyrsistent==0.14.11
PyYAML==5.1
six==1.12.0
tabulate==0.8.3
$ python --version
Python 3.7.2

import_tasks does work. test_build2.yml:

- hosts: all
  vars:
    ansible_bender:
      base_image: python:3.5-stretch
      target_image:
        name: test_img
  tasks:
    - import_tasks: test.yml

test2.yml:

- debug:
    msg: hi

Thanks

@TomasTomecek TomasTomecek added the bug Something isn't working label Apr 12, 2019
@TomasTomecek
Copy link
Collaborator

Thanks for the excellent bug report. You're correct that bender looks for the hosts key in a playbook. But it's interesting that it's doing such a thing when importing a playbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants