Re: [ansible-project] expect module does not answer questions on remote and it hangs

2023-04-14 Thread Lavanya VJ
Hi all, when I tried to debug Output I checked it runs up to a certain point and then I get “installation aborted by user”  though I didnot abort. I appreciate your help On 14. Apr 2023, at 11:05, Lavanya VJ  wrote:Hi sorry , i commented on the past post (2017) last time and hence i assumed thats was invalid.On Fri, Apr 14, 2023 at 10:57 AM Dick Visser  wrote:HiPlease do not ask exactly the same question is multiple messagesOn Fri, 14 Apr 2023 at 09:55, Lavanya VJ  wrote:Hi all,i am facing the issues with expect module though the timeout: 600 is mentioned, i always get     "msg": "command exceeded timeout" or it hangs , i have around 25 reponses to answer after the command has been executed.  - name: install file    expect:      command: /tmp/install.run      responses:        'path\? \[/tmp/output\]:': '/tmp/output/new'        'Run after installation\? \[yes\]:': 'yes'               timeout: 600



-- 
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/CAGmnkn3Y4DpQAwELUSREcp8kGGBwYhZb6ZR00uGEuyTz%3D71XZw%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/CAF8BbLZtDfsh5Zpr6v2%2BUz%2BCNrdfoz5epmTpUYk6Cn1X4MWnGQ%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/D9DBB570-C740-43C5-B1EC-F85318D6339D%40gmail.com.


Re: [ansible-project] Parsing csv file and running shell command

2023-04-14 Thread alonso...@gmail.com

Thank you every much, that worked, although I am not certain why echo with 
shell module wouldnt work , but thank you!
On Friday, 14 April 2023 at 02:24:25 UTC-4 Vladimir Botka wrote:

> On Thu, 13 Apr 2023 21:14:42 -0700 (PDT)
> "alonso...@gmail.com"  wrote:
>
> > ---
> > - name: Read Users
> > gather_facts: True
> > hosts: localhost
> > 
> > tasks:
> > - name: Read users
> > read_csv:
> > path: users.csv
> > delimiter: ","
> > register: s3list
> > 
> > - name: Running command
> > command: 
> > echo "aws s3 cp {{ s3.source }}" {{ s3.destination }} -- recursive 
> --acl-parameters ---profile prod'
> > loop: "{{ s3list.list }}"
> > loop_control:
> > loop_var: s3
> > 
> > the csv file contents:
> > source,destination
> > S3://mybucket/puppy/test.jpg,S3://mybucket2/trying/
> > S3://mybucket/puppy/ds.jpg,S3://mybucket3/trying/
> > S3://mybucket/puppy/as.jpg,S3://mybucket4/trying/
> > S3://mybucket/puppy/was.jpg,S3://mybucket5/trying/
> > S3://mybucket/puppy/qaes.jpg,S3://mybucket6/trying/
> > 
> > When I run the playbook I am getting the following
> > TASK [Running command] 
> > 
> *
> > changed: [localhost] => (item={'source': 'S3://mybucket/puppy/test.jpg', 
> > 'destination': 'S3://mybucket2/trying/'})
> > changed: [localhost] => (item={'source': 'S3://mybucket/puppy/ds.jpg', 
> > 'destination': 'S3://mybucket3/trying/'})
> > changed: [localhost] => (item={'source': 'S3://mybucket/puppy/as.jpg', 
> > 'destination': 'S3://mybucket4/trying/'})
> > changed: [localhost] => (item={'source': 'S3://mybucket/puppy/was.jpg', 
> > 'destination': 'S3://mybucket5/trying/'})
> > changed: [localhost] => (item={'source': 'S3://mybucket/puppy/qaes.jpg', 
> > 'destination': 'S3://mybucket6/trying/'})
>
> You're not running the *aws* command. You're testing the *aws* command
> with *echo*. Actually, this is a good idea to see the commands before
> you run them. Register the results and take a look at *stdout*.
>
> In the module *command*, there is a couple of syntax problems
> in the run-string. To make the syntax both simpler and easier to read
> use the *folded style*. See
> https://yaml.org/spec/1.2.2/#813-folded-style
>
> The tasks below
>
> - command: >-
> echo
> aws s3 cp
> {{ item.source }}
> {{ item.destination }}
> --recursive --acl parameters --profile prod
> loop: "{{ s3list.list }}"
> register: out
> - debug:
> msg: "{{ out.results|map(attribute='stdout')|list }}"
>
> should give you what you want
>
> msg:
> - aws s3 cp S3://mybucket/puppy/test.jpg S3://mybucket2/trying/
> --recursive --acl parameters --profile prod
> - aws s3 cp S3://mybucket/puppy/ds.jpg S3://mybucket3/trying/
> --recursive --acl parameters --profile prod
> - aws s3 cp S3://mybucket/puppy/as.jpg S3://mybucket4/trying/
> --recursive --acl parameters --profile prod
> - aws s3 cp S3://mybucket/puppy/was.jpg S3://mybucket5/trying/
> --recursive --acl parameters --profile prod
> - aws s3 cp S3://mybucket/puppy/qaes.jpg S3://mybucket6/trying/
> --recursive --acl parameters --profile prod
>
> If this is what you want remove *echo* and run the *aws* command with
> the option *--dryrun*
>
> - command: >-
> aws s3 cp
> {{ item.source }}
> {{ item.destination }}
> --dryrun --recursive --acl parameters --profile prod
> loop: "{{ s3list.list }}"
> register: out
> - debug:
> var: out
>
> If everything is alright copy the files
>
> - command: >-
> aws s3 cp
> {{ item.source }}
> {{ item.destination }}
> --recursive --acl parameters --profile prod
> loop: "{{ s3list.list }}"
> register: out
> - debug:
> var: out
>
> Notes:
>
> * You can remove the option *--recursive* as long as you copy single
> files
> * You'll have to replace *parameters* with actual values. See
> https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html
>
>
> -- 
> Vladimir Botka
>

-- 
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/de345992-1a92-4648-b2e4-4bd4dfe10f66n%40googlegroups.com.


Re: [ansible-project] expect module does not answer questions on remote and it hangs

2023-04-14 Thread Lavanya VJ
Hi sorry , i commented on the past post (2017) last time and hence i
assumed thats was invalid.

On Fri, Apr 14, 2023 at 10:57 AM Dick Visser  wrote:

> Hi
> Please do not ask exactly the same question is multiple messages
>
> On Fri, 14 Apr 2023 at 09:55, Lavanya VJ 
> wrote:
>
>> Hi all,
>> i am facing the issues with expect module though the timeout: 600 is
>> mentioned, i always get "msg": "command exceeded timeout" or it hangs ,
>> i have around 25 reponses to answer after the command has been executed.
>>   - name: install file
>> expect:
>>   command: /tmp/install.run
>>   responses:
>> 'path\? \[/tmp/output\]:': '/tmp/output/new'
>> 'Run after installation\? \[yes\]:': 'yes'
>>  
>>   timeout: 600
>>
>> --
>> 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/CAGmnkn3Y4DpQAwELUSREcp8kGGBwYhZb6ZR00uGEuyTz%3D71XZw%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/CAF8BbLZtDfsh5Zpr6v2%2BUz%2BCNrdfoz5epmTpUYk6Cn1X4MWnGQ%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/CAGmnkn1e9eqT8U%2B5oer%2BB3AMJYzWcLEjhxWgXmvYrFSFxBhWAg%40mail.gmail.com.


Re: [ansible-project] expect module does not answer questions on remote and it hangs

2023-04-14 Thread Dick Visser
Hi
Please do not ask exactly the same question is multiple messages

On Fri, 14 Apr 2023 at 09:55, Lavanya VJ 
wrote:

> Hi all,
> i am facing the issues with expect module though the timeout: 600 is
> mentioned, i always get "msg": "command exceeded timeout" or it hangs ,
> i have around 25 reponses to answer after the command has been executed.
>   - name: install file
> expect:
>   command: /tmp/install.run
>   responses:
> 'path\? \[/tmp/output\]:': '/tmp/output/new'
> 'Run after installation\? \[yes\]:': 'yes'
>  
>   timeout: 600
>
> --
> 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/CAGmnkn3Y4DpQAwELUSREcp8kGGBwYhZb6ZR00uGEuyTz%3D71XZw%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/CAF8BbLZtDfsh5Zpr6v2%2BUz%2BCNrdfoz5epmTpUYk6Cn1X4MWnGQ%40mail.gmail.com.


[ansible-project] expect module does not answer questions on remote and it hangs

2023-04-14 Thread Lavanya VJ
Hi all,
i am facing the issues with expect module though the timeout: 600 is
mentioned, i always get "msg": "command exceeded timeout" or it hangs ,
i have around 25 reponses to answer after the command has been executed.
  - name: install file
expect:
  command: /tmp/install.run
  responses:
'path\? \[/tmp/output\]:': '/tmp/output/new'
'Run after installation\? \[yes\]:': 'yes'
 
  timeout: 600

-- 
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/CAGmnkn3Y4DpQAwELUSREcp8kGGBwYhZb6ZR00uGEuyTz%3D71XZw%40mail.gmail.com.


Re: [ansible-project] Parsing csv file and running shell command

2023-04-14 Thread Vladimir Botka
On Thu, 13 Apr 2023 21:14:42 -0700 (PDT)
"alonso...@gmail.com"  wrote:

> ---
>   - name: Read Users
> gather_facts: True
> hosts: localhost
> 
> tasks:
> - name: Read users
>   read_csv:
> path: users.csv
> delimiter: ","
>   register: s3list
> 
> - name: Running command
>   command: 
> echo "aws s3 cp {{ s3.source }}" {{ s3.destination }} -- recursive 
> --acl-parameters ---profile prod'
>   loop: "{{ s3list.list }}"
>   loop_control:
> loop_var: s3
> 
> the csv file contents:
> source,destination
> S3://mybucket/puppy/test.jpg,S3://mybucket2/trying/
> S3://mybucket/puppy/ds.jpg,S3://mybucket3/trying/
> S3://mybucket/puppy/as.jpg,S3://mybucket4/trying/
> S3://mybucket/puppy/was.jpg,S3://mybucket5/trying/
> S3://mybucket/puppy/qaes.jpg,S3://mybucket6/trying/
> 
> When I run the playbook I am getting the following
> TASK [Running command] 
> *
> changed: [localhost] => (item={'source': 'S3://mybucket/puppy/test.jpg', 
> 'destination': 'S3://mybucket2/trying/'})
> changed: [localhost] => (item={'source': 'S3://mybucket/puppy/ds.jpg', 
> 'destination': 'S3://mybucket3/trying/'})
> changed: [localhost] => (item={'source': 'S3://mybucket/puppy/as.jpg', 
> 'destination': 'S3://mybucket4/trying/'})
> changed: [localhost] => (item={'source': 'S3://mybucket/puppy/was.jpg', 
> 'destination': 'S3://mybucket5/trying/'})
> changed: [localhost] => (item={'source': 'S3://mybucket/puppy/qaes.jpg', 
> 'destination': 'S3://mybucket6/trying/'})

You're not running the *aws* command. You're testing the *aws* command
with *echo*. Actually, this is a good idea to see the commands before
you run them. Register the results and take a look at *stdout*.

In the module *command*, there is a couple of syntax problems
in the run-string. To make the syntax both simpler and easier to read
use the *folded style*. See
https://yaml.org/spec/1.2.2/#813-folded-style

The tasks below

- command: >-
echo
aws s3 cp
{{ item.source }}
{{ item.destination }}
--recursive --acl parameters --profile prod
  loop: "{{ s3list.list }}"
  register: out
- debug:
msg: "{{ out.results|map(attribute='stdout')|list }}"

should give you what you want

  msg:
  - aws s3 cp S3://mybucket/puppy/test.jpg S3://mybucket2/trying/
--recursive --acl parameters --profile prod
  - aws s3 cp S3://mybucket/puppy/ds.jpg S3://mybucket3/trying/
--recursive --acl parameters --profile prod
  - aws s3 cp S3://mybucket/puppy/as.jpg S3://mybucket4/trying/
--recursive --acl parameters --profile prod
  - aws s3 cp S3://mybucket/puppy/was.jpg S3://mybucket5/trying/
--recursive --acl parameters --profile prod
  - aws s3 cp S3://mybucket/puppy/qaes.jpg S3://mybucket6/trying/
--recursive --acl parameters --profile prod

If this is what you want remove *echo* and run the *aws* command with
the option *--dryrun*

- command: >-
aws s3 cp
{{ item.source }}
{{ item.destination }}
--dryrun --recursive --acl parameters --profile prod
  loop: "{{ s3list.list }}"
  register: out
- debug:
var: out

If everything is alright copy the files

- command: >-
aws s3 cp
{{ item.source }}
{{ item.destination }}
--recursive --acl parameters --profile prod
  loop: "{{ s3list.list }}"
  register: out
- debug:
var: out

Notes:

* You can remove the option *--recursive* as long as you copy single
  files
* You'll have to replace *parameters* with actual values. See
  https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html


-- 
Vladimir Botka

-- 
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/20230414082342.214a2322%40gmail.com.


pgpTXEzalt13Q.pgp
Description: OpenPGP digital signature