Re: [ansible-project] Change current directory

2019-05-15 Thread Brian Coca
Consider that EACH task get's it's own environment and session, the
first task hat does a cd, does NOT affect subsequent tasks.


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


Re: [ansible-project] Change current directory

2019-05-14 Thread James Cassell



On Tue, May 14, 2019, at 8:20 PM, Kevin Kwon wrote:
> 
> 
> Hi..
> 
> I want to change the current directory in remote host by Ansible.
> so, i have created the playbook like below. but, it is not working 
> correctly.
> 

What problem are you actually trying to solve? Maybe try `args: chdir=/mydir`

V/r,
James Cassell


> would you please let me know how can i do change the current directory in 
> the remote host?
> 
> Kevin
> 
> 
> 
> ===
> 
> ---
> - name: Testing to change current direcotry
>   hosts: Ansible-01
>   tasks:
>   - name: confirm current Directory in the switch
> become: yes
> become_method: sudo
> command: 'pwd'
> register: exec_result
>   - debug: var=exec_result.stdout_lines
> 
>   - name: Go to "/tmp" Directory in the switch
> become: yes
> become_method: sudo
> command: ' cd /tmp '
> 
>   - name: confirm current Directory in the switch
> become: yes
> become_method: sudo
> command: 'pwd'
> register: exec_result
>   - debug: var=exec_result.stdout_lines
> 
> 
> ==
> 
> admin@ubuntu-Ansible:~$ ansible-playbook Change-dir.yml
> 
> PLAY [Testing to change current direcotry] 
> ***
> 
> TASK [Gathering Facts] 
> ***
> ok: [Ansible-01]
> 
> TASK [confirm current Directory in the switch] 
> ***
> changed: [Ansible-01]
> 
> TASK [debug] 
> *
> ok: [Ansible-01] => {
> "exec_result.stdout_lines": [
> *"/home/admin"*
> ]
> }
> 
> TASK [Go to "/tmp" Directory in the switch] 
> 
> fatal: [Ansible-01]: FAILED! => {"changed": false, "cmd": "cd /tmp", 
> "msg": 
> "[Errno 2] No such file or directory", "rc": 2}
> to retry, use: --limit @/home/admin/Change-dir.retry
> 
> PLAY RECAP 
> ***
> Ansible-01   : ok=3changed=1unreachable=0failed=1
> 
> admin@ubuntu-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/1557879876.1209629.1669197072.58A7B777%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Change current directory

2019-05-14 Thread Kevin Kwon


Hi..

I want to change the current directory in remote host by Ansible.
so, i have created the playbook like below. but, it is not working 
correctly.

would you please let me know how can i do change the current directory in 
the remote host?

Kevin



===

---
- name: Testing to change current direcotry
  hosts: Ansible-01
  tasks:
  - name: confirm current Directory in the switch
become: yes
become_method: sudo
command: 'pwd'
register: exec_result
  - debug: var=exec_result.stdout_lines

  - name: Go to "/tmp" Directory in the switch
become: yes
become_method: sudo
command: ' cd /tmp '

  - name: confirm current Directory in the switch
become: yes
become_method: sudo
command: 'pwd'
register: exec_result
  - debug: var=exec_result.stdout_lines


==

admin@ubuntu-Ansible:~$ ansible-playbook Change-dir.yml

PLAY [Testing to change current direcotry] 
***

TASK [Gathering Facts] 
***
ok: [Ansible-01]

TASK [confirm current Directory in the switch] 
***
changed: [Ansible-01]

TASK [debug] 
*
ok: [Ansible-01] => {
"exec_result.stdout_lines": [
*"/home/admin"*
]
}

TASK [Go to "/tmp" Directory in the switch] 

fatal: [Ansible-01]: FAILED! => {"changed": false, "cmd": "cd /tmp", "msg": 
"[Errno 2] No such file or directory", "rc": 2}
to retry, use: --limit @/home/admin/Change-dir.retry

PLAY RECAP 
***
Ansible-01   : ok=3changed=1unreachable=0failed=1

admin@ubuntu-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/4c6c90a0-445a-4e1e-ae6d-6d2e23f23369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Jesse DeFer
The CWD of the shell and sudo are still the home directory.  The chdir 
needs to happen before sudo is called.

On Friday, September 12, 2014 1:46:39 PM UTC-7, Michael DeHaan wrote:
>
> If remote temp is outside of your home why would it still prevent things 
> from unmounting?
>
>
>
> On Fri, Sep 12, 2014 at 4:39 PM, Jesse DeFer  > wrote:
>
>> raw doesn't seem to have a chdir option or it doesn't have the effect I 
>> need, command does but it still shows open files.  I already have 
>> remote_tmp set to a different directory.  I'm sure I could do something 
>> with at, but that's not the cleanest way to do it.  I had thought to set 
>> "sudo_exe = cd / && sudo" but that caused errors about executing sudo.
>>
>> On Friday, September 12, 2014 1:07:50 PM UTC-7, Michael DeHaan wrote:
>>>
>>> Or configure ansible.cfg to use a different temp dir path?
>>>
>>> On Fri, Sep 12, 2014 at 4:07 PM, Michael DeHaan  
>>> wrote:
>>>
 Another thought might be to use the "at" module to defer execution of 
 this particular command, sleep a bit to let it run, and then proceed?



 On Fri, Sep 12, 2014 at 4:01 PM, Michael Peters  
 wrote:

> Does the chdir argument to raw work?
>
>   raw: "/usr/sbin/lsof /afs" chdir="/"
>
> On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer  
> wrote:
> > I am trying to create a playbook to unmount an AFS mounted home 
> directory,
> > but I can't unmount it because the user running ansible has open 
> files
> > because of ansible.  I can't do this with user with a local home, or 
> ssh
> > configs or anything like that.   I need to do it with a regular 
> ansible play
> > and regular user, so no funky ssh configs or other changes to my 
> hosts.
> >
> > Here is my play:
> > - name: check if files are open in /afs
> >   raw: "cd / && /usr/sbin/lsof /afs"
> >   register: command_result
> >   failed_when: "command_result.rc != 1"
> >
> > If I run it with ansible, it will succeed, but ansible-playbook will 
> show
> > two processes spawned by the ansible run (sh and sudo).
> >
> > Is there a way to change the current directory before tasks are run?
> >
> > Thanks,
> > Jesse
> >
> > --
> > 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-proje...@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/
> 31dfb506-1544-4093-978d-d1a923dd3e33%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-proje...@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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%
> 2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.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-proje...@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/c14a01ca-a317-4bca-b097-3ee90947ba73%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/98c1a0f7-34fa-4649-8919-05c8803dab17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Michael DeHaan
If remote temp is outside of your home why would it still prevent things
from unmounting?



On Fri, Sep 12, 2014 at 4:39 PM, Jesse DeFer  wrote:

> raw doesn't seem to have a chdir option or it doesn't have the effect I
> need, command does but it still shows open files.  I already have
> remote_tmp set to a different directory.  I'm sure I could do something
> with at, but that's not the cleanest way to do it.  I had thought to set
> "sudo_exe = cd / && sudo" but that caused errors about executing sudo.
>
> On Friday, September 12, 2014 1:07:50 PM UTC-7, Michael DeHaan wrote:
>>
>> Or configure ansible.cfg to use a different temp dir path?
>>
>> On Fri, Sep 12, 2014 at 4:07 PM, Michael DeHaan 
>> wrote:
>>
>>> Another thought might be to use the "at" module to defer execution of
>>> this particular command, sleep a bit to let it run, and then proceed?
>>>
>>>
>>>
>>> On Fri, Sep 12, 2014 at 4:01 PM, Michael Peters 
>>> wrote:
>>>
 Does the chdir argument to raw work?

   raw: "/usr/sbin/lsof /afs" chdir="/"

 On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer  wrote:
 > I am trying to create a playbook to unmount an AFS mounted home
 directory,
 > but I can't unmount it because the user running ansible has open files
 > because of ansible.  I can't do this with user with a local home, or
 ssh
 > configs or anything like that.   I need to do it with a regular
 ansible play
 > and regular user, so no funky ssh configs or other changes to my
 hosts.
 >
 > Here is my play:
 > - name: check if files are open in /afs
 >   raw: "cd / && /usr/sbin/lsof /afs"
 >   register: command_result
 >   failed_when: "command_result.rc != 1"
 >
 > If I run it with ansible, it will succeed, but ansible-playbook will
 show
 > two processes spawned by the ansible run (sh and sudo).
 >
 > Is there a way to change the current directory before tasks are run?
 >
 > Thanks,
 > Jesse
 >
 > --
 > 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-proje...@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/
 31dfb506-1544-4093-978d-d1a923dd3e33%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-proje...@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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%
 2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.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/c14a01ca-a317-4bca-b097-3ee90947ba73%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/CA%2BnsWgyhGRsL498%3D3kK0ExA%3Doq2N122-pKct6FR8O8Zmr8LV6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Jesse DeFer
raw doesn't seem to have a chdir option or it doesn't have the effect I 
need, command does but it still shows open files.  I already have 
remote_tmp set to a different directory.  I'm sure I could do something 
with at, but that's not the cleanest way to do it.  I had thought to set 
"sudo_exe = cd / && sudo" but that caused errors about executing sudo.

On Friday, September 12, 2014 1:07:50 PM UTC-7, Michael DeHaan wrote:
>
> Or configure ansible.cfg to use a different temp dir path?
>
> On Fri, Sep 12, 2014 at 4:07 PM, Michael DeHaan  > wrote:
>
>> Another thought might be to use the "at" module to defer execution of 
>> this particular command, sleep a bit to let it run, and then proceed?
>>
>>
>>
>> On Fri, Sep 12, 2014 at 4:01 PM, Michael Peters > > wrote:
>>
>>> Does the chdir argument to raw work?
>>>
>>>   raw: "/usr/sbin/lsof /afs" chdir="/"
>>>
>>> On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer >> > wrote:
>>> > I am trying to create a playbook to unmount an AFS mounted home 
>>> directory,
>>> > but I can't unmount it because the user running ansible has open files
>>> > because of ansible.  I can't do this with user with a local home, or 
>>> ssh
>>> > configs or anything like that.   I need to do it with a regular 
>>> ansible play
>>> > and regular user, so no funky ssh configs or other changes to my hosts.
>>> >
>>> > Here is my play:
>>> > - name: check if files are open in /afs
>>> >   raw: "cd / && /usr/sbin/lsof /afs"
>>> >   register: command_result
>>> >   failed_when: "command_result.rc != 1"
>>> >
>>> > If I run it with ansible, it will succeed, but ansible-playbook will 
>>> show
>>> > two processes spawned by the ansible run (sh and sudo).
>>> >
>>> > Is there a way to change the current directory before tasks are run?
>>> >
>>> > Thanks,
>>> > Jesse
>>> >
>>> > --
>>> > 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-proje...@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/31dfb506-1544-4093-978d-d1a923dd3e33%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-proje...@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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.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/c14a01ca-a317-4bca-b097-3ee90947ba73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Michael DeHaan
Or configure ansible.cfg to use a different temp dir path?

On Fri, Sep 12, 2014 at 4:07 PM, Michael DeHaan  wrote:

> Another thought might be to use the "at" module to defer execution of this
> particular command, sleep a bit to let it run, and then proceed?
>
>
>
> On Fri, Sep 12, 2014 at 4:01 PM, Michael Peters  > wrote:
>
>> Does the chdir argument to raw work?
>>
>>   raw: "/usr/sbin/lsof /afs" chdir="/"
>>
>> On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer  wrote:
>> > I am trying to create a playbook to unmount an AFS mounted home
>> directory,
>> > but I can't unmount it because the user running ansible has open files
>> > because of ansible.  I can't do this with user with a local home, or ssh
>> > configs or anything like that.   I need to do it with a regular ansible
>> play
>> > and regular user, so no funky ssh configs or other changes to my hosts.
>> >
>> > Here is my play:
>> > - name: check if files are open in /afs
>> >   raw: "cd / && /usr/sbin/lsof /afs"
>> >   register: command_result
>> >   failed_when: "command_result.rc != 1"
>> >
>> > If I run it with ansible, it will succeed, but ansible-playbook will
>> show
>> > two processes spawned by the ansible run (sh and sudo).
>> >
>> > Is there a way to change the current directory before tasks are run?
>> >
>> > Thanks,
>> > Jesse
>> >
>> > --
>> > 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/31dfb506-1544-4093-978d-d1a923dd3e33%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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.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/CA%2BnsWgzdmmRpy%2BuRhkDOgF_-jq7ErvaF0yOisksBnJLBuKSOgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Michael DeHaan
Another thought might be to use the "at" module to defer execution of this
particular command, sleep a bit to let it run, and then proceed?



On Fri, Sep 12, 2014 at 4:01 PM, Michael Peters 
wrote:

> Does the chdir argument to raw work?
>
>   raw: "/usr/sbin/lsof /afs" chdir="/"
>
> On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer  wrote:
> > I am trying to create a playbook to unmount an AFS mounted home
> directory,
> > but I can't unmount it because the user running ansible has open files
> > because of ansible.  I can't do this with user with a local home, or ssh
> > configs or anything like that.   I need to do it with a regular ansible
> play
> > and regular user, so no funky ssh configs or other changes to my hosts.
> >
> > Here is my play:
> > - name: check if files are open in /afs
> >   raw: "cd / && /usr/sbin/lsof /afs"
> >   register: command_result
> >   failed_when: "command_result.rc != 1"
> >
> > If I run it with ansible, it will succeed, but ansible-playbook will show
> > two processes spawned by the ansible run (sh and sudo).
> >
> > Is there a way to change the current directory before tasks are run?
> >
> > Thanks,
> > Jesse
> >
> > --
> > 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/31dfb506-1544-4093-978d-d1a923dd3e33%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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.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/CA%2BnsWgwJLRzNUUmAoAmvOeEo1h-%3DG%3DrJxYsvraP8qOV2djbtrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Michael Peters
Does the chdir argument to raw work?

  raw: "/usr/sbin/lsof /afs" chdir="/"

On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer  wrote:
> I am trying to create a playbook to unmount an AFS mounted home directory,
> but I can't unmount it because the user running ansible has open files
> because of ansible.  I can't do this with user with a local home, or ssh
> configs or anything like that.   I need to do it with a regular ansible play
> and regular user, so no funky ssh configs or other changes to my hosts.
>
> Here is my play:
> - name: check if files are open in /afs
>   raw: "cd / && /usr/sbin/lsof /afs"
>   register: command_result
>   failed_when: "command_result.rc != 1"
>
> If I run it with ansible, it will succeed, but ansible-playbook will show
> two processes spawned by the ansible run (sh and sudo).
>
> Is there a way to change the current directory before tasks are run?
>
> Thanks,
> Jesse
>
> --
> 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/31dfb506-1544-4093-978d-d1a923dd3e33%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/CAJQqANdF1%2Bcxkic%3Dux%2BK9Zq%2BKja04O1RH9HmVs8qx1xjXVf7KA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Change current directory before tasks are run

2014-09-12 Thread Jesse DeFer
I am trying to create a playbook to unmount an AFS mounted home directory, 
but I can't unmount it because the user running ansible has open files 
because of ansible.  I can't do this with user with a local home, or ssh 
configs or anything like that.   I need to do it with a regular ansible 
play and regular user, so no funky ssh configs or other changes to my hosts.

Here is my play:
- name: check if files are open in /afs
  raw: "cd / && /usr/sbin/lsof /afs"
  register: command_result
  failed_when: "command_result.rc != 1"

If I run it with ansible, it will succeed, but ansible-playbook will show 
two processes spawned by the ansible run (sh and sudo).

Is there a way to change the current directory before tasks are run?

Thanks,
Jesse

-- 
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/31dfb506-1544-4093-978d-d1a923dd3e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.