Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Run command fails when passing --var-file option with an existing vars file #643

Closed
geerlingguy opened this issue Jul 7, 2017 · 4 comments

Comments

@geerlingguy
Copy link
Contributor

ISSUE TYPE
  • Bug Report
container.yml
version: "2"
settings:
  conductor_base: debian:9

services:
  solr:
    from: "debian:9"
    ports:
      - "8983:8983"
    command: "{{ container_start_command }}"
    roles:
      - setup
      - geerlingguy.java
      - geerlingguy.solr
OS / ENVIRONMENT

See: https://gist.github.com/geerlingguy/98cb8a4b61baa285bafe813823eb2b23

SUMMARY

It seems that when I use the run command, I can't also pass a --var_file. I am defining my service's command as a variable in my container.yml, and trying to set the variable in a var file for each environment.

STEPS TO REPRODUCE
  1. Create a vars-test.yml file with a variable container_start_command defined in it.
  2. Use a container.yml file like the one above.
  3. Try running the run command after building the container(s) along with the --var_file option.

It says in the docs line that [--var-file VAR_FILE] is one of the options... and it works fine with the build option, but it seems not to be accepted by run.

EXPECTED RESULTS

The variables defined in vars-test.yml should be used by the run command allowing variables to be used in container.yml.

ACTUAL RESULTS
$ ansible-container --var_file ./vars-test.yml run
usage: ansible-container [-h] [--debug] [--devel] [--engine ENGINE_NAME]
                         [--project-path BASE_PATH]
                         [--project-name PROJECT_NAME] [--var-file VAR_FILE]
                         [--no-selinux]
                         {run,help,deploy,stop,destroy,restart,init,version,build,install,push,import}
                         ...
ansible-container: error: argument subcommand: invalid choice: './vars-test.yml' (choose from 'run', 'help', 'deploy', 'stop', 'destroy', 'restart', 'init', 'version', 'build', 'install', 'push', 'import')
@geerlingguy
Copy link
Contributor Author

See geerlingguy/solr-container#7 for the configuration I'm currently using.

@chouseknecht
Copy link
Contributor

@geerlingguy

I tested running from source with the following:

# Init the project with ac-solr role
$ ansible-container init geerlingguy.ac-solr

# Build using latest AC source
$ ansible-container --var-file vars-6.x.yml --debug --devel build

# Run with --var-file, using latest AC source:
$ ansible-container --var-file vars-6.x.yml --debug --devel run

# Check if the container is actually running
$ docker ps
WARNING: Error loading config file:/Users/chouseknecht/.docker/config.json - EOF
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                    NAMES
655ad410ceae        ac-solr-solr:20170710150458   "/opt/solr/bin/sol..."   3 minutes ago       Up 3 minutes        0.0.0.0:8983->8983/tcp   acsolr_solr_1

Looks like in your comments above, and in your docs, you're specifying the --var-file param incorrectly. Notice in both places you have --var_file, emphasis on the _.

@geerlingguy
Copy link
Contributor Author

🤦🏻‍♂️

Will try that out, and if it works, close this issue.

I think I was confusing myself the night I posted this issue with the underscores and dashes!

@geerlingguy
Copy link
Contributor Author

Yep. Thanks for the help, and sorry about the noise!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants