[ansible-project] Re: Dynamic Inventory using Active Directory / LDAP

2018-02-14 Thread Balz . aschwanden
We do exactly that: We run ansible in pull mode with AD as inventory.

Maybe you can take a look at the dynamic inventory script we use: 
https://github.com/ANTS-Framework/ants/blob/master/antslib/inventory/inventory_ad
(Because it is used for ansible-pull, it will only return the current host, 
but it should give you some ideas.) 

Am Dienstag, 13. Februar 2018 02:50:31 UTC+1 schrieb Aaron K:
>
> Does anyone have code that can pull a dynamic inventory from list of AD 
> OUs?  Want to use the windows_update module to patch our servers only in 
> specific OUs.
>
> Maybe I missed it, but I don't see Windows Active Directory inventory 
> here:  https://github.com/ansible/ansible/tree/devel/contrib/inventory
>

-- 
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/3a835396-41c0-426c-bb0a-a8e2369611bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] letsencrypt module - account_key

2018-02-14 Thread 'Felix Fontein' via Ansible Project
Hi,

> I am a little confused by what is needed in the account_key parameter.
> 
> The docs say it is:
> 
> *File containing the Let's Encrypt account RSA key.*
> *Can be created with openssl rsa *
> I know when I first setup the account it generated keys in 
> /etc/letsencrypt/accounts/...
> 
> They are in a json format though:

well, the ones used by CertBot are in JSON, that is. There are many
different ACME (the Let's Encrypt protocol) clients, and some use JWK
(JSON Web Key), while others (like acme-tiny and the one integrated in
Ansible) use PEM.

> https://github.com/certbot/certbot/blob/master/tests/letstest/testdata/sample-config/accounts/acme-staging.api.letsencrypt.org/directory/48d6b9e8d767eccf7e4d877d6ffa81e3/private_key.json
> 
> I didnt think they needed to be created - perhaps an openssl export?

Either you simply create a new key, or you convert your existing key
(assuming you have one) using for example this method:
https://github.com/diafygi/acme-tiny/#use-existing-lets-encrypt-key

> what is that parameter looking for?

If you have an existing account key (say, from CertBot) and want to use
Ansible to create certificates for the same sets of domains, it's
probably best if you convert the existing key. Otherwise, creating a
new one is fine. Just keep whatever key you use secret and don't delete
it.

Best regards,
Felix

-- 
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/20180214093045.26d4d78f%40ivalo.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Dynamically set /etc/hosts using ansible_interfaces

2018-02-14 Thread Giovanni Tommasini
Thanks Dayton for you final solution.
If I use it, I notice that the privat IP wasn't set correctly; like this:
192.168.1.1 
1.2.3.4 hostname hostname.domain.com

So I use this solution
{% for interface in ansible_interfaces if interface != 'lo' %}
{{ hostvars[inventory_hostname]['ansible_' + interface]['ipv4']['address'] 
}} {{ inventory_hostname_short }} {{ inventory_hostname }}
{% endfor %}

and now it's ok for me
192.168.1.1 hostname hostname.domain.com
1.2.3.4 hostname hostname.domain.com

thanks

Il giorno lunedì 1 febbraio 2016 15:47:58 UTC+1, Dayton Jones ha scritto:
>
> Final solution:
>
> {% for interface in ansible_interfaces if interface != 'lo' %}{{ 
> hostvars[inventory_hostname]['ansible_' + interface]['ipv4']['address'] }} 
> {{ lookup('dig', hostvars[inventory_hostname]['ansible_' + 
> interface]['ipv4']['address'] + '/PTR').rstrip('.') }} {{ lookup('dig', 
> hostvars[inventory_hostname]['ansible_' + interface]['ipv4']['address'] + 
> '/PTR').split('.')[0] }}
> {% endfor %} 
>
>
> results in :
> 1.2.3.4 hostname.mydomain.com hostname
> 2.3.4.5 hostname-alt.otherdomain.com hostname-alt
>
>
> This of course assumes that DNS has been properly set beforehand...
>
> On Friday, January 29, 2016 at 11:17:47 AM UTC-6, Dayton Jones wrote:
>>
>> I'm trying to dynamically set /etc/hosts based on the ipv4 address 
>> assigned to all the interfaces on a host... my template reads as such
>>
>>
>> 127.0.0.1   localhost.localdomain localhost
>>
>> {% for item in ansible_interfaces if item != 'lo' %}
>>
>> {{ 'ansible_' + item + '.ipv4.address' }} {{ lookup('dig', 'ansible_' + 
>> item + '.ipv4.address' + '/PTR') }}
>>
>> {% endfor %}
>>
>>
>> which results in :
>>
>> 127.0.0.1 localhost.localdomain localhost
>>
>> ansible_eth1.ipv4.address NXDOMAIN 
>>
>> ansible_eth0.ipv4.address NXDOMAIN 
>>
>>
>>
>> I've tried several iterations, but I'm struggling to find the proper 
>> syntax to get the file to write as expected... is this possible?  Any 
>> suggestions greatly appreciated.
>>
>

-- 
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/4c700efa-d0d4-445e-a853-195bfae7b3d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread jn . bedag

This is my example playbook:
---
 - name: play1
   hosts: app1
   vars_files:
   - "vars/app1.yml"

  tasks:
  - include_role:
  name: role1
vars:
  applicationname: "{{ APPLICATIONNAME }}"
  description: "{{ DESCRIPTION }}"

Now in the role, I want to make sure applicationname is not undefined, 
empty or null.

It works when I use assert in the role:


/roles/defaults/main.yml
---
applicationname: ""
description: ""


/roles/tasks/main.yml
---
- assert:
that:
  - (applicationname != "") and (applicationname is not none) and 
(applicationname 
is defined)
msg: "Variable 'applicationname' is null, empty or undefined"


But this is ugly when I have lots of variables in a role.


I tried the following approach:

/roles/defaults/main.yml
---
applicationname: ""
description: ""

required_vars:
 - applicationname


/roles/tasks/main.yml
---
- assert:
that:
  - item != ""
  - item is not none
msg: "A Variable is null, empty or undefined. But we don't know which 
one"
  with_items: "{{ required_vars }}"

This workes, but we don't know which variable is affected, this is also 
ugly.



Another approach:

- name: check required vars
  fail: msg="Variable '{{ item }}' is not defined"
  when: item not in vars
  with_items: "{{required_vars}}"

Workes, but you cannot check the value of the variable, just if it is not 
undefined.



How do I make sure that a lot of variables are not undefined, empty or null 
when passed to a role in a simple way?


Thanks for your help.

Regards
jn







-- 
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/5a1915fa-8097-4f30-aef3-2a223f973fc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Upgrade from 1.9 to 2.4 throws "recursive loop detected" error

2018-02-14 Thread jn . bedag
Not sure, but maybe you run into this problem: 
https://github.com/ansible/ansible/issues/8603

Use a different variable, or what we do:
group_vars are in capital letter. Vars within playbooks or roles are in 
lowercases.

-- 
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/91462dee-acd2-4292-8712-ea4fee1ec0df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread Kai Stian Olstad

On 14.02.2018 11:03, jn.be...@gmail.com wrote:

Another approach:

- name: check required vars
  fail: msg="Variable '{{ item }}' is not defined"
  when: item not in vars
  with_items: "{{required_vars}}"

Workes, but you cannot check the value of the variable, just if it is 
not

undefined.


This should work

when: vars[item] is not defined or vars[item] == ""

--
Kai Stian Olstad

--
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/f1b9b2ee97dd30801f5c16847f3a158c%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread jn . bedag
Perfect, works like a charm, thank you so much!

-- 
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/75291858-757b-4e4a-a951-3915685a103f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread jn . bedag
I was too fast with my answer.

/roles/defaults/main.yml
---
applicationname: ""
description: ""

required_vars:
 - applicationname




This workes:

- name: check required vars empty
  fail: msg="Variable '{{ item }}' is empty"
  when: vars[item] == ""
  with_items: "{{ required_vars }}"


This too:
- name: check required vars null
  fail: msg="Variable '{{ item }}' is null"
  when: vars[item] is none
  with_items: "{{ required_vars }}"



But this doesn't work:
- name: check required vars undefined
  fail: msg="Variable '{{ item }}' is null"
  when: vars[item] is not defined
  with_items: "{{ required_vars }}"



TASK [role1 : check required undefined] 
**
skipping: [server1] => (item=applicationname)  => {"changed": false, 
"item": "applicationname", "skip_reason": "Conditional result was False"}



I think
vars[item] is not defined
does not work because the variable "applicationname" in fact does have a 
value: "{{ APPLICATIONNAME }}"



TASK [role1 : debug] ***
ok: [server1] => {
"vars": {
   "applicationname": "{{ APPLICATIONNAME }}"
}
}

TASK [role1 : debug] 
*
ok: [server1] => {
"applicationname": "VARIABLE IS NOT DEFINED!"
}


Any suggestions?




-- 
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/59c89301-3552-45d6-9e44-bbeb4ec0611c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread Kai Stian Olstad

On 14.02.2018 13:01, jn.be...@gmail.com wrote:

I was too fast with my answer.

/roles/defaults/main.yml
---
applicationname: ""
description: ""

required_vars:
 - applicationname






But this doesn't work:
- name: check required vars undefined
  fail: msg="Variable '{{ item }}' is null"
  when: vars[item] is not defined
  with_items: "{{ required_vars }}"


It does, when I do a test

---
- hosts: localhost
  gather_facts: false
  vars:
required_vars:
  - applicationname
  tasks:

  - name: check required vars when applicationname is not defined
debug: msg="Variable '{{ item }}' is not defined"
when: vars[item] is not defined
with_items: "{{ required_vars }}"

  - set_fact:
  applicationname: ''

  - name: check required vars when applicationname is defined
debug: msg="Variable '{{ item }}' is not defined"
when: vars[item] is not defined
with_items: "{{ required_vars }}"

The output

TASK [check required vars when applicationname is not defined] 


ok: [localhost] => (item=applicationname) => {
"item": "applicationname"
}

MSG:

Variable 'applicationname' is not defined


TASK [set_fact] 
***

ok: [localhost]

TASK [check required vars when applicationname is defined] 


skipping: [localhost] => (item=applicationname)




TASK [role1 : check required undefined]
**
skipping: [server1] => (item=applicationname)  => {"changed": false,
"item": "applicationname", "skip_reason": "Conditional result was 
False"}




I think
vars[item] is not defined
does not work because the variable "applicationname" in fact does have 
a

value: "{{ APPLICATIONNAME }}"


I don't understand where "{{ APPLICATIONNAME }}" comes from, you have 
nothing like that in you code.


--
Kai Stian Olstad

--
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/5acdfc44083f9d3d48a4f3c237166e69%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible vmware_guest creates vmware vm, but hostname does not changes. Also creates a additional junk folder

2018-02-14 Thread Ajay Sharma
Hi Everyone,

I would like to close this issue, as it is resolved. 

On Thursday, February 8, 2018 at 4:09:30 PM UTC+5:30, Ajay Sharma wrote:
>
>
> 
> HI Everyone. this Ansible yaml script creates vmware vm from previous 
> template, but does not changes its host name.  also creates a additional 
> folder named 
>
> here is the screen shot attached. The vmware_guest module creates 
> Testmachine, but the hostname of the machine remains same when i login to 
> centos machine. 
>
> also creates a junk folder named as  
> "replica-e040a406-2f24-4c53-b719-67f42c1b9115"
>
> Thanks in Advance. please give some solution. here is my yaml script 
> attached. 
>
>
> 
> cat us_vm.yaml
> ---
> - name: Deploy VM on 172.XX.X.XXX
>   hosts: localhost
>   gather_facts: no
>   vars_prompt:
>   - name: templatename
> prompt: Supply template name
> default: "CENTOS7-ENT-WWW-APACHE-DEFAULT"
> private: no
>
>   - name: vm_name
> prompt: Supply VM Name to Be Created
> default: "TestMachine"
> private: no
>   tasks:
> - name: Create a VM from USA template
>   vmware_guest:
> hostname: 172.17.X.XXX
> username: \X
> password: d1
> datacenter: OSC-US-Datacenter-Other
> validate_certs: no
> folder: /VMwareViewComposerReplicaFolder
> name: "{{vm_name}}"
> state: poweredon
> template: "{{templatename}}"
> disk:
>   - size_gb: 50
> type: thin
> datastore: 3PAR_Datastore01
> hardware:
>   memory_mb: 512
>   num_cpus: 1
>   scsi: paravirtual
> networks:
>   - name: "OSC VLAN 4 172.16.9.0"
> type: dhcp
> customization:
> # dns_servers:
> # - 172.16.XX.XX
> # - 172.16.XX.XX
>  dns_suffix: .Xield.com
>  hostname: "{{vm_name}}"
> wait_for_ip_address: no
>   delegate_to: localhost
>   register: deploy
> [root@OSIANSIBLEIND instance]#
>
>

-- 
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/f39d2ffe-5560-47b7-b7aa-318c29731c5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: ansible-pull query

2018-02-14 Thread Balz . aschwanden
Hi

This could be solved by using a dynamic inventory script. 
http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html

This is an executable file which has to print out json. You could use such 
a script do redirect your clients to the desired directory.

Am Samstag, 3. Februar 2018 17:00:03 UTC+1 schrieb sriman dharba:
>
> Hello
>
> I am using ansible-pull along with cron to perform hardening and 
> predependencies for my infra. I am managing all the contents of ansible 
> playbooks/roles/inventory in git  I am using a seperate directory name 
> templates and have a yml template specific for all apps and defining nodes 
> directly into the git repo main directory by copying the template to 
> hostname yml file of the host . This way I am able to define how my each 
> node takes which configuration changes or based on application. 
>
> My issue is as I am creating more number of host yml files inside my git 
> repo directory, I have many files in the infra i have defined and the repo 
> files listing looks messed up, I have local.yml which will be picked up by 
> default if no definitions are made for a host. Is there any chance I can 
> define a directory via ansible-pull to search host definitions only from 
> that directory instead of the main git repo directory.
>
> Thanks
> Sri
>
>

-- 
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/1a24cbf3-e523-4a13-906d-6c5cb15478ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible 2.5.0 Alpha 1 is available

2018-02-14 Thread Stas Fomin

 https://docs.ansible.com/ansible/devel/porting_guide_2.5.html 

  
— 404

-- 
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/74b69ea5-f13f-46b1-a308-ae5cb0f6ad9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Looping over nested inventory items with conditional

2018-02-14 Thread Jason Gilfoil
Thanks! that got me what I needed. I made this slight modification to the 
item piece and i'm good to go!

msg: "{{ hostvars[item].ansible_host }}"

On Tuesday, February 13, 2018 at 5:30:55 PM UTC-5, flowerysong wrote:
>
> On Tuesday, February 13, 2018 at 4:02:57 PM UTC-5, Jason Gilfoil wrote:
>>
>>
>> We're migrating from a single load balancer pair for all systems 
>> (dev/test/qa/prod) to separate pairs for dev/test and qa/prod. As a result, 
>> my previous task to pull nodes from the pool on the load balancer will no 
>> longer suffice without some conditional logic. I have a partial solution, 
>> but it two issues. 
>>
>> 1st Issue
>> In the following code i'm attempting to make it so that if the server is 
>> in the test inventory group, it uses the dev-test f5 pair and if it's not, 
>> use the qa-prod f5 pair. The first issue is that it loops over all 
>> combinations so the task would essentially execute twice for each f5 
>> target. 
>>
>> https://pastebin.com/ZxkPqvPF
>>
>> 2nd Issue
>> The second problem is that i need to expand the conditional to allow 
>> multiple statements. 
>>
>> I need to find a way to expand this line:
>>   msg: "{{ (inventory_hostname in groups['test']) | 
>> ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"
>> into
>>   msg: "{{ (inventory_hostname in groups['test'] OR inventory_hostname 
>> in groups['dev']) | 
>> ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"
>>
>
>  I'm not entirely sure of your constraints, but it seems like you would 
> want something more like 
> https://gist.github.com/flowerysong/ae18f75d2103b41198149380e8d6fb1c 
> rather than a nested loop.
>

-- 
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/fb497939-1b5c-4970-a71e-7d9be31ac977%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Upgrade from 1.9 to 2.4 throws "recursive loop detected" error

2018-02-14 Thread K. Seshadri Iyer
Thanks. I renamed the variable.

-- 
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/CAPxWMU0hE9%3Dx2KT4zk-vfQXDejFm3BOuwFzfL11aO4MrSQMAkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread jn . bedag
Hi Kai

You used the variable in a playbook, maybe that works. But I want to make 
sure that the role is not being executed when someone forgets to set the 
variable.
So the trick here is: "{{ APPLICATIONNAME }}" is not set.
Normaly this is a variable in vars/app1.yml
Here is the full code:


/vars/app1.yml
---
#APPLICATIONNAME: "app1"
#normally this var is set, but we want to provoke an error



playbook.yml
---
 - name: play1
   hosts: app1
   vars_files:
   - "vars/app1.yml"

  tasks:
  - include_role:
  name: role1
vars:
  applicationname: "{{ APPLICATIONNAME }}"
  description: "{{ DESCRIPTION }}"





/roles/defaults/main.yml
---
required_vars:
 - applicationname

applicationname: ""
description: ""






/role/tasks/main.yml
---
- debug:
var: vars

- debug:
var: applicationname

- name: check required vars when applicationname is not defined
  debug: msg="Variable '{{ item }}' is not defined"
  when: vars[item] is not defined
  with_items: "{{ required_vars }}" 




Execution:


TASK [role1 : debug] ***
ok: [server1] => {
"vars": {

"applicationname": "{{ APPLICATIONNAME }}"
}
}

TASK [role1 : debug] 

ok: [SERVER1] => {
"applicationname": "VARIABLE IS NOT DEFINED!"
}

TASK [role1 : check required vars when applicationname is not defined] 
***
skipping: [server1] => (item=applicationname)  => {"changed": false, 
"item": "applicationname", "skip_reason": "Conditional result was False"}




Or is my approach completely wrong?





-- 
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/c7c16217-530d-46e1-b7f5-a213df1cc81c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Extracting a substring with regex_replace fails

2018-02-14 Thread jean-christophe manciot
ansible 2.6.0 (devel da5cf72236) last updated 2018/02/14 14:29:49 (GMT +200)

The task seems obvious at first glance but it appears to be difficult to 
implement in this context.
The string is:
host_meta: "\n
\n"

I need to extract the values of rel and href into api_release and api_root.
I unsuccessfully tried the following:
- set_fact: api_release="{{ host_meta | regex_replace('^.* rel=(.*) .*$', 
'\\1') }}"
  when: host_meta is defined

- set_fact: api_root="{{ host_meta | regex_replace('^.* href=(.*)/>.*$', 
'\\1') }}"
  when: host_meta is defined

Both variables contain the whole string instead of the corresponding 
substring, which should be:
api_release: 'restconf'
api_root: /restconf

I have already successfully used this filter in other contexts. 
What am I missing here? Is the filter confused by the string?

-- 
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/5aeaac3f-277e-4df8-af4b-95f419979447%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Extracting a substring with regex_replace fails

2018-02-14 Thread jean-christophe manciot

>
>
>
I  have the same difficulty with:
ansible 2.4.3.0 (detached HEAD 8a7f9beab7) last updated 2018/02/14 16:11:16 
(GMT +200)
 

-- 
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/fb5f8d45-ea18-42ab-bd6e-ddc19fbec3b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Extracting a substring with regex_replace fails

2018-02-14 Thread 'Felix Fontein' via Ansible Project
Hi,

> The task seems obvious at first glance but it appears to be difficult
> to implement in this context.
> The string is:
> host_meta: " xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n  rel='restconf' href='/restconf'/>\n"
> 
> I need to extract the values of rel and href into api_release and
> api_root. I unsuccessfully tried the following:
> - set_fact: api_release="{{ host_meta | regex_replace('^.*
> rel=(.*) .*$', '\\1') }}"
>   when: host_meta is defined
> 
> - set_fact: api_root="{{ host_meta | regex_replace('^.*
> href=(.*)/>.*$', '\\1') }}"
>   when: host_meta is defined
> 
> Both variables contain the whole string instead of the corresponding 
> substring, which should be:
> api_release: 'restconf'
> api_root: /restconf
> 
> I have already successfully used this filter in other contexts. 
> What am I missing here? Is the filter confused by the string?

You are missing the newlines the string contains. regex_replace uses
re.sub() in Python and does not offer a way to set the MULTILINE flag.
If you remove '^' and '$' from your regexps, you can see what happens:
only the matching part between two '\n's is replaced.

Instead of regexp_replace() you should use the regex_search() filter;
that works as expected:

  - set_fact: api_release="{{ host_meta | regex_search('rel=(.*)') }}"
when: host_meta is defined
  - set_fact: api_root="{{ host_meta | regex_search('href=(.*)/>') }}"
when: host_meta is defined

Yields:

  "api_release": "rel='restconf' href='/restconf'/>"
  "api_root": "href='/restconf'/>"

(That's not exactly equal to what you expected, but that is what your
original regexes would have returned if the multiline flag would have
been set. The problem is that regexes are notoriously bad for matching
XML and or HTML.)

Cheers,
Felix



> 


-- 
Felix Fontein -- fe...@fontein.de -- http://felix.fontein.de/

-- 
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/20180214163633.41e78214%40utsjoki.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Extracting a substring with regex_replace fails

2018-02-14 Thread 'Felix Fontein' via Ansible Project
Hi,

instead of using regexes, you might want to use the XML module
(https://docs.ansible.com/ansible/2.4/xml_module.html) with the
xmlstring argument. That should allow you to do this in a much cleaner
way.

Cheers,
Felix



> ansible 2.6.0 (devel da5cf72236) last updated 2018/02/14 14:29:49
> (GMT +200)
> 
> The task seems obvious at first glance but it appears to be difficult
> to implement in this context.
> The string is:
> host_meta: " xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n  rel='restconf' href='/restconf'/>\n"
> 
> I need to extract the values of rel and href into api_release and
> api_root. I unsuccessfully tried the following:
> - set_fact: api_release="{{ host_meta | regex_replace('^.*
> rel=(.*) .*$', '\\1') }}"
>   when: host_meta is defined
> 
> - set_fact: api_root="{{ host_meta | regex_replace('^.*
> href=(.*)/>.*$', '\\1') }}"
>   when: host_meta is defined
> 
> Both variables contain the whole string instead of the corresponding 
> substring, which should be:
> api_release: 'restconf'
> api_root: /restconf
> 
> I have already successfully used this filter in other contexts. 
> What am I missing here? Is the filter confused by the string?
> 

-- 
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/20180214163823.3a305ebc%40utsjoki.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Jinja2 Template and Dictionary issue

2018-02-14 Thread Owen Corcoran
  

Can anyone help me with the below, maybe my approach is wrong. What I’m 
trying to do is to create from a template a keepalived file based on the 
elements in a dictionary.

 

I’ve included the code below, when its ran the error that appears is 

 

msg": "AnsibleUndefinedVariable: 'dict object' has no 
attribute 'hostname'"

 

The error appears to in the second loop in the jinja2 template, where i try 
to extract the elements from the sub lst in the dictionary.

 

ANSIBLE Dictionary 

 

keepalived_virtual_ip:

  - vip_details_1:

haproxy_vip_name: "AddressCleaner_Development"

ip: "1.0.1.2"

front_end_port: 80

haproxy_backend_servers:

   - servers_1.1:

  hostname: system12

  address: 2.0.0.1

   - servers_1.2:

  hostname: system13

  address: 2.0.0.2

 

  - vip_details_2:

haproxy_vip_name: "AddressCleaner_Cert"

ip: "3.0.0.114"

front_end_port: 80

haproxy_backend_servers:

   - servers_2.1:

  hostname: system21

  address: 2.0.0.3

   - servers_2.2:

  hostname: system22

  address: 2.0.0.4

 

 

 

keepalived_virtual_ip:

  - vip_details_1:

haproxy_vip_name: "AddressCleaner_Development"

ip: "3.0.0.115"

front_end_port: 80

haproxy_backend_servers:

   - servers_1.1:

  hostname: lonldpostal01

  address: 3.0.0.87

   - servers_1.2:

  hostname: lonldpostal02

  address: 3.0.0.100

 

  - vip_details_2:

haproxy_vip_name: "AddressCleaner_Cert"

ip: "3.0.0.114"

front_end_port: 80

haproxy_backend_servers:

   - servers_2.1:

  hostname: lonlcpostal01

  address: 3.0.0.96

   - servers_2.2:

  hostname: lonlcpostal02

  address: 3.0.0.104

 

 

 

 

HA PROXY TEMPLATE 

 

 

{% for item in keepalived_virtual_ip %}

 

   listen {{ item.haproxy_vip_name }} {{ item.ip }}:{{ item.front_end_port 
}}

  mode {{ haproxy_mode }}

  balance {{ haproxy_vip_algo }}

   default_backend {{ item.haproxy_vip_name }}_backend

 

{% endfor %}

 

 

 

{% for item in keepalived_virtual_ip %}

backend {{ item.haproxy_vip_name }}_backend

mode tcp

balance source

 

{% for backend in item.haproxy_backend_servers %}

   server {{ backend.hostname }} {{ backend.address }}:{{ 
haproxy_vip_port }} maxconn 9000 send-proxy check

{% endfor %}

 

{% endfor %}
  

-- 
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/6c315659-e24d-42b4-a4f4-918e12b7067c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Are there issue with mass deployment related to SSH?

2018-02-14 Thread cmonty14


Hello!

I have a question that derives from the comparison Ansible vs. Salt.

As Ansible relies on SSH connection some people say that this has a 
downside for a scenario like

   - mass deployment of 1000 servers

Can you confirm that there's a severe performance impact when Ansible 
master must establish SSH connection to 1000+ servers at the same time (for 
mass deployment)?

THX

-- 
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/2565bed2-43d2-45df-b962-e8e12f227261%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ansible with jenkins pipeline

2018-02-14 Thread Sidh
Hi,

Anyone using ansible with jenkins pipeline ?

Can you please point me to some documentation with examples ?

Regards,
Sidh

-- 
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/44e8974f-e402-452d-9921-67a5a8740b86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible and PowerShell 6 (Core)

2018-02-14 Thread lovi


Hello,


I would like to know if it's possible to get ansible working with 
powershell version 6 core : pwsh.exe on remote host with winrm ?


And if not is there a planning for this feature ?


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/703a9e65-aa7e-4ec6-a3d5-3955bdbfc69c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible and PowerShell 6 (Core)

2018-02-14 Thread Balaram R
https://www.virtualtothecore.com/en/configuring-windows-machines-for-ansible/

On Wednesday, February 14, 2018 at 10:19:59 PM UTC+5:30, lovi wrote:
>
> Hello,
>
>
> I would like to know if it's possible to get ansible working with 
> powershell version 6 core : pwsh.exe on remote host with winrm ?
>
>
> And if not is there a planning for this feature ?
>
>
> 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/ebd9b93c-9e66-48af-b592-efda8578d2c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible and PowerShell 6 (Core)

2018-02-14 Thread mattdavi
We've done some experimentation with it, and it's possible, but it required 
"if pwsh do X, else do Y" in several of the core connection methods (around 
hash calculation, etc), as some .NET things have moved around since .NET 
4.0 on the oldest platforms we support.

Just out of curiosity: why is it that you want Ansible to target PS Core? 
We did our initial experiments in the context of trying to support Nano 
Server, but base Nano Server images in 1709 don't even come with PS/WinRM, 
and Microsoft's plan is to continue working with Windows Powershell ("big" 
Powershell) for the foreseeable future.

-Matt

On Wednesday, February 14, 2018 at 8:49:59 AM UTC-8, lovi wrote:
>
> Hello,
>
>
> I would like to know if it's possible to get ansible working with 
> powershell version 6 core : pwsh.exe on remote host with winrm ?
>
>
> And if not is there a planning for this feature ?
>
>
> 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/720fb7bd-c3e6-435f-84f7-b1cbab14ec40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible 2.5.0 Alpha 1 is available

2018-02-14 Thread mattdavi
Sorry about that- some docs reorgs in devel moved that right after we sent 
the release announcement, and the redirects aren't in place yet. New 
location is 
https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.5.html
.

-Matt

On Wednesday, February 14, 2018 at 5:59:20 AM UTC-8, Stas Fomin wrote:
>
>
>  https://docs.ansible.com/ansible/devel/porting_guide_2.5.html 
> 
>   
> — 404
>

-- 
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/6c522cab-f52b-408f-bab6-a68183223867%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] junos error

2018-02-14 Thread 'Daley Okuwa' via Ansible Project
Hello I am trying to backup config on a juniper router without success
and getting an error message 

ansible@ansible-new:/etc/ansible$ ansible-playbook -i  hosts 
backup_config-junos-facts.yml --user=ansible --extra-vars 
"ansible_sudo_pass="
PLAY [collect default set of facts] 

TASK [Gathering Facts] 
*
ok: [10.101.250.41]
TASK [collect default sets of facts and configuration] 
*
An exception occurred during task execution. To see the full traceback, use 
-vvv. The error was: TypeError: argument must be string or read-only 
character buffer, not None
fatal: [10.101.250.41]: FAILED! => {"changed": false, "module_stderr": 
"Traceback (most recent call last):\n  File 
\"/tmp/ansible_vRkO_Y/ansible_module_junos_facts.py\", line 346, in 
\nmain()\n  File 
\"/tmp/ansible_vRkO_Y/ansible_module_junos_facts.py\", line 327, in 
main\ninst.populate()\n  File 
\"/tmp/ansible_vRkO_Y/ansible_module_junos_facts.py\", line 130, in 
populate\nreply = self.rpc('get-software-information')\n  File 
\"/tmp/ansible_vRkO_Y/ansible_module_junos_facts.py\", line 118, in 
rpc\nreturn send_request(self.module, Element(rpc))\n  File 
\"/tmp/ansible_vRkO_Y/ansible_modlib.zip/ansible/module_utils/netconf.py\", 
line 42, in send_request\n  File 
\"/tmp/ansible_vRkO_Y/ansible_modlib.zip/ansible/module_utils/connection.py\", 
line 66, in exec_command\n  File \"/usr/lib/python2.7/socket.py\", line 
228, in meth\nreturn getattr(self._sock,name)(*args)\nTypeError: 
argument must be string or read-only character buffer, not None\n", 
"module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
 [WARNING]: Could not create retry file '/etc/ansible/backup_config-junos-
facts.retry'. [Errno 13] Permission denied: u'/etc/ansible
/backup_config-junos-facts.retry'


This is the code 
---
- name: collect default set of facts
  hosts: 10.101.250.41
  connection: local
  tasks:
  - name: collect default sets of facts and configuration
junos_facts:
  gather_subset: config

-- 
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/5c14f180-f022-4da8-a266-1ba71ef5f2d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Extracting a substring with regex_replace fails

2018-02-14 Thread Kai Stian Olstad
On Wednesday, 14 February 2018 16.36.33 CET 'Felix Fontein' via Ansible Project 
wrote:
> > The task seems obvious at first glance but it appears to be difficult
> > to implement in this context.
> > The string is:
> > host_meta: " > xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n  > rel='restconf' href='/restconf'/>\n"
> > 
> > I need to extract the values of rel and href into api_release and
> > api_root. I unsuccessfully tried the following:
> > - set_fact: api_release="{{ host_meta | regex_replace('^.*
> > rel=(.*) .*$', '\\1') }}"
> >   when: host_meta is defined
> > 
> > - set_fact: api_root="{{ host_meta | regex_replace('^.*
> > href=(.*)/>.*$', '\\1') }}"
> >   when: host_meta is defined
> 
> You are missing the newlines the string contains. regex_replace uses
> re.sub() in Python and does not offer a way to set the MULTILINE flag.
> If you remove '^' and '$' from your regexps, you can see what happens:
> only the matching part between two '\n's is replaced.


It's possible to turn on multiline, but the dot doesn't match newline so DOTALL 
flag need to be set to.

This can be done with (?mS), "m" is multiline and "S" is DOTALL.

So this should work:

- set_fact:
api_release: "{{ host_meta | regex_replace('(?ms)^.* rel=(.*) .*$', '\\1') 
}}"


-- 
Kai Stian Olstad

-- 
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/3038237.GlpWJfDGSG%40x1.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread Kai Stian Olstad
On Wednesday, 14 February 2018 15.57.02 CET jn.be...@gmail.com wrote:
> Hi Kai
> 
> You used the variable in a playbook, maybe that works. But I want to make 
> sure that the role is not being executed when someone forgets to set the 
> variable.
> So the trick here is: "{{ APPLICATIONNAME }}" is not set.
> Normaly this is a variable in vars/app1.yml
> Here is the full code:

The full code make is clear whats happening.


> /vars/app1.yml
> ---
> #APPLICATIONNAME: "app1"
> #normally this var is set, but we want to provoke an error
> 
> 
> 
> playbook.yml
> ---
>  - name: play1
>hosts: app1
>vars_files:
>- "vars/app1.yml"
> 
>   tasks:
>   - include_role:
>   name: role1
> vars:
>   applicationname: "{{ APPLICATIONNAME }}"
>   description: "{{ DESCRIPTION }}"
> 
> 
> /roles/defaults/main.yml
> ---
> required_vars:
>  - applicationname
> 
> applicationname: ""
> description: ""

role default will always set applicationname to "" and therefor always be 
defined.
So checking if that variable "is not defined" has no purpose since it will be 
defined.


-- 
Kai Stian Olstad

-- 
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/1556662.FaPZ0SOvf3%40x1.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Trouble with win_package

2018-02-14 Thread Dimitri Yioulos
All,

I'm running version 2.3 (can't update to 2.4 just yet) and, despite what 
should be super stupid simple, I've never been able to get win_package to 
work.  I've changed up my win_package play in every conceivable way, but no 
joy.  Here's my basic set-up, which is taken directly from the doc:

---

- hosts: all
  gather_facts: false

  tasks:

- name: install hotfix kb3140245
  win_package:
path: 
C:\temp\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu'
product_id: 'MicrosoftTLS'
arguments: '/quiet /norestart'
state: present

Here's the error I get:

fatal: [acampos10]: FAILED! => {"changed": false, "failed": true, "msg": 
"The given Path 
(C:\\temp\\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu')
 
could not be found", "name": 
"C:\\temp\\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu'"}

OK, so it looks like the backslashes are causing the problem.  But, I've 
tried many things to account for that, without success.  Would someone be 
kind enough to point out what I'm doing wrong?

Thanks.

-- 
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/c57ded19-ef18-4040-a936-473238fd80cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Trouble with win_package

2018-02-14 Thread Dimitri Yioulos
path should read:

path: C:\temp\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c65
8e52a0dec0.msu

On Wednesday, February 14, 2018 at 1:16:43 PM UTC-5, Dimitri Yioulos wrote:
>
> All,
>
> I'm running version 2.3 (can't update to 2.4 just yet) and, despite what 
> should be super stupid simple, I've never been able to get win_package to 
> work.  I've changed up my win_package play in every conceivable way, but no 
> joy.  Here's my basic set-up, which is taken directly from the doc:
>
> ---
>
> - hosts: all
>   gather_facts: false
>
>   tasks:
>
> - name: install hotfix kb3140245
>   win_package:
> path: 
> C:\temp\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu'
> product_id: 'MicrosoftTLS'
> arguments: '/quiet /norestart'
> state: present
>
> Here's the error I get:
>
> fatal: [acampos10]: FAILED! => {"changed": false, "failed": true, "msg": 
> "The given Path 
> (C:\\temp\\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu')
>  
> could not be found", "name": 
> "C:\\temp\\windows6.1-kb3140245-x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu'"}
>
> OK, so it looks like the backslashes are causing the problem.  But, I've 
> tried many things to account for that, without success.  Would someone be 
> kind enough to point out what I'm doing wrong?
>
> Thanks.
>

-- 
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/e8c80338-37da-4730-aae4-25ee7ec6f7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Are there issue with mass deployment related to SSH?

2018-02-14 Thread Andrew Latham
I suggest you start with reading about
http://docs.ansible.com/ansible/latest/intro_configuration.html#forks

On Wed, Feb 14, 2018 at 10:23 AM, cmonty14 <74cmo...@gmail.com> wrote:

> Hello!
>
> I have a question that derives from the comparison Ansible vs. Salt.
>
> As Ansible relies on SSH connection some people say that this has a
> downside for a scenario like
>
>- mass deployment of 1000 servers
>
> Can you confirm that there's a severe performance impact when Ansible
> master must establish SSH connection to 1000+ servers at the same time (for
> mass deployment)?
>
> THX
>
> --
> 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/2565bed2-43d2-45df-b962-e8e12f227261%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
- Andrew "lathama" Latham -

-- 
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/CA%2Bqj4S9DssXKe7LZj0FwvjhHyBs0ieJ6X-y0kWLozkq7LHL5pA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Jinja2 Template and Dictionary issue

2018-02-14 Thread Kai Stian Olstad
On Wednesday, 14 February 2018 17.07.00 CET Owen Corcoran wrote:
> keepalived_virtual_ip:
>   - vip_details_1:
> haproxy_vip_name: "AddressCleaner_Development"
> ip: "1.0.1.2"
> front_end_port: 80
> haproxy_backend_servers:
>- servers_1.1:
>   hostname: system12
>   address: 2.0.0.1
>- servers_1.2:
>   hostname: system13
>   address: 2.0.0.2
>  

It's not allowed to have . (dot) in variable name only letters, numbers and 
underscores is allowed so servers_1.1: is invalid 


> {% for item in keepalived_virtual_ip %}
> backend {{ item.haproxy_vip_name }}_backend
> mode tcp
> balance source
> {% for backend in item.haproxy_backend_servers %}
>server {{ backend.hostname }} {{ backend.address }}:{{ 
> haproxy_vip_port }} maxconn 9000 send-proxy check
> {% endfor %}
> {% endfor %}
>   

Lets say that servers_1.1: is servers_1_1:, the same for server_1.2


item.haproxy_backend_server is a list of dictonary, the hostname is not 
backend.hostname but
backend.servers_1_1.hostname and backend.servers_1_2.hostname


-- 
Kai Stian Olstad

-- 
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/3490142.gy42nNLA3x%40x1.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Trouble with win_package

2018-02-14 Thread Jordan Borean
There are a few issues you will come across;

* You figured out that the path shouldn't have the end single quote, unless 
you are start the path with a single quote. No need to escape the 
backslashes unless you enclose it in double quotes
* While you specify the path as .msu, win_package doesn't have any smarts 
in place to automatically use wusa.exe to install the hotfix, you need to 
modify the path and arguments to use wusa.exe
* There is the win_hotfix module in 2.4 but this isn't available for Server 
2008, 2008 R2 without lots of messing around so for this hotfix it probably 
won't matter but I've included an example anyway

The final issue is that on a WinRM process any access to the Windows Update 
API like wusa.exe will fail with access is denied, you need to escape the 
Network Logon process to get it working, there are multiple ways of doing 
this currently

* Use Ansible and become to become an interactive process, while this was 
added in 2.3 it was experimental and only worked in certain situations. I 
would recommend you upgrade to 2.5 when it is out as it is no longer 
experimental and quite easy to use
* Use a scheduled task to run the process, this works but it quite 
cumbersome to setup and run so I won't give an example
* Use psexec and the win_psexec module, it requires the psexec executable 
downloaded onto the host and chocolately can do that for you

Because you are on an older Ansible version the psexec option will be the 
easiest way for you to move forward so I recommend you look into that.


# on 2.5 you could do the following for most Windows hosts
- name: install hotfix KB3140245
  win_package:
path: C:\Windows\System32\wusa.exe
arguments: C:\temp\windows6.1-kb3140245-
x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu /quiet /norestart
product_id: MicrosoftTLS
state: present
  register: hotfix_install
  become: yes
  become_method: runas
  become_user: SYSTEM

- name: reboot if required
  win_reboot:
  when: hotfix_install.reboot_required



# or from 2.4 onwards and Server 2012 or newer you can use win_hotfix (I 
know this is for Server 2008 R2 but keeping it here as an example for other 
updates)
- name: install hotfix KB3140245
  win_hotfix:
path: C:\temp\windows6.1-kb3140245-
x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu
hotfix_kb: KB3140245
state: present
  register: hotfix_install

- name: reboot host if required
  win_reboot:
  when: hotfix_install.reboot_required



# finally if you cannot upgrade Ansible versions, you can get it working 
with psexec by running these tasks
- name: make sure psexec is installed locally
  win_chocolatey:
name: psexec
state: present

- name: check if hotfix KB3140245 is installed
  win_shell: if (Get-Hotfix -Id KB3140245 -ErrorAction SilentlyContinue) { 
"true" } else { "false" }
  register: hotfix_installed

- name: install hotfix if not installed
  win_psexec:
command: C:\Windows\System32\wusa.exe C:\temp\windows6.1-kb3140245-
x64_5b067ffb69a94a6e5f9da89ce88c658e52a0dec0.msu /quiet /norestart
system: yes
  register: hotfix_install_out
  failed_when: hotfix_install_out.rc not in [0, 3010]
  when: hotfix_installed.stdout_lines[0] == "false"

- name: reboot system if required
  win_reboot:
  when: hotfix_install_out.rc == 3010



Thanks

Jordan

-- 
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/0be99f3e-a9ed-4ee3-8720-aacbffd30d15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] BUG or Operating As Designed?

2018-02-14 Thread John Harmon
I have the following playbook:
---
- hosts: "{{ host }}"

  roles:
- ansible_dependencies
- aliases
- dns_update
- cpu_utilization
- role: nagios
  install: yes
- password_policy
- role: disable_NetworkManager
  new_install: yes
- ldap_users
- ps1_customize
- vim_customize
- sudoers
- grub_cmdline_oracle_tuning

- import_playbook: /playbooks/one-offs/bash_history.yml
- import_playbook: /playbooks/one-offs/dmesg_timestamps.yml
- import_playbook: /playbooks/one-offs/grub_cmdline.yml
- import_playbook: /playbooks/one-offs/update_gitlab_scripts.yml
- import_playbook: /playbooks/one-offs/grub_timeout.yml
- import_playbook: /playbooks/one-offs/update_sssd_ddns.yml
- import_playbook: /playbooks/one-offs/authconfig_cleanup.yml
- import_playbook: /playbooks/one-offs/change_timezone.yml
- import_playbook: /playbooks/one-offs/firefox_no_gui.yml
- import_playbook: /playbooks/one-offs/tcp_tuning.yml

In the middle of disable_NetworkManager I have the following.  It works 
perfectly stand-alone.
- meta: end_play
  when: nm_installed.rc != 0 and new_install

When this is encountered it skips the remaining roles of my playbook (and 
continues on with my import_playbook sections).
The following get skipped:
- ldap_users
- ps1_customize
- vim_customize
- sudoers
- grub_cmdline_oracle_tuning

I expected it to end the play for disable_networkManager, and then continue 
on with the rest of the roles.  Is this the way it is supposed to operate 
in this situation? is there a better approach to it?  Or does this sound 
like a bug?

-- 
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/a114f93b-4365-48df-a3ad-79658047cb62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] BUG or Operating As Designed?

2018-02-14 Thread Matt Martz
A play encompasses `pre_tasks`, `roles`, `tasks`, and `post_tasks`.  You
are expecting it to end the role.

Perhaps you should instead move all subsequent tasks of that role into a
block or another file and use include_tasks, and then apply the `when`
statement to that (but reverse the logic).

On Wed, Feb 14, 2018 at 1:48 PM, John Harmon 
wrote:

> I have the following playbook:
> ---
> - hosts: "{{ host }}"
>
>   roles:
> - ansible_dependencies
> - aliases
> - dns_update
> - cpu_utilization
> - role: nagios
>   install: yes
> - password_policy
> - role: disable_NetworkManager
>   new_install: yes
> - ldap_users
> - ps1_customize
> - vim_customize
> - sudoers
> - grub_cmdline_oracle_tuning
>
> - import_playbook: /playbooks/one-offs/bash_history.yml
> - import_playbook: /playbooks/one-offs/dmesg_timestamps.yml
> - import_playbook: /playbooks/one-offs/grub_cmdline.yml
> - import_playbook: /playbooks/one-offs/update_gitlab_scripts.yml
> - import_playbook: /playbooks/one-offs/grub_timeout.yml
> - import_playbook: /playbooks/one-offs/update_sssd_ddns.yml
> - import_playbook: /playbooks/one-offs/authconfig_cleanup.yml
> - import_playbook: /playbooks/one-offs/change_timezone.yml
> - import_playbook: /playbooks/one-offs/firefox_no_gui.yml
> - import_playbook: /playbooks/one-offs/tcp_tuning.yml
>
> In the middle of disable_NetworkManager I have the following.  It works
> perfectly stand-alone.
> - meta: end_play
>   when: nm_installed.rc != 0 and new_install
>
> When this is encountered it skips the remaining roles of my playbook (and
> continues on with my import_playbook sections).
> The following get skipped:
> - ldap_users
> - ps1_customize
> - vim_customize
> - sudoers
> - grub_cmdline_oracle_tuning
>
> I expected it to end the play for disable_networkManager, and then
> continue on with the rest of the roles.  Is this the way it is supposed to
> operate in this situation? is there a better approach to it?  Or does this
> sound like a bug?
>
> --
> 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/a114f93b-4365-48df-a3ad-79658047cb62%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v_YRQnz%3DqarOnb4nTYnnRC1f0%2BOd%2BOGDP%3DYKOajLN_Quw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] BUG or Operating As Designed?

2018-02-14 Thread Brian Coca
a way to do this is having a block on whole role and a rescue that
checks for the error, which allows you to make a  'skip rest' kind
facility.



-- 
--
Brian Coca

-- 
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/CACVha7fC-v9RPb%3DdObUSOi%2B5N9-aj5%3DtqKq65fUdptBmaN3xdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Jinja2 Template and Dictionary issue

2018-02-14 Thread Owen Corcoran
Could i have instead of :

Servers_1.1
Servers_1.2
Servers_2.1
Servers_2.2
Servers_3.1
Servers_3.2


Call each list

servers

The reason being i dont want to have to hard code names in the jinja2
template of the elements in the lists of backends, depending on the size of
the dictionary i might shink or add hosts/backends and i want the template
to dynamically pick these additions or substractions without a code change
in the template file.

On Wed, Feb 14, 2018 at 6:36 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On Wednesday, 14 February 2018 17.07.00 CET Owen Corcoran wrote:
> > keepalived_virtual_ip:
> >   - vip_details_1:
> > haproxy_vip_name: "AddressCleaner_Development"
> > ip: "1.0.1.2"
> > front_end_port: 80
> > haproxy_backend_servers:
> >- servers_1.1:
> >   hostname: system12
> >   address: 2.0.0.1
> >- servers_1.2:
> >   hostname: system13
> >   address: 2.0.0.2
> >
>
> It's not allowed to have . (dot) in variable name only letters, numbers
> and underscores is allowed so servers_1.1: is invalid
>
>
> > {% for item in keepalived_virtual_ip %}
> > backend {{ item.haproxy_vip_name }}_backend
> > mode tcp
> > balance source
> > {% for backend in item.haproxy_backend_servers %}
> >server {{ backend.hostname }} {{ backend.address }}:{{
> haproxy_vip_port }} maxconn 9000 send-proxy check
> > {% endfor %}
> > {% endfor %}
> >
>
> Lets say that servers_1.1: is servers_1_1:, the same for server_1.2
>
>
> item.haproxy_backend_server is a list of dictonary, the hostname is not
> backend.hostname but
> backend.servers_1_1.hostname and backend.servers_1_2.hostname
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/JsvtwiHeyvE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/3490142.gy42nNLA3x%40x1.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Thanks
Owen Corcoran

-- 
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/CAMXBBpiaf-J_-CcG6fcW%3D6gthkea8exuHvgUt7n_rS%3DGHz5SPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Run pre/post tasks once with serial 1

2018-02-14 Thread Michael Perzel
I have a playbook where I would like to do a task once before starting a 
couple roles and once after roles with serial 1. I thought I could 
accomplish this with pre and post tasks but it looks like they are called 
once per server.

---
- name: Pre Post Task Test
  hosts: "linux"
  gather_facts: false
  any_errors_fatal: true
  serial: 1
  pre_tasks:
  - shell: echo "pre"

  tasks:
  - shell: echo "tasks"

  post_tasks:
  - shell: echo "post"

Results in:
PLAY [Hello World Linux] 


TASK [command] 
**
changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"pre\"", "delta": 
"0:00:00.002576", "end": "2018-02-14 15:27:31.198276", "rc": 0, "start": 
"2018-02-14 15:27:31.195700", "stderr": "", "stderr_lines": [], "stdout": 
"pre", "stdout_lines": ["pre"]}

TASK [command] 
**
changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"tasks\"", 
"delta": "0:00:00.003271", "end": "2018-02-14 15:27:37.240087", "rc": 0, 
"start": "2018-02-14 15:27:37.236816", "stderr": "", "stderr_lines": [], 
"stdout": "tasks", "stdout_lines": ["tasks"]}

TASK [command] 
**
changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"post\"", "delta": 
"0:00:00.002614", "end": "2018-02-14 15:27:43.29", "rc": 0, "start": 
"2018-02-14 15:27:43.291830", "stderr": "", "stderr_lines": [], "stdout": 
"post", "stdout_lines": ["post"]}

PLAY [Hello World Linux] 


TASK [command] 
**
changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"pre\"", "delta": 
"0:00:00.002461", "end": "2018-02-14 15:27:44.875867", "rc": 0, "start": 
"2018-02-14 15:27:44.873406", "stderr": "", "stderr_lines": [], "stdout": 
"pre", "stdout_lines": ["pre"]}

TASK [command] 
**
changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"tasks\"", 
"delta": "0:00:00.002899", "end": "2018-02-14 15:27:45.271244", "rc": 0, 
"start": "2018-02-14 15:27:45.268345", "stderr": "", "stderr_lines": [], 
"stdout": "tasks", "stdout_lines": ["tasks"]}

TASK [command] 
**
changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"post\"", "delta": 
"0:00:00.002650", "end": "2018-02-14 15:27:45.664172", "rc": 0, "start": 
"2018-02-14 15:27:45.661522", "stderr": "", "stderr_lines": [], "stdout": 
"post", "stdout_lines": ["post"]}

PLAY RECAP 
**
mdl-swch01 : ok=3changed=3unreachable=0failed=0
mdl-swch02 : ok=3changed=3unreachable=0failed=0


I am looking for something that would do:
pre tasks
tasks for mdl-swch01
tasks for mdl-swch02
post tasks

Any ideas on how to accomplish this?


-- 
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/61aa41c2-3ecc-4822-8644-cd68308d8d7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] win_scheduled_task : run the scheduled task every minute

2018-02-14 Thread ktesr123456
Team,

Is there any option to run the scheduled task every minute. in the 
documentation i see the frequency is either once or daily or weekly

I am referring to "Advance Settings" from Trigger of Windows Scheduled task

Thanks.

-- 
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/88c4b878-8b93-47de-826a-4e28e484dec6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Run pre/post tasks once with serial 1

2018-02-14 Thread Brian Coca
you want run_once, not serial




-- 
--
Brian Coca

-- 
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/CACVha7eJsHrPYLAXb%2BF-CQ5SVveDtzDnYnBrCMum0xKUByspEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Roles are download to a different directory when running ansible-galaxy install?

2018-02-14 Thread ZillaYT
Ansible v2.4.0.0

I have a requirements file that specifies the Git repo for each role that I 
want to use in my playbook, and I do the following to install the roles 
from our internal galaxy

cd /path_to_playbook
ansible-galaxy install -r requirements/requirements1.yml -p ./roles


and I expect the roles to be download in /path_to_playbook/roles, but 
instead are downloaded in /home/myuser/.ansible/roles. My ansible.cfg file 
does NOT have the roles path defined, and I don't want it to. Any ideas why?

-- 
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/06fb6002-e707-41fb-ad34-973ac8c510ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Run pre/post tasks once with serial 1

2018-02-14 Thread Michael Perzel
My real use case is a patching playbook. I have a collection of servers I 
want to patch one at a time (serial: 1) but there are a set of decommision 
steps I only want to run once for the entire group. Then patch the servers 
one by one. Then there is a set of commission tasks I want to run once for 
the entire group. If I put run once on the pre/post tasks. It still gets 
run once per play eg once per host.

If it helps, the full context is this is a cassandra cluster. I want to 
stop the repair service, patch the whole cluster 1 node at a time, then 
start the repair service.

On Wednesday, February 14, 2018 at 4:34:50 PM UTC-6, Brian Coca wrote:
>
> you want run_once, not serial 
>
>
>
>
> -- 
> -- 
> Brian Coca 
>

-- 
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/baf86475-f5b3-4ae1-bc0e-f71f1a8658c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] BUG? 'AnsibleSequence' object has no attribute 'strip'

2018-02-14 Thread Brian Coca
Actually, you should write it like this:

- import_playbook: /playbooks/one-offs/bash_history.yml
  vars:
host: "{{ host }}"

- import_playbook: /playbooks/one-offs/dmesg_timestamps.yml
  vars:
 host: "{{ host }}"


-- 
--
Brian Coca

-- 
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/CACVha7c9FWTJqaWAyk%2B%2Bq%3DyPaQrjbg5JuGbxxEYDNfL92w%2BbEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Run pre/post tasks once with serial 1

2018-02-14 Thread Kai Stian Olstad

On 15.02.2018 00:08, Michael Perzel wrote:
My real use case is a patching playbook. I have a collection of servers 
I
want to patch one at a time (serial: 1) but there are a set of 
decommision
steps I only want to run once for the entire group. Then patch the 
servers
one by one. Then there is a set of commission tasks I want to run once 
for
the entire group. If I put run once on the pre/post tasks. It still 
gets

run once per play eg once per host.

If it helps, the full context is this is a cassandra cluster. I want to
stop the repair service, patch the whole cluster 1 node at a time, then
start the repair service.


How to make this work is documented under note section of run_once.
http://docs.ansible.com/ansible/latest/playbooks_delegation.html#run-once

--
Kai Stian Olstad

--
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/5a8c7bc13fafd72fc1c7a986e77ae5bb%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Jinja2 Template and Dictionary issue

2018-02-14 Thread Kai Stian Olstad

On 14.02.2018 21:54, Owen Corcoran wrote:

Could i have instead of :


Servers_1.1
Servers_1.2
Servers_2.1
Servers_2.2
Servers_3.1
Servers_3.2


Call each list

servers


The easiest to do is make haproxy_backend_servers a list of dictionaries 
and not a list of dictionary.


So if you can change you haproxy_backend_servers to

haproxy_backend_servers:
  - name: servers_1.1
hostname: system12
address: 2.0.0.1
  - name: servers_1.2:
hostname: system13
address: 2.0.0.2

You code will work as is since you can call backend.hostname and not 
backend..hostname



--
Kai Stian Olstad

--
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/6cd57575dff4773a6549c065f7c573de%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: win_scheduled_task : run the scheduled task every minute

2018-02-14 Thread Jordan Borean
In the latest release it isn't possible to do with the current 
win_scheduled_task module. For 2.5 the module was drastically rewritten and 
supports this scenario, you can find the latest docs for it here 
http://docs.ansible.com/ansible/devel/modules/win_scheduled_task_module.html.

Using your example this is how it could possibly be done with the new 
format in 2.5

- name: create scheduled task to run every minute
  win_scheduled_task:
name: task name here
actions:
- path: cmd.exe
  arguments: /c echo hello world
triggers:
- type: registration
  repetition:
  - interval: PT1M
duration: '' # an empty value should mean it last infinitely


What this means is that a task that run "cmd.exe /c echo hello world" will 
create a registration trigger and run that every minute indefinitely. The 
registration trigger just means start the task on registration.

Thanks

Jordan

-- 
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/321d1d6b-20bb-44ef-9c51-345d66defe10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Checking for undefined, empty or null variables

2018-02-14 Thread jn . bedag
I don't fully agree with you.
Because I set "applicationname" to "{{ APPLICATIONNAME }}" when I call the 
role in the playbook:


- include_role: 
name: role1 
  vars: 
applicationname: "{{ APPLICATIONNAME }}" 
description: "{{ DESCRIPTION }}"

Problem is, that "{{ APPLICATIONNAME }}" at this point is undefined.

And again, I think the problem with 
- name: check required vars when applicationname is not defined
  debug: msg="Variable '{{ item }}' is not defined"
  when: vars[item] is not defined
  with_items: "{{ required_vars }}" 

is, that vars[item] is not undefined.
Why? Because "applicationname" seems to have a value:


TASK [role1 : debug] ***

ok: [server1] => {
"vars": {

"applicationname": "{{ APPLICATIONNAME }}"
}
}

Maybe it is misinterpreted as a string "{{ APPLICATIONNAME }}"
Therefore, when: vars[item] is not defined does not work as expected

Hope you can follow me.







-- 
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/416e6a40-37a3-4791-a3da-2d14b6792bbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.