FAQ
Hi,

I am a n00b and I am trying to create a CA playbook that first locally
creates certs, keys etc (using easy-rsa's pkitool) and then deploys these
to the different play_hosts. -I might be going about this the wrong way,
but is there a way to register the play_hosts in a list that can then be
used when I change play_hosts to be just localhost, and then when I do the
deploy go back to the original play_hosts?


---
- hosts: all
   sudo: yes
   tasks:
   - name: register current play_hosts for later
     ping:
     register: play_hosts_all # this doesn't work obviously

- hosts: localhost
   connection: local
   sudo: yes
   tasks:
   - name: create keys/certs
     command : pkitool {{ item }}
     with_items: {{ play_hosts_all }}

- hosts: {{ play_hosts_all }}
   sudo: yes
   tasks:
   - name: deploy key/cert/...
     copy: src= ... dest= ...




--
Xtratherm Limited is a limited company registered in Ireland. Registered
number: 331130. Registered office: Kells Road, Navan, Co. Meath. Directors:
D.E. Hynes, E.J. Hynes, S.K. Steenson, J. Keegan, B. Rafferty, T. Hynes.
VAT Registration: IE6351130B
Xtratherm UK Limited is a limited company registered in England and Wales.
Registered number: 4404208. Registered office: Holmewood Industrial Park,
Park Road, Chesterfield, Derbyshire S42 5UY. VAT Registration: GB787574856
Please note that [Xtratherm Limited/Xtratherm UK Limited] may monitor
e-mail traffic data and content of e-mail for the purpose of security and
training.

--
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+unsubscribe@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/3fa52e35-1104-4bfd-aea4-be39d0d2dfd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Brian Coca at Jul 6, 2014 at 3:03 pm
    you already have a play_hosts variable with the 'current active hosts' in
    the play​, but it will be reset every play.

    In this case I would just rewrite the play to use:

       with_items: groups['all']

    --
    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+unsubscribe@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/CADn%2BHsxi1Xc2-BPmxfese12yCrWviigwXS7XsMPxbCM6ey%2BoOQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sturban at Jul 6, 2014 at 4:46 pm
    ​-The problem with 'with_items: groups['all']' is that it takes that
    directly from /etc/ansible/hosts rather than using whatever hosts-pattern
    that was supplied on the command-line - i.e. '--limit ​somehosts'

    # somehosts.yml
    ---

    - hosts: all

      sudo: yes

      vars:

        allhosts: "{{ hostvars.keys() }}"

      tasks:

      - name: all the current hosts

        debug: var=allhosts

    - hosts: localhost

      connection: local

      sudo: yes

      tasks:

      - name: allhosts is reset/empty because this is a new play

       debug: var=allhosts

      - name: hosts in all-group

        debug: var="{{ item }}"

        with_items: groups['all']

    $ ansible-playbook somehosts.yml --limit not-all-group


    -The above playbook is apparently TWO plays and the var allhosts doesn't
    survive between them even though it was set in the same yml-file. -Is there
    a way of saving ""{{ hostvars.keys() }}"" between plays? (Other than
    saving it to a file). -Ideally I would like the reverse of failed_hosts as
    it is after first play above.


    --
    Xtratherm Limited is a limited company registered in Ireland. Registered
    number: 331130. Registered office: Kells Road, Navan, Co. Meath. Directors:
    D.E. Hynes, E.J. Hynes, S.K. Steenson, J. Keegan, B. Rafferty, T. Hynes.
    VAT Registration: IE6351130B
    Xtratherm UK Limited is a limited company registered in England and Wales.
    Registered number: 4404208. Registered office: Holmewood Industrial Park,
    Park Road, Chesterfield, Derbyshire S42 5UY. VAT Registration: GB787574856
    Please note that [Xtratherm Limited/Xtratherm UK Limited] may monitor
    e-mail traffic data and content of e-mail for the purpose of security and
    training.

    --
    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+unsubscribe@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/1ea37b43-5cb2-4c1a-8835-63fb55e8864b%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sturban at Jul 7, 2014 at 12:18 pm
    What should current_host be replaced with so that the below only runs for
    the host localhost?

    ---

    - hosts: all

      sudo: yes

      tasks:

      - name:play_hosts
       debug: var=play_hosts
        when: current_host == "localhost"





    --
    Xtratherm Limited is a limited company registered in Ireland. Registered
    number: 331130. Registered office: Kells Road, Navan, Co. Meath. Directors:
    D.E. Hynes, E.J. Hynes, S.K. Steenson, J. Keegan, B. Rafferty, T. Hynes.
    VAT Registration: IE6351130B
    Xtratherm UK Limited is a limited company registered in England and Wales.
    Registered number: 4404208. Registered office: Holmewood Industrial Park,
    Park Road, Chesterfield, Derbyshire S42 5UY. VAT Registration: GB787574856
    Please note that [Xtratherm Limited/Xtratherm UK Limited] may monitor
    e-mail traffic data and content of e-mail for the purpose of security and
    training.

    --
    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+unsubscribe@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/b676a295-5431-4d3a-8e7a-053f61a3afa4%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Brian Coca at Jul 7, 2014 at 12:21 pm
    when: inventory_hostname == 'localhost'​

    --
    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+unsubscribe@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/CADn%2BHswjCB54ezyf5uBxb2x9Jmc0iNvTm%2BSYAXbmNE5%2BZQ_i6w%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael DeHaan at Jul 7, 2014 at 7:24 pm
    " with_items: groups['all']"

    I wouldn't. I'd use the host loop since it's already there.

    - hosts: all
       tasks:
         - local_action: ...




    On Sun, Jul 6, 2014 at 11:03 AM, Brian Coca wrote:

    you already have a play_hosts variable with the 'current active hosts' in
    the play​, but it will be reset every play.

    In this case I would just rewrite the play to use:

    with_items: groups['all']

    --
    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+unsubscribe@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/CADn%2BHsxi1Xc2-BPmxfese12yCrWviigwXS7XsMPxbCM6ey%2BoOQ%40mail.gmail.com
    <https://groups.google.com/d/msgid/ansible-project/CADn%2BHsxi1Xc2-BPmxfese12yCrWviigwXS7XsMPxbCM6ey%2BoOQ%40mail.gmail.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 ansible-project+unsubscribe@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/CA%2BnsWgw_sMfbV5BuJSNZ3HyMaMi9jW7R6endhy8viLKnzsxjPg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupansible-project @
postedJul 6, '14 at 1:06p
activeJul 7, '14 at 7:24p
posts6
users3

People

Translate

site design / logo © 2022 Grokbase