[ansible-project] Help on using the wen condition

2020-01-24 Thread Daniel Nanboe
I have a list of users defined as variable on my inventory.

I want to create a task that checks if for each user exists a file in a 
folder if it exists will run a task if not will run an other task. I have a 
task that add the user with password if password exists and no ssh key is 
found and another that adds the user with both password and key.


This one checks if there is an ssh key defined for the client:

- name: Add sftp users
  block:
- name: Check if diapason folder exists
  stat:
path: "SYMPHONY_HOME + '/config/ssh_keys/clients/keys/{{ 
item.ssh_key }}.pub"
  register: sshkey_status
  with_items: "{{ sftp_users }}"

And then I want to use the info in a conditional

- name: Add sftp users with ssh key
  user:
name: "{{ item.remote_user }}"
state: "{{ item.state | default('present') }}"
shell: /usr/bin/false
skeleton: yes
group: "{{ item.remote_user }}"
groups:
  - sftpgroup
  with_items: "{{ sftp_users }}"
  when: (item.state != "absent") and (sshkey_status.stat.exists == 
true)

The problem is that sshkey_status is a variable with a list for each user 
from the user list and I cannot use it like that. I have te required info 
there but not sure how to get to it in the when statement.

Can somebody point me towards a working direction.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0f5deb45-7895-49f7-acf6-02af9a88ba8f%40googlegroups.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-24 Thread Srinivas Naram
Ok, I found the solution myself. Group or host variables should have
different directory. There is no need of explicit mention such as  in the playbook, but create a directory called group_vars or
host_vars in the directory where the playbook is placed.

these directories will have files with variables you want to define. File
structure should be in yml format.



On Thu, Jan 23, 2020 at 2:19 PM Srinivas Naram 
wrote:

> Suggestions please.
>
> On Wed, Jan 22, 2020 at 9:43 AM Srinivas Naram 
> wrote:
>
>> Any suggestions would be greatly appreciated.
>>
>> On Tue, Jan 21, 2020 at 8:05 PM Srinivas Naram 
>> wrote:
>>
>>> Hello Vladimir
>>>
>>> I have followed exactly same steps mentioned above and I see different
>>> errors now.
>>>
>>> My steps
>>>
>>> - Set the Ansible Vault password file Env variable
>>> - Create the vault encrypted file
>>> - Create directories and copy files in specific location. My dir
>>> structure
>>> playbooks
>>>|- vault
>>>   |-testing.yml
>>>   |-host_vars
>>>|- 192.168.249.107
>>> |- test.yml
>>>
>>> I get following error
>>>
>>> Error - ERROR! failed to combine variables, expected dicts but got a
>>> 'dict' and a 'AnsibleUnicode':{} "testing123:sensitive"
>>>
>>> When I change the directory structure in host_vars to groupname
>>> playbooks
>>>|- vault
>>>   |-testing.yml
>>>   |-host_vars
>>>|- ansible_enddevice_2
>>> |- test.yml
>>>
>>> I get different message
>>>
>>> ok: [ 192.168.249.107 ] => { "testing123": "VARIABLE IS NOT DEFINED!" }
>>>
>>> My inventory file structure
>>>
>>> [ansible_enddevice_2]
>>> 192.168.249.107
>>>
>>>
>>>
>>> On Tue, Jan 21, 2020 at 4:48 PM Vladimir Botka  wrote:
>>>
 On Tue, 21 Jan 2020 15:31:33 +0530
 Srinivas Naram  wrote:

 > I am trying to maintain password (encrypted using ansible-vault) and
 my
 > playbook (clear-text) in separate files.

 Below is a step-by-step scenario:

 1) Let's assume the vault password has bee configured properly (you
 have set
 the 'vault_password_file' in ansible.cfg) . Let's use global variable
 here.
 For example

   $ set | grep VAULT
   ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt

 See "Providing Vault Passwords"

 https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords

 2) Create a file foo.yml with variable(s). Encrypt the file. See the
 content.

   $ cat foo.yml
   test_var1: secret
   $ ansible-vault encrypt foo.yml
   $ cat foo.yml
   $ANSIBLE_VAULT;1.1;AES256

 3933376636373537313366326361306331333132626337343335343465353439623366373338

 6438306562323262363965653336653362616136366439620a326533316463346437373066333433

 3035333662373330376261363963613833366631386531633064323733313936663831393731

 3036633964323235310a613766346633613765643832306539346137613731663865636564636164
   61303534393363616263666564636366303861623131306536316432383230393736
   $ ansible-vault view foo.yml
   test_var1: secret1

 See "Encrypting Unencrypted Files"

 https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-unencrypted-files

 3) Create inventory (fit the groups and hosts to your needs)

   $ cat hosts
   [test]
   test_01

 4) Put the encrypted file into the directory host_vars (fit the host to
 your
 needs)

   $ mkdir -p host_vars/test_01
   $ mv foo.yml host_vars/test_01/

 5) Create and run playbook. See the variable was successfully decrypted.

   $ cat test.yml
   - hosts: test_01
 tasks:
 - debug:
 var: test_var1
   $ ansible-playbook test1.yml
   ok: [test_01] => { "test_var1": "secret1" }

 There are many variations how-to handle vault variables. If you have
 troubles
 report minimal, complete, reproducible example.


 HTH,

 -vlado

>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P66fx-%3D8svSK_RW_DPgm6zB1J6tRRewDgk15sdbrfOj_w%40mail.gmail.com.


[ansible-project] Re: can someone please explain about "undefined" error

2020-01-24 Thread 'Eric Hymowitz' via Ansible Project
At the risk of being rude, I'm not sure what you don't understand.

You're querying a hash variable update_count , and looking for the member 
named reboot_required .  Where did you define this variable?  If you don't 
define a variable, then the variable is undefined.

Is there more to this playbook that you didn't provide?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5c5985b8-32a6-4334-aa09-c0e8814af823%40googlegroups.com.


Re: [ansible-project] Re: can someone please explain about "undefined" error

2020-01-24 Thread Karl Auer
To expand on what Eric said:

Your when: condition refers to a variable called "update_count".

At the point where you refer to it, that variable does not exist. I bolded
the bits of the error message that really matter:

TASK [reboot if required] **

**
task path: /etc/ansible/windows-playbook/copied.yml:22
*fatal*: [EC2AMAZ-9M186EG.corp.medqia.com]: FAILED! => {
"msg": "The conditional check 'update_count.reboot_required' failed.
The error was: error while evaluating conditional
(update_count.reboot_required): *'update_count' is undefined*\n\n.\n\nThe
offending line appears to be:\n\n  tasks:\n   - name: reboot if required\n
   ^ here\n"
}

Common reasons for this error include:
- you misspelled it
- you got the CaPiTaLiSaTiOn wrong
- you defined it after first reference
- you defined it for a host other than EC2AMAZ-9M186EG.corp.medqia.com
- you defined it in a vars file that is not being loaded
- you defined it in a vars file that is not being referenced
- you defined it somewhere where it cannot be referenced
- you rearranged your code and accidentally moved the definition to after
the first reference
- update_count is a field or element of something bigger you forgot to
reference first
- you didn't define it at all

If you'd like more help, post the ENTIRE playbook here (or make it
available in e.g. pastebin). Don't post anything confidential though.

Please post code in a fixed-width font so we can see the indentation.

Regards, K.

On Sat, Jan 25, 2020 at 12:24 AM 'Eric Hymowitz' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> At the risk of being rude, I'm not sure what you don't understand.
>
> You're querying a hash variable update_count , and looking for the member
> named reboot_required .  Where did you define this variable?  If you don't
> define a variable, then the variable is undefined.
>
> Is there more to this playbook that you didn't provide?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5c5985b8-32a6-4334-aa09-c0e8814af823%40googlegroups.com
> 
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RC00nc_zFqQSboYEkXASjPSSkEhqnfdzh%3DikH8Obnx3Q%40mail.gmail.com.


[ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Rakesh Parida
Hi 

Iam trying to access the variable from other hosts using hostvars. I am 
getting the undefined error.
Can anybody help me: stuck at this point



- hosts: yum
  gather_facts: false
  vars:
 file_locn: "/san/repos/{{ version }}/packages"
  tasks:
- name: Find the Packages that are present in File location
  shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
  register: files_present

- name: Set Fact
  set_fact:
 some_value: "{{ files_present.stdout_lines }}"

- debug:
msg: "{{ some_value }}"

- hosts: localhost
  gather_facts: false
  tasks:
- name: Show hostvars
  debug:
msg: "{{ hostvars['yum']['some_value'] }}"

error:
PLAY [yum] 
***

TASK [Find the Packages that are present in File location] 
***
changed: [YUM01]

TASK [Set Fact] 
**
ok: [YUM01]

TASK [debug] 
*
ok: [YUM01] => {
"msg": [
"common-3.0.12.rpm", 

]
}

PLAY [localhost] 
*

TASK [Show hostvars] 
*
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an 
undefined variable. The error was: \"hostvars['yum']\" is undefined\n\nThe 
error appears to be in '/home/rparida1/raka.yml': line 20, column 7, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n  tasks:\n- name: Show 
hostvars\n  ^ here\n"}

PLAY RECAP 
***
YUM01   : ok=3changed=1unreachable=0failed=0
skipped=0rescued=0ignored=0   
localhost  : ok=0changed=0unreachable=0
failed=1skipped=0rescued=0ignored=0  

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com.


[ansible-project] How to a activate ONOS apps by ansible-playbook?

2020-01-24 Thread Ivy Min
 

My ansible-playbook version is latest. I try to activate ONOS service in 
docker container by running ansible-playbook. I tried some ways. However 
they all failed.

---
- hosts: local
  tasks:
  - name: Create a onos-a container
docker_container:
  name: onos-a
  image: onosproject/onos 
  restart: yes
  ports: 8190:8190 

  - name: Activate onos-a fwd apps #failed by shell
shell: "docker exec -it onos-a bash -c 
'/root/onos/apache-karaf-4.2.6/bin/client app activate 
org.onosproject.openflow'"
become: yes
  - name: Activate onos-a apps #fialed by commands
docker_container:
   name: onos-a
   command: export ONOS_APPS=fwd
   command: export ONOS_APPS=openflow

Need some help ~

when I running shell command, the error shows

   "changed": true, 
"cmd": "sudo docker exec -it onos_b bash -c 
'/root/onos/apache-karaf-4.2.6/bin/client app activate 
org.onosproject.openflow'", 
"delta": "0:00:03.291473", 
"end": "2020-01-23 20:00:33.229114", 
"invocation": {
"module_args": {
"_raw_params": "sudo docker exec -it onos_b bash -c 
'/root/onos/apache-karaf-4.2.6/bin/client app activate 
org.onosproject.openflow'", 
"_uses_shell": true, 
"argv": null, 
"chdir": null, 
"creates": null, 
"executable": null, 
"removes": null, 
"stdin": null, 
"stdin_add_newline": true, 
"strip_empty_ends": true, 
"warn": true
}
}, 
"msg": "non-zero return code", 
"rc": 1, 
"start": "2020-01-23 20:00:29.937641", 
"stderr": "", 
"stderr_lines": [], 
"stdout": "Logging in as karaf\r\nFailed to get the session.", 
"stdout_lines": [
"Logging in as karaf", 
"Failed to get the session."
]
}

When I ssh to the sever running commands, shows

onos-b:~$ sudo docker exec -it onos_b bash -c 
'/root/onos/apache-karaf-4.2.6/bin/client app activate org.onosproject.fwd'
Logging in as karaf
Activated org.onosproject.fwd

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a63fedf7-5495-4f02-87bc-bc8a93144ba4%40googlegroups.com.


[ansible-project] Re: Need Help in Ansible regex

2020-01-24 Thread Cyril Stoll
Hi

Not quite sure what you are trying to do with the slash ("/") symbol in 
your regex. If you want to use it to escape the dot (".") sign then you 
need to use a backslash ("\") instead of a slash and you need to put it 
before the dot not after it.

So try this: dp-steps-common-[0-9\.]+[0-9\.]+[0-9][0-9\.]rpm$

Also there is a quite handy webpage that helps you test your regex. Just 
visit regex101.com and type your regex in the small field on top and the 
string you want to capture with your regex in the large field below. Then 
you can play around with your regex and the webpage will tell you which 
part of your regex captured which part of the string.

Best,
Cyril


On Friday, 24 January 2020 07:09:47 UTC+1, Rakesh Parida wrote:
>
> Hi all,
>
> I have a rpm whcich i have added in a list. I want to make it dynamic i.e 
> when the version of rpm changes playbook should handle it.
> I have build a logic but the playbook skips the task where i have 
> mentioned the regex. Kindly help me .
>
>
> - hosts: localhost
>   tasks:
> - name: Create a list
>   set_fact:
>  some_value:
> - dp-steps-common-3.0.12.rpm
>
> - debug:
> msg: "{{ some_value }}"
>
> - name: Print DP steps records
>   set_fact:
> dp_record: "{{ item }}"
>   when: item is defined and item  == 'regexp 
> (dp-steps-common-[0-9./]+[0-9./]+[0-9][0-9./]rpm$)'
>   with_items: "{{ some_value }}"
>
> - name: Create an empty list variable
>   set_fact:
> nodes1: []
>
> - name: Append string to ECE node list
>   set_fact:
> nodes1: "{{ ece_nodes + [ item ] }}"
>   with_items:
> - "{{ dp_record | default(None) }}"
>   when: item is defined and item != None and item != ""
>
> - name: Display Lists
>   debug:
> msg:
>  - "{{ nodes1 }}"
>
> OUTput:
> PLAY [localhost] 
> 
>
> TASK [Gathering Facts] 
> **
> ok: [localhost]
>
> TASK [Create a list] 
> 
> ok: [localhost]
>
> TASK [debug] 
> 
> ok: [localhost] => {
> "msg": [
> "dp-steps-common-3.0.12.rpm"
> ]
> }
>
> TASK [Print DP steps records] 
> ***
> skipping: [localhost] => (item=dp-steps-common-3.0.12.rpm)
>
> TASK [Create an empty list variable] 
> 
> ok: [localhost]
>
> TASK [Append string to ECE node list] 
> ***
> skipping: [localhost] => (item=)
>
> TASK [Display Lists] 
> 
> ok: [localhost] => {
> "msg": [
> []
> ]
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b5601625-e203-4724-a8d7-c00bbc49dcc2%40googlegroups.com.


[ansible-project] Re: I have Ansible and Jenkins installed on Different Servers how can i configure both

2020-01-24 Thread 'J Hawkesworth' via Ansible Project
You can use the not-particularly-helpfully-named 'Publish Over SSH' Jenkins 
plugin https://plugins.jenkins.io/publish-over-ssh which lets you run 
arbitrary commands as well as transferring files.

If your playbooks run for more than 2 minutes you will need to configure 
the 'Exec timeout (ms)' setting ( I found I had to do this in the common 
jenkins configuration and individually on each Jenkins job).

Hope this helps,

Jon


On Thursday, January 23, 2020 at 4:04:00 AM UTC, Sai Prasha wrote:
>
> I have Ansible and Jenkins on Windows but on different servers how can i 
> establish a connection between this two to trigger a playbook based on 
> inventory files
> What is the inventory path to be given? 
> My inventory file is as shown below 
>
> [win]
> 10.96.43.61
> 10.96.43.177
>
> [win:vars]
> ansible_user=Administrator
> ansible_password=N0b0r33l
> ansible_connection=winrm
> ansible_winrm_server_cert_validation=ignore
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fcd37267-527e-467a-b475-8b8b6fdf0806%40googlegroups.com.


[ansible-project] Unable to connect to Windows 2016 over HTTPS using self signed certificates; using ansible securely in a mixed active directory environment

2020-01-24 Thread Dan Hebert
 

Good afternoon,

 

I have been trying to get ansible working over a Windows 2016 HTTPS 
listener with encryption using TLS encryption and self-signed certificate 
authentication. 

User authentication over HTTP is not going to be sufficient. The 
environment where I work is a mix of nodes where some use active directory. 

 

Here is the matrix for authentication:

https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html 

 

Given this matrix, I expected that I would have been able to authenticate 
with a local account that is part of the administrators group using 
certificates. I followed this process, taken from the Windows ansible 
guides:

https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html 

 

E*nable TLS*

Function Enable-TLS12 {

param(

[ValidateSet("Server", "Client")]

[String]$Component = "Server"

)

 

$protocols_path = 
'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols'

New-Item -Path "$protocols_path\TLS 1.2\$Component" -Force

New-ItemProperty -Path "$protocols_path\TLS 1.2\$Component" -Name 
Enabled -Value 1 -Type DWORD -Force

New-ItemProperty -Path "$protocols_path\TLS 1.2\$Component" -Name 
DisabledByDefault -Value 0 -Type DWORD -Force

}

 

Enable-TLS12 -Component Server

 

# Not required but highly recommended to enable the Client side TLS 1.2 
components

Enable-TLS12 -Component Client

 

Restart-Computer

 

 

*Enable certificate authentication*

Set-Item -Path WSMan:\localhost\Service\Auth\Certificate -Value $true

 

*Enable LocalTestAccount certificate*

*Please note that I changed the -TextExtension which corresponds to the EKU 
to have the trailing digit be a 1 instead of a 2, which differs from: 
https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html#generate-a-certificate
 

 
*

*Using the code from the documentation gives an EKU error: “The Enhanced 
Key Usage (EKU) field of the certificate is not set to "Server 
Authentication"”*

 

 

$username = "LocalTestAccount"

$output_path = "C:\temp"

 

# Instead of generating a file, the cert will be added to the personal

# LocalComputer folder in the certificate store

$cert = New-SelfSignedCertificate -Type Custom `

-Subject "CN=$username" `

-TextExtension 
@("2.5.29.37={text}1.3.6.1.5.5.7.3.1","2.5.29.17={text}upn=$username@localhost")
 
`

-KeyUsage DigitalSignature,KeyEncipherment `

-KeyAlgorithm RSA `

-KeyLength 2048

 

# Export the public key

$pem_output = @()

$pem_output += "-BEGIN CERTIFICATE-"

$pem_output += [System.Convert]::ToBase64String($cert.RawData) -replace 
".{64}", "$&`n"

$pem_output += "-END CERTIFICATE-"

[System.IO.File]::WriteAllLines("$output_path\cert.pem", $pem_output)

 

# Export the private key in a PFX file

[System.IO.File]::WriteAllBytes("$output_path\cert.pfx", 
$cert.Export("Pfx"))

 

 

 

*Import LocalTestAccount*

$cert = New-Object -TypeName 
System.Security.Cryptography.X509Certificates.X509Certificate2

$cert.Import("C:\temp\LocalTestAccount\cert.pem")

 

$store_name = 
[System.Security.Cryptography.X509Certificates.StoreName]::Root

$store_location = 
[System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine

$store = New-Object -TypeName 
System.Security.Cryptography.X509Certificates.X509Store -ArgumentList 
$store_name, $store_location

$store.Open("MaxAllowed")

$store.Add($cert)

$store.Close()

 

 

*Map certificate to **LocalTestAccount*

$username = "LocalTestAccount"

$password = ConvertTo-SecureString -String "my_password" -AsPlainText -Force

$credential = New-Object -TypeName 
System.Management.Automation.PSCredential -ArgumentList $username, $password

 

# This is the issuer thumbprint which in the case of a self generated cert

# is the public key thumbprint, additional logic may be required for other

# scenarios

$thumbprint = (Get-ChildItem -Path cert:\LocalMachine\root | Where-Object { 
$_.Subject -eq "CN=$username" }).Thumbprint

 

New-Item -Path WSMan:\localhost\ClientCertificate `

-Subject "$username@localhost" `

-URI * `

-Issuer $thumbprint `

-Credential $credential `

-Force

 

 

 

*Create HTTPS Listener with Certificate*

$selector_set = @{

Address = "*"

Transport = "HTTPS"

}

$value_set = @{

CertificateThumbprint = "my thumbprint code here"

}

 

Get-ChildItem -Path cert:\LocalMachine\My -Recurse | Where-Object { 
$_.Thumbprint -eq "my thumbprint code here" } | Select-Object *

 

New-WSManInstance -ResourceURI "winrm/config/Listener" -SelectorSet 
$selector_set -ValueSet $value_set

 

 

*To be run on my Linux machine*

# Extract private key

openssl pkcs12 -in cert.pfx -nocerts -nodes -out cert_key.pem -passin pass: 
-passout pass:

 

# certificate: cert.pem

 

 

*The checks that I run:*

 


*Enumerate listeners (Microsoft documenta

Re: [ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Dick Visser
Is 'yum' a group name perhaps?

On Fri, 24 Jan 2020 at 17:49, Rakesh Parida 
wrote:

> Hi
>
> Iam trying to access the variable from other hosts using hostvars. I am
> getting the undefined error.
> Can anybody help me: stuck at this point
>
>
>
> - hosts: yum
>   gather_facts: false
>   vars:
>  file_locn: "/san/repos/{{ version }}/packages"
>   tasks:
> - name: Find the Packages that are present in File location
>   shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>   register: files_present
>
> - name: Set Fact
>   set_fact:
>  some_value: "{{ files_present.stdout_lines }}"
>
> - debug:
> msg: "{{ some_value }}"
>
> - hosts: localhost
>   gather_facts: false
>   tasks:
> - name: Show hostvars
>   debug:
> msg: "{{ hostvars['yum']['some_value'] }}"
>
> error:
> PLAY [yum]
> ***
>
> TASK [Find the Packages that are present in File location]
> ***
> changed: [YUM01]
>
> TASK [Set Fact]
> **
> ok: [YUM01]
>
> TASK [debug]
> *
> ok: [YUM01] => {
> "msg": [
> "common-3.0.12.rpm",
>
> ]
> }
>
> PLAY [localhost]
> *
>
> TASK [Show hostvars]
> *
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with
> an undefined variable. The error was: \"hostvars['yum']\" is
> undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': line
> 20, column 7, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n-
> name: Show hostvars\n  ^ here\n"}
>
> PLAY RECAP
> ***
> YUM01   : ok=3changed=1unreachable=0failed=0
>   skipped=0rescued=0ignored=0
> localhost  : ok=0changed=0unreachable=0
> failed=1skipped=0rescued=0ignored=0
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com
> 
> .
>


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwN%2B-Y-6OQegKH%2BbDTEN5kcSrR3OdBwWUcLvBJXo3sMhUw%40mail.gmail.com.


Re: [ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Jean-Yves LENHOF

Hi,

You should better use the find module instead of shell module and ls.

As said, yum seem to be a group... To use hostvars special variable you 
need to use host and not group...


Something like this will work :

msg: "{{ hostvars['YUM01']['some_value'] }}"


But instead of asking to remove your error, perhaps you could explain 
what you want to do...


Regards,

JYL


Le 24/01/2020 à 17:49, Rakesh Parida a écrit :

Hi

Iam trying to access the variable from other hosts using hostvars. I 
am getting the undefined error.

Can anybody help me: stuck at this point



- hosts: yum
  gather_facts: false
  vars:
     file_locn: "/san/repos/{{ version }}/packages"
  tasks:
    - name: Find the Packages that are present in File location
      shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
      register: files_present

    - name: Set Fact
      set_fact:
         some_value: "{{ files_present.stdout_lines }}"

    - debug:
        msg: "{{ some_value }}"

- hosts: localhost
  gather_facts: false
  tasks:
    - name: Show hostvars
      debug:
        msg: "{{ hostvars['yum']['some_value'] }}"

error:
PLAY [yum] 
***


TASK [Find the Packages that are present in File location] 
***

changed: [YUM01]

TASK [Set Fact] 
**

ok: [YUM01]

TASK [debug] 
*

ok: [YUM01] => {
    "msg": [
        "common-3.0.12.rpm",
    ]
}

PLAY [localhost] 
*


TASK [Show hostvars] 
*
fatal: [localhost]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: \"hostvars['yum']\" is 
undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': 
line 20, column 7, but may\nbe elsewhere in the file depending on the 
exact syntax problem.\n\nThe offending line appears to be:\n\n 
tasks:\n    - name: Show hostvars\n      ^ here\n"}


PLAY RECAP 
***
YUM01                   : ok=3    changed=1 unreachable=0    failed=0  
  skipped=0    rescued=0 ignored=0
localhost                  : ok=0    changed=0 unreachable=0    
failed=1    skipped=0    rescued=0 ignored=0

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com 
.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ccda6477-ddea-79ee-60b0-2c5cbac511d4%40lenhof.eu.org.


[ansible-project] How to skip the playbook based on a condition

2020-01-24 Thread Anand Solomon
Hi,
I basically wanted to skip the remaining of the playbook if a file exists


- name: Check if the file exists
  stat:
path: /home/ansible/dbname/sql/file.sql
  register: optional_file

- debug:
msg: "File Exists"
  when: optional_file.stat.exists == True

Also, Is there a way I read the same file, and based on a string I stop the 
remaining playbook?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com.


Re: [ansible-project] How to skip the playbook based on a condition

2020-01-24 Thread Dick Visser
meta: end_play
is what you want

https://docs.ansible.com/ansible/latest/modules/meta_module.html


On Fri, 24 Jan 2020 at 21:01, Anand Solomon 
wrote:

> Hi,
> I basically wanted to skip the remaining of the playbook if a file exists
>
>
> - name: Check if the file exists
>   stat:
> path: /home/ansible/dbname/sql/file.sql
>   register: optional_file
>
> - debug:
> msg: "File Exists"
>   when: optional_file.stat.exists == True
>
> Also, Is there a way I read the same file, and based on a string I stop
> the remaining playbook?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNVhM-3ZpGQZ9t-xRVO73PTP4kPWQLgR4U06BBuPYtHCw%40mail.gmail.com.


Re: [ansible-project] How to skip the playbook based on a condition

2020-01-24 Thread Anand Solomon
Thanks I got this working.

On Friday, January 24, 2020 at 3:37:43 PM UTC-5, Dick Visser wrote:
>
> meta: end_play 
> is what you want 
>
> https://docs.ansible.com/ansible/latest/modules/meta_module.html
>
>
> On Fri, 24 Jan 2020 at 21:01, Anand Solomon  > wrote:
>
>> Hi,
>> I basically wanted to skip the remaining of the playbook if a file exists
>>
>>
>> - name: Check if the file exists
>>   stat:
>> path: /home/ansible/dbname/sql/file.sql
>>   register: optional_file
>>
>> - debug:
>> msg: "File Exists"
>>   when: optional_file.stat.exists == True
>>
>> Also, Is there a way I read the same file, and based on a string I stop 
>> the remaining playbook?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e721cdba-d562-4ec5-922a-f46c5ba25b6e%40googlegroups.com.


Re: [ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Rakesh Parida
Yum is a hostname ina group variable
And der are multiple yum server entries

On Fri, 24 Jan, 2020, 11:35 PM Dick Visser,  wrote:

> Is 'yum' a group name perhaps?
>
> On Fri, 24 Jan 2020 at 17:49, Rakesh Parida 
> wrote:
>
>> Hi
>>
>> Iam trying to access the variable from other hosts using hostvars. I am
>> getting the undefined error.
>> Can anybody help me: stuck at this point
>>
>>
>>
>> - hosts: yum
>>   gather_facts: false
>>   vars:
>>  file_locn: "/san/repos/{{ version }}/packages"
>>   tasks:
>> - name: Find the Packages that are present in File location
>>   shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>>   register: files_present
>>
>> - name: Set Fact
>>   set_fact:
>>  some_value: "{{ files_present.stdout_lines }}"
>>
>> - debug:
>> msg: "{{ some_value }}"
>>
>> - hosts: localhost
>>   gather_facts: false
>>   tasks:
>> - name: Show hostvars
>>   debug:
>> msg: "{{ hostvars['yum']['some_value'] }}"
>>
>> error:
>> PLAY [yum]
>> ***
>>
>> TASK [Find the Packages that are present in File location]
>> ***
>> changed: [YUM01]
>>
>> TASK [Set Fact]
>> **
>> ok: [YUM01]
>>
>> TASK [debug]
>> *
>> ok: [YUM01] => {
>> "msg": [
>> "common-3.0.12.rpm",
>>
>> ]
>> }
>>
>> PLAY [localhost]
>> *
>>
>> TASK [Show hostvars]
>> *
>> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with
>> an undefined variable. The error was: \"hostvars['yum']\" is
>> undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': line
>> 20, column 7, but may\nbe elsewhere in the file depending on the exact
>> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n-
>> name: Show hostvars\n  ^ here\n"}
>>
>> PLAY RECAP
>> ***
>> YUM01   : ok=3changed=1unreachable=0failed=0
>>   skipped=0rescued=0ignored=0
>> localhost  : ok=0changed=0unreachable=0
>> failed=1skipped=0rescued=0ignored=0
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwN%2B-Y-6OQegKH%2BbDTEN5kcSrR3OdBwWUcLvBJXo3sMhUw%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKxTaAFr5MQZwF7ca%3D0seV2fdbe5RTcUXfYuUmx3SpZGbT-4A%40mail.gmail.com.


Re: [ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Rakesh Parida
I had already tried d same but same error

On Sat, 25 Jan, 2020, 12:25 AM Jean-Yves LENHOF, 
wrote:

> Hi,
>
> You should better use the find module instead of shell module and ls.
>
> As said, yum seem to be a group... To use hostvars special variable you
> need to use host and not group...
>
> Something like this will work :
>
> msg: "{{ hostvars['YUM01']['some_value'] }}"
>
>
> But instead of asking to remove your error, perhaps you could explain what
> you want to do...
>
> Regards,
>
> JYL
>
>
> Le 24/01/2020 à 17:49, Rakesh Parida a écrit :
>
> Hi
>
> Iam trying to access the variable from other hosts using hostvars. I am
> getting the undefined error.
> Can anybody help me: stuck at this point
>
>
>
> - hosts: yum
>   gather_facts: false
>   vars:
>  file_locn: "/san/repos/{{ version }}/packages"
>   tasks:
> - name: Find the Packages that are present in File location
>   shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>   register: files_present
>
> - name: Set Fact
>   set_fact:
>  some_value: "{{ files_present.stdout_lines }}"
>
> - debug:
> msg: "{{ some_value }}"
>
> - hosts: localhost
>   gather_facts: false
>   tasks:
> - name: Show hostvars
>   debug:
> msg: "{{ hostvars['yum']['some_value'] }}"
>
> error:
> PLAY [yum]
> ***
>
> TASK [Find the Packages that are present in File location]
> ***
> changed: [YUM01]
>
> TASK [Set Fact]
> **
> ok: [YUM01]
>
> TASK [debug]
> *
> ok: [YUM01] => {
> "msg": [
> "common-3.0.12.rpm",
>
> ]
> }
>
> PLAY [localhost]
> *
>
> TASK [Show hostvars]
> *
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with
> an undefined variable. The error was: \"hostvars['yum']\" is
> undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': line
> 20, column 7, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n-
> name: Show hostvars\n  ^ here\n"}
>
> PLAY RECAP
> ***
> YUM01   : ok=3changed=1unreachable=0failed=0
>   skipped=0rescued=0ignored=0
> localhost  : ok=0changed=0unreachable=0
> failed=1skipped=0rescued=0ignored=0
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com
> 
> .
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ccda6477-ddea-79ee-60b0-2c5cbac511d4%40lenhof.eu.org
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKxTaAPCU9x%3DFMY49w5UczeQn5iAze3bexF18NJgYFkWZ3E%3Dw%40mail.gmail.com.


Re: [ansible-project] Hostvars giving me undefined error

2020-01-24 Thread Rakesh Parida


On Saturday, January 25, 2020 at 12:25:26 AM UTC+5:30, Jean-Yves LENHOF 
wrote:
>
> Hi,
>
> You should better use the find module instead of shell module and ls.
>
> As said, yum seem to be a group... To use hostvars special variable you 
> need to use host and not group...
>
> Something like this will work : 
>
> msg: "{{ hostvars['YUM01']['some_value'] }}"
>
>
> But instead of asking to remove your error, perhaps you could explain what 
> you want to do...
>
> Regards,
>
> JYL
>
>
> Le 24/01/2020 à 17:49, Rakesh Parida a écrit :
>
> Hi  
>
> Iam trying to access the variable from other hosts using hostvars. I am 
> getting the undefined error.
> Can anybody help me: stuck at this point
>
>
>
> - hosts: yum
>   gather_facts: false
>   vars:
>  file_locn: "/san/repos/{{ version }}/packages"
>   tasks:
> - name: Find the Packages that are present in File location
>   shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>   register: files_present
>
> - name: Set Fact
>   set_fact:
>  some_value: "{{ files_present.stdout_lines }}"
>
> - debug:
> msg: "{{ some_value }}"
>
> - hosts: localhost
>   gather_facts: false
>   tasks:
> - name: Show hostvars
>   debug:
> msg: "{{ hostvars['yum']['some_value'] }}"
>
> error:
> PLAY [yum] 
> ***
>
> TASK [Find the Packages that are present in File location] 
> ***
> changed: [YUM01]
>
> TASK [Set Fact] 
> **
> ok: [YUM01]
>
> TASK [debug] 
> *
> ok: [YUM01] => {
> "msg": [
> "common-3.0.12.rpm", 
> 
> ]
> }
>
> PLAY [localhost] 
> *
>
> TASK [Show hostvars] 
> *
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with 
> an undefined variable. The error was: \"hostvars['yum']\" is 
> undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': line 
> 20, column 7, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n- 
> name: Show hostvars\n  ^ here\n"}
>
> PLAY RECAP 
> ***
> YUM01   : ok=3changed=1unreachable=0failed=0  
>   skipped=0rescued=0ignored=0   
> localhost  : ok=0changed=0unreachable=0
> failed=1skipped=0rescued=0ignored=0  
> -- 
> 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...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com
>  
> 
> .
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/11f85ada-ce0c-4484-a7ac-3c0f0cae0d83%40googlegroups.com.


[ansible-project] Re: Hostvars giving me undefined error

2020-01-24 Thread Rakesh Parida
Hi Dick/Jean,

My inventory file has only one  entry of yum..
Now i  have also tried to use :

 - name: Show hostvars
  debug:
msg: "{{ hostvars[groups['yum']['some_value'] }}"


But still i get same error 
I think iam doing  some error in syntax...
as i keep getting the undefined error


Pls suggest 

On Friday, January 24, 2020 aThe yum is in t 10:19:04 PM UTC+5:30, Rakesh 
Parida wrote:
>
> Hi 
>
> Iam trying to access the variable from other hosts using hostvars. I am 
> getting the undefined error.
> Can anybody help me: stuck at this point
>
>
>
> - hosts: yum
>   gather_facts: false
>   vars:
>  file_locn: "/san/repos/{{ version }}/packages"
>   tasks:
> - name: Find the Packages that are present in File location
>   shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>   register: files_present
>
> - name: Set Fact
>   set_fact:
>  some_value: "{{ files_present.stdout_lines }}"
>
> - debug:
> msg: "{{ some_value }}"
>
> - hosts: localhost
>   gather_facts: false
>   tasks:
> - name: Show hostvars
>   debug:
> msg: "{{ hostvars['yum']['some_value'] }}"
>
> error:
> PLAY [yum] 
> ***
>
> TASK [Find the Packages that are present in File location] 
> ***
> changed: [YUM01]
>
> TASK [Set Fact] 
> **
> ok: [YUM01]
>
> TASK [debug] 
> *
> ok: [YUM01] => {
> "msg": [
> "common-3.0.12.rpm", 
> 
> ]
> }
>
> PLAY [localhost] 
> *
>
> TASK [Show hostvars] 
> *
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with 
> an undefined variable. The error was: \"hostvars['yum']\" is 
> undefined\n\nThe error appears to be in '/home/rparida1/raka.yml': line 
> 20, column 7, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n- 
> name: Show hostvars\n  ^ here\n"}
>
> PLAY RECAP 
> ***
> YUM01   : ok=3changed=1unreachable=0failed=0  
>   skipped=0rescued=0ignored=0   
> localhost  : ok=0changed=0unreachable=0
> failed=1skipped=0rescued=0ignored=0  
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/eb758a39-58f6-44b7-a8cc-003a81018ccc%40googlegroups.com.


[ansible-project] Run excel VB or Macro?

2020-01-24 Thread John Harmon
I am trying to automate a process.  Is it possible, natively in Ansible, to 
run an Excel Macro, or Visual Basic code against an .csv?

Thanks in advance.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8effa0a3-e7b8-49b4-a3af-da2bb7a50ce1%40googlegroups.com.


Re: [ansible-project] Re: can someone please explain about "undefined" error

2020-01-24 Thread Work-Hard
Got it thanks

On Friday, January 24, 2020 at 6:07:34 AM UTC-8, Karl Auer wrote:
>
> To expand on what Eric said:
>
> Your when: condition refers to a variable called "update_count".
>
> At the point where you refer to it, that variable does not exist. I bolded 
> the bits of the error message that really matter:
>
> TASK [reboot if required] **
> 
> **
> task path: /etc/ansible/windows-playbook/copied.yml:22
> *fatal*: [EC2AMAZ-9M186EG.corp.medqia.com]: FAILED! => {
> "msg": "The conditional check 'update_count.reboot_required' failed. 
> The error was: error while evaluating conditional 
> (update_count.reboot_required): *'update_count' is undefined*\n\n.\n\nThe 
> offending line appears to be:\n\n  tasks:\n   - name: reboot if required\n  
>^ here\n"
> }
>
> Common reasons for this error include:
> - you misspelled it
> - you got the CaPiTaLiSaTiOn wrong
> - you defined it after first reference
> - you defined it for a host other than EC2AMAZ-9M186EG.corp.medqia.com
> - you defined it in a vars file that is not being loaded
> - you defined it in a vars file that is not being referenced
> - you defined it somewhere where it cannot be referenced
> - you rearranged your code and accidentally moved the definition to after 
> the first reference
> - update_count is a field or element of something bigger you forgot to 
> reference first
> - you didn't define it at all
>
> If you'd like more help, post the ENTIRE playbook here (or make it 
> available in e.g. pastebin). Don't post anything confidential though.
>
> Please post code in a fixed-width font so we can see the indentation.
>
> Regards, K.
>
> On Sat, Jan 25, 2020 at 12:24 AM 'Eric Hymowitz' via Ansible Project <
> ansible...@googlegroups.com > wrote:
>
>> At the risk of being rude, I'm not sure what you don't understand.
>>
>> You're querying a hash variable update_count , and looking for the member 
>> named reboot_required .  Where did you define this variable?  If you don't 
>> define a variable, then the variable is undefined.
>>
>> Is there more to this playbook that you didn't provide?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/5c5985b8-32a6-4334-aa09-c0e8814af823%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
>
> *Karl Auer* { manager, systems support }
> P: 1300 759 975
> E: ka...@2pisoftware.com 
> 2pisoftware.com
>
> GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
> Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5a15e971-fbf0-4dc9-8e74-04bac130402a%40googlegroups.com.


[ansible-project] What is the best approach to creating a inlude_vars file for my requirement

2020-01-24 Thread Shifa Shaikh
I use the stat module to read multiple files statistics from each remote 
server. 

Thus, I'm able to get the file mode and checksum value of say 3 files on 
host1 and 2 files on host2.

I wish to know what is a good way to create/construct an include_vars file 
so that I can easily read back each file's mode and checksum for any given 
server?

I thought of constructing a myvars.yaml as below:

---
host1:
   name: /tmp/conf/httpd.conf
   checksum: 79783482382789273
   mode: 0744
   name: /tmp/conf/extra/httpd.conf
   checksum: 112312382789273
   mode: 0754



host2:

   name: /tmp/conf/httpd.conf
   checksum: 89662ff9273
   mode: 0774
   name: /tmp/conf/extra/httpd.conf
   checksum: 82094810498
   mode: 0754


I can construct the myvars.yaml as I like but the challenge is how can I 
read the values of the individual file name on a given hots?

Any suggestions for construct myvars.yaml differently and reading 
individual file details in a playbook will be of great help. 

Thank you !!

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fd96dabf-6ed9-4924-84b5-d855d15f05ff%40googlegroups.com.


[ansible-project] What is the module to install drivers?

2020-01-24 Thread Work-Hard
What is the module to install drivers ? it's not working with win_updates.
===
"changed": false,
"filtered_updates": {
"3ae62049-cfd0-482e-b95b-e44f346aa156": {
"categories": [
"Drivers"
],
"filtered_reason": "category_names",
"id": "3ae62049-cfd0-482e-b95b-e44f346aa156",
"installed": false,
"kb": [],
"title": "*Realtek Semiconductor Corp. - Extension - 
10.0.17134.1*"
}
},
"found_update_count": 0,
"installed_update_count": 0,
"reboot_required": false,
"updates": {}

Cheers

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/31c343bf-6668-4557-afd7-349de1dc7775%40googlegroups.com.


[ansible-project] Re: What is the module to install drivers?

2020-01-24 Thread Work-Hard
it's filtering now 
vars :
win_updates:
 - SecurityUpdates
 - CriticalUpdates
 - UpdateRollups
 - Definition Updates
 - Updates
 - Windows Server 2016
 - Windows Defender
 - Feature Packs
 - Silverlight
 - Upgrades
 - Windows 10
 - Drivers
  tasks:
- name: check for missing updates
  win_updates:
state: searched
catagory_names: "{{ win_updates }}"
  register: update_count
  ignore_errors: yes

- name: reboot if required
  win_reboot:
  when: update_count.reboot_required
  ignore_errors: yes

- name: install updates
  win_updates:
catagory_names: "{{ win_updates }}"
reboot: yes
  register: update_result

*OUTPUT*
"changed": false,
"filtered_updates": {
"65ecc208-c6b1-4fce-b892-fc2c93917d76": {
"categories": [
"Drivers"
],
"filtered_reason": "category_names",
"id": "65ecc208-c6b1-4fce-b892-fc2c93917d76",
"installed": false,
"kb": [],
"title": "Logitech - Image - 10/24/2018 12:00:00 AM - 1.3.89.0"
},
"79bfbb87-ae9d-480d-9f6f-5c82361e015d": {
"categories": [
"Upgrades"
],
"filtered_reason": "category_names",
"id": "79bfbb87-ae9d-480d-9f6f-5c82361e015d",
"installed": false,
"kb": [
"4530684"
],
"title": "Feature update to Windows 10, version 1909"
},
"9dd000db-ce7e-48cc-b7e9-0508ee8e6c56": {
"categories": [
"Updates",
"Windows 10"
],
"filtered_reason": "category_names",
"id": "9dd000db-ce7e-48cc-b7e9-0508ee8e6c56",
"installed": false,
"kb": [
"4534129"
],
"title": "2020-01 Cumulative Update for .NET Framework 4.8 for 
Windows 10 Version 1709 for x64 (KB4534129)"
}
},
"found_update_count": 0,
"installed_update_count": 0,
"reboot_required": false,
"updates": {}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5cddfe67-661f-4cbd-93b3-c82a93cff37f%40googlegroups.com.


[ansible-project] Re: What is the module to install drivers?

2020-01-24 Thread Work-Hard
changed - catagory_names to category_names.. Will try again but will the 
driver update ? please let me know

On Friday, January 24, 2020 at 4:03:45 PM UTC-8, Work-Hard wrote:
>
> it's filtering now 
> vars :
> win_updates:
>  - SecurityUpdates
>  - CriticalUpdates
>  - UpdateRollups
>  - Definition Updates
>  - Updates
>  - Windows Server 2016
>  - Windows Defender
>  - Feature Packs
>  - Silverlight
>  - Upgrades
>  - Windows 10
>  - Drivers
>   tasks:
> - name: check for missing updates
>   win_updates:
> state: searched
> catagory_names: "{{ win_updates }}"
>   register: update_count
>   ignore_errors: yes
>
> - name: reboot if required
>   win_reboot:
>   when: update_count.reboot_required
>   ignore_errors: yes
>
> - name: install updates
>   win_updates:
> catagory_names: "{{ win_updates }}"
> reboot: yes
>   register: update_result
>
> *OUTPUT*
> "changed": false,
> "filtered_updates": {
> "65ecc208-c6b1-4fce-b892-fc2c93917d76": {
> "categories": [
> "Drivers"
> ],
> "filtered_reason": "category_names",
> "id": "65ecc208-c6b1-4fce-b892-fc2c93917d76",
> "installed": false,
> "kb": [],
> "title": "Logitech - Image - 10/24/2018 12:00:00 AM - 1.3.89.0"
> },
> "79bfbb87-ae9d-480d-9f6f-5c82361e015d": {
> "categories": [
> "Upgrades"
> ],
> "filtered_reason": "category_names",
> "id": "79bfbb87-ae9d-480d-9f6f-5c82361e015d",
> "installed": false,
> "kb": [
> "4530684"
> ],
> "title": "Feature update to Windows 10, version 1909"
> },
> "9dd000db-ce7e-48cc-b7e9-0508ee8e6c56": {
> "categories": [
> "Updates",
> "Windows 10"
> ],
> "filtered_reason": "category_names",
> "id": "9dd000db-ce7e-48cc-b7e9-0508ee8e6c56",
> "installed": false,
> "kb": [
> "4534129"
> ],
> "title": "2020-01 Cumulative Update for .NET Framework 4.8 for 
> Windows 10 Version 1709 for x64 (KB4534129)"
> }
> },
> "found_update_count": 0,
> "installed_update_count": 0,
> "reboot_required": false,
> "updates": {}
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d1fabaa2-990f-4a78-a34e-31557ca0d737%40googlegroups.com.


Re: [ansible-project] Need Help in Ansible regex

2020-01-24 Thread James Cassell


On Fri, Jan 24, 2020, at 1:09 AM, Rakesh Parida wrote:
> Hi all,
> 
> I have a rpm whcich i have added in a list. I want to make it dynamic 
> i.e when the version of rpm changes playbook should handle it.
> I have build a logic but the playbook skips the task where i have 
> mentioned the regex. Kindly help me .
> 
> 
> - hosts: localhost
>  tasks:
>  - name: Create a list
>  set_fact:
>  some_value:
>  - dp-steps-common-3.0.12.rpm
> 
>  - debug:
>  msg: "{{ some_value }}"
> 
>  - name: Print DP steps records
>  set_fact:
>  dp_record: "{{ item }}"
>  when: item is defined and item == 'regexp 
> (dp-steps-common-[0-9./]+[0-9./]+[0-9][0-9./]rpm$)'

In the first part, item will always be defined or the task won't run at all, so 
no need to test it.

In the second part, you're comparing two static strings here that will never 
match. You probably meant to do something like

when: item is regex('your regex')

See for examples: 
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings

V/r,
James Cassell

>  with_items: "{{ some_value }}"
> 
>  - name: Create an empty list variable
>  set_fact:
>  nodes1: []
> 
>  - name: Append string to ECE node list
>  set_fact:
>  nodes1: "{{ ece_nodes + [ item ] }}"
>  with_items:
>  - "{{ dp_record | default(None) }}"
>  when: item is defined and item != None and item != ""
> 
>  - name: Display Lists
>  debug:
>  msg:
>  - "{{ nodes1 }}"
> 
> OUTput:
> PLAY [localhost] 
> 
> 
> TASK [Gathering Facts] 
> **
> ok: [localhost]
> 
> TASK [Create a list] 
> 
> ok: [localhost]
> 
> TASK [debug] 
> 
> ok: [localhost] => {
>  "msg": [
>  "dp-steps-common-3.0.12.rpm"
>  ]
> }
> 
> TASK [Print DP steps records] 
> ***
> skipping: [localhost] => (item=dp-steps-common-3.0.12.rpm)
> 
> TASK [Create an empty list variable] 
> 
> ok: [localhost]
> 
> TASK [Append string to ECE node list] 
> ***
> skipping: [localhost] => (item=)
> 
> TASK [Display Lists] 
> 
> ok: [localhost] => {
>  "msg": [
>  []
>  ]
> 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1b7264fb-2e7f-4b8e-9baa-b7d4e4372e7b%40www.fastmail.com.