Re: [ansible-project] multiple elements from list
Trying to pass a list of packages to be installed, and the output must return the packages will get installed before continuing with the install. Example output I get using jq (which is what I'm after): "dpkg-dev [1.17.5ubuntu5.5] (1.17.5ubuntu5.6 Ubuntu:14.04/trusty-updates [all]) []" "libdpkg-perl [1.17.5ubuntu5.5] (1.17.5ubuntu5.6 Ubuntu:14.04/trusty-updates [all])" "apt-transport-https [1.0.1ubuntu2.11] (1.0.1ubuntu2.13 Ubuntu:14.04/trusty-updates [amd64])" "linux-libc-dev [3.13.0-83.127] (3.13.0-85.129 Ubuntu:14.04/trusty-updates [amd64])" Below is the playbook - name: APT | Check upgradeable packages shell: apt-get -s install '{{item}}' | grep ^Inst | cut -d' ' -f2- with_items: '{{adhoc_package_list}}' register: packages - name: APT | List upgradeable packages debug: msg='{{item.stdout_lines}}' with_items: '{{packages.results}}' Is this possible? On Friday, 6 May 2016 13:48:09 UTC+2, Johannes Kastl wrote: > > On 06.05.16 13:12 deo...@miranetworks.net wrote: > > Hi, > > > > It is possible to select all the elements instead of specify one > element? > > > > Working: > > debug: msg="{{packages.results[0].stdout_lines}}" > > > > I've tried: > > debug: msg="{{packages.results[].stdout_lines}}" - It returns 'list > object > > has no element ()' > > > > Just a guess: > > debug: msg="{{item.stdout_lines}}" > with_items: packages.results > > or just output the whole: > > debug: var=packages > or > debug: var=packages.results > > What do you want to achieve? > > Johannes > > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/47436c5b-7874-4cae-b5fb-dcd4258e993e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] multiple elements from list
Hi, It is possible to select all the elements instead of specify one element? Working: debug: msg="{{packages.results[0].stdout_lines}}" I've tried: debug: msg="{{packages.results[].stdout_lines}}" - It returns 'list object has no element ()' -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/982d7697-c76a-4b65-8a34-22cf96fd8421%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Apt packages
Thanks, working now On Friday, 6 May 2016 11:18:08 UTC+2, Johannes Kastl wrote: > > On 06.05.16 11:13 deo...@miranetworks.net wrote: > > Tried that and does not work. > > > > Apt sees it as "apt-get install [foo,bar]" instead of "apt-get install > foo > > bar" > > Damn, I get the list thing wrong each time.. > > https://docs.ansible.com/ansible/YAMLSyntax.html > fruits: ['Apple', 'Orange', 'Strawberry', 'Mango'] > > Try this: ansible-playbook -e "your_package_list=['foo','bar','xyz']" > > Johannes > > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/66afc7ea-ca50-4e9c-acc5-703c61bbbe9f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Apt packages
Tried that and does not work. Apt sees it as "apt-get install [foo,bar]" instead of "apt-get install foo bar" On Friday, 6 May 2016 10:58:42 UTC+2, Johannes Kastl wrote: > > On 06.05.16 10:56 deo...@miranetworks.net wrote: > > Hi, > > > > Is it possible to pass list of packages with --extra-vars that needs to > be > > installed with apt? I don't want to update the playbook everytime with > list > > of package. Currently I can pass one package and it installed fine. > > Use something like this: > > apt: name="{{ item }}" ... > with_items: your_package_list > > and call the playbook with > > ansible-playbook -e 'your_package_list=[foo,bar,xyz]' > > Untested! > > Johannes > > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c8e9729e-5a33-4dc0-87f1-e75b8797f6ae%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Apt packages
Hi, Is it possible to pass list of packages with --extra-vars that needs to be installed with apt? I don't want to update the playbook everytime with list of package. Currently I can pass one package and it installed fine. Regards -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/aa2d5f07-bf54-4773-ab38-da35a854a781%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] authorized_key module with delegate_to
Hi, In my playbook I copy the ssh public key to my local ansible master. - name: fetch pub key from server fetch: src=/home/user/.ssh/id_rsa.pub dest=/tmp/keys/{{ inventory_hostname_short }}_id_rsa.pub flat=yes Next I use authorized_key module to place it in authorized keys of another user on the server. - name: ensure public key is authorized_keys on local host authorized_key: user=user2 key="{{ lookup('file', '/tmp/keys/{{ inventory_hostname_short }}_id_rsa.pub') }}" The issue I'm having is that the next task is to copy the public key to the authorized keys of the backup server using "delegate_to" - name: ensure public key is authorized_keys on backup server authorized_key: user=user2 key="{{ lookup('file', '/tmp/keys/{{ inventory_hostname_short }}_id_rsa.pub') }}" delegate_to: backup_server This use to work, but no longer does as it seems to ignore the delegate_to and copies to authorized to server again. Using ansible 2.0.1.0 Regards -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/17bbaa03-1a45-4a21-b7fc-79fa7c42fa19%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.