-
Notifications
You must be signed in to change notification settings - Fork 392
Using container enabled roles with ansible-container #671
Comments
I think what you're saying is that the
That's my interpretation of the phrase "The tasks in meta/container.yml" When the project's If that's indeed what you're trying to do, then obviously it's not going to work as you want. The only way to add additional tasks outside of the role's You could also make conditional tasks or includes in |
Chris, Thanks. This solves one of my 2 issues. I had in fact misunderstood, the use of meta/container.yml. The other issue is passing the which_container variable, and that still does not seem to be working.
But the value of mongo is passed both times and I end up with one container which simply has been tagged with 2 names. |
Sounds like a bug with our role cache detection logic? |
I was about to say that everything looks fine on my side, and you're crazy! Turns out you're not crazy. I was able to duplicate what you're seeing. Here's my
Here's the
And here's the playbook output from
And here are my built images:
Same as what you're seeing. One image has been tagged for both services. It build the mongo service, and then decided it could simply use that image for the tomee service. Seems our build cache does not account for variables. It only considers the tasks. |
@chouseknecht |
Working on quick hack to fix this... |
See if my fix makes sense. It at least fixes this particular case. We probably can't account for all variables, but it's something. |
@chouseknecht
That is incorrect. It should be
There is no error, but ansible-container is obviously parsing the roles incorrectly when the incorrect syntax is used. If you use the correct syntax then the two containers are created distinctly as they should be. |
@chouseknecht and @j00bar |
ISSUE TYPE
container.yml
OS / ENVIRONMENT
SUMMARY
I am working on a common deployment of my application both for VM installs and container installs. I have the VM ansible script tested and working. In the VM deployment, I have a common setup role which executes as root. Then I have separate roles for mongo and tomee which are executed by the application user which is created by the initial setup role.
There is one tomee specific action in the setup, which is the install of the right version of java. I do this in the setup role, because you need to be root to install java.
I would like to do the same thing in container deployment. This means I would run the setup role for each container. I would pass the name of the container as a variable, so that for the tomee container, java would be installed. Also, I need to execute container specific actions for the mongo and tomee roles.
From the documentation, I understood 2 things about roles and container enabled roles.
So I have create a very simple role which basically create 4 files.
In the main.yml I create 2 files
In the meta/container.yml I create 2 files
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
Here is setup_container_role/tasks/main.yml
Here is setup_container_role/meta/container.yml
Here you can see that the same container was simply tagged as mongo and tomee
The text was updated successfully, but these errors were encountered: