Hey Patrick, I typically use "raise Exception(message)" when debugging in modules, since Ansible captures this output and prints it to the console.
On Thu, Apr 17, 2014 at 11:22 AM, Patrick Galbraith <[email protected]> wrote: > Michael, > > With containers (versus VMs), you ideally can run a LOT of them on a > single host. RedHat did a demo with 1000s of them running: > http://www.theregister.co.uk/2014/04/15/red_hat_project_atomic_docker/ > > Maybe I'm not understanding what you are saying, and apologies in advance > ;) > > So, I was looking at the code but having a _heck_ of a time figuring out > how to do some in-depth debugging. I want to print out a dictionary > ("containers" in this case) > > def get_deployed_containers(self): > # determine which images/commands are running already > containers = self.client.containers(all=True) > image = self.module.params.get('image') > command = self.module.params.get('command') > if command: > command = command.strip() > name = self.module.params.get('name') > if name and not name.startswith('/'): > name = '/' + name > deployed = [] > > I'm new to Ansible, I will admit, and using my tried-and-true "print" > statement debugging tool breaks an ansible run. I'd like to know the trick > to being able to debug Python code that runs ansible. > > Regards, > > Patrick > > > On Wednesday, April 16, 2014 10:13:16 PM UTC-4, Michael DeHaan wrote: > >> Yep yep! >> >> Paul nailed it. >> >> Ideally every cloud module would support an exact_count like was done for >> Rackspace and EC2, where it makes that number of containers exist. >> >> Though I'm a little unclear why you'd want multiple docker containers on >> the same host, the way that sucker runs (i.e. it's not a cloud API so those >> images get all on the same box). >> >> --Michael >> >> >> >> >> On Wed, Apr 16, 2014 at 10:09 PM, Patrick Galbraith <[email protected]>wrote: >> >>> Thanks! I could actually tinker with this. I'm comfortable with ansible >>> source now, having a pull-request in for the nova_compute module (ahem :) >>> What you describe seems to be the case and in fact I was running with -vvvv >>> and noticed this. >>> >>> >>> On Wednesday, April 16, 2014 7:41:36 PM UTC-4, Paul Durivage wrote: >>> >>>> I'll venture a guess as to what is happening here, but I don't know for >>>> sure. I guess I could look at the source. ;) >>>> >>>> I think what's happening here is that with_sequence is actually >>>> invoking a new module build/upload/run for every item in the with_sequence, >>>> and thereby overwriting the docker_containers variable with the facts from >>>> the last docker module run. So, it's a guess, but you could probably verify >>>> that by running with some extra verbosity (I think you need at least -vv). >>>> This is definitely not happening in the first container launch, because >>>> it's passing those values directly to the module, running only once. >>>> >>>> If you don't give it a shot, I'll probably take a look at it in the >>>> morning. >>>> >>>> Let me know what you find! >>>> >>>> >>>> On Wed, Apr 16, 2014 at 4:41 PM, Patrick Galbraith <[email protected]>wrote: >>>> >>>>> Hi all! >>>>> >>>>> I have what I think is a simple question. It pertains to what is >>>>> visible/available in the "docker_containers" dictionary when running a run >>>>> book. >>>>> >>>>> Ok, so, what’s throwing me off is whether to use one of the following: >>>>> >>>>> - name launch containers >>>>> >>>>> docker: image=df02bd73464a count={{ start_containers_count }} >>>>> >>>>> Or >>>>> >>>>> - name launch containers >>>>> >>>>> docker: image=df02bd73464a name=somename_{{item}} >>>>> >>>>> with_sequence: count={{ start_containers_count }} >>>>> >>>>> It is the first snippet that works for doing this next task: >>>>> >>>>> - name: print container info >>>>> >>>>> debug: msg="{{item['NetworkSettings']['IPAddress']}}" >>>>> >>>>> with_items: docker_containers >>>>> >>>>> Why? Because the latter results in “docker_containers” only having the >>>>> last container’s information (last container launched), whereas the former >>>>> gives me all of them. >>>>> >>>>> >>>>> It’s probably something really simple… >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ansible Project" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> >>>>> To view this discussion on the web visit https://groups.google.com/d/ >>>>> msgid/ansible-project/5145e9f6-0aa0-45ee-af33-c50c37d82b06% >>>>> 40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/5145e9f6-0aa0-45ee-af33-c50c37d82b06%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ansible Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/ansible-project/0274085d-cb0d-4450-bf63- >>> 326e39df5658%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/0274085d-cb0d-4450-bf63-326e39df5658%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/8ac6673f-d563-42e6-832f-73c1bc8f3cef%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/8ac6673f-d563-42e6-832f-73c1bc8f3cef%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK6JQEHWc1G653CSZn3jz%3Dg7HUs_-myYfSeyjjYBPszRxa3Kig%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
