Thanks for looking.

PlistBuddy is called with an absolute path in osx.sh (see lines 198-205 for 
example):

https://bitbucket.org/dbohea/mac-setup-playbook/src/0b4d30a3e44a16462d94808c66e15eba0aa44f7d/osx.sh?at=master

I added the following but it doesn't seem tot make a difference (sqlite3 
does seem to get run):

- name: Execute .osx
  # TODO: doesn't run commands that use PlistBuddy or sqlite3
  shell: ./osx.sh --ansible
  notify: killall
  environment:
    PATH: "/usr/bin:/usr/bin/sqlite3/bin"

I also tried the following but still no dice:

PATH: "/usr/bin:/usr/bin/sqlite3"




On Wednesday, 20 August 2014 14:10:23 UTC+1, Michael DeHaan wrote:
>
> Ok so from your playbook:
>
>  - name: Execute .osx
>
>   # TODO: doesn't run commands that use PlistBuddy or sqlite3  shell: 
> ./osx.sh --ansible  notify: killall
>
>
> Inside osx.sh are PlistBuddy and sqlite3 absolute-pathed?  I assume they are 
> not.  I suspect they are in a path defined in your local environment, and 
> won't be in the path for ansible, because of the way we enforce centralized 
> and reliable configurations - not trusting 500 servers who might all have 
> different .bashrcs, etc, we don't log in with interactive shells.
>
>
> You'll want to read this section:
>
>
> http://docs.ansible.com/playbooks_environment.html
>
>
> Then:
>
>
>  - name: Execute .osx
>
>   # TODO: doesn't run commands that use PlistBuddy or sqlite3  shell: 
> ./osx.sh --ansible  notify: killall
>
>   environment:
>
>      PATH: "/usr/bin:/opt/where/is/buddy/bin:/opt/where/is/sqlite3/bin"
>
>
> And you should be good to go.
>
>
> I got a very nice recent PR to make the environment keyword also be applied 
> at play level, though right now it's task level only.
>
>
>
>
>
>
>
> On Wed, Aug 20, 2014 at 6:20 AM, Dan Bohea <[email protected] <javascript:>
> > wrote:
>
>> Sure, the role that attempts to run the bash script is here:
>>
>>
>> https://bitbucket.org/dbohea/mac-setup-playbook/src/414cda3c20b9e20d82c34a2776d0d0c34b6c5d97/roles/osx/tasks/main.yml?at=master
>>
>>
>>
>> On Wednesday, 20 August 2014 02:44:24 UTC+1, Michael DeHaan wrote:
>>
>>> Can I see the playbook line in question.
>>>
>>> Many things don't trust the system path, but most of them do.  The 
>>> command module is one of those things.
>>>
>>> Though if you need explicit environment variable control, take a look 
>>> here:
>>>
>>> http://docs.ansible.com/playbooks_environment.html
>>>
>>>
>>>
>>>  On Tue, Aug 19, 2014 at 3:41 PM, Mark McCoy <[email protected]> wrote:
>>>
>>>> Yes, if the which command found the binary from within ansible, then it 
>>>> should find it when running the script via ansible.  That seems pretty odd 
>>>> that it doesn't.  I know that the script asks for the sudo password so you 
>>>> can run it locally, but does it run via sudo when run by ansible?  If so 
>>>> then it would be using root's path and not yours.
>>>>
>>>>
>>>> ----
>>>> Mark McCoy <http://markmccoy.us>
>>>>
>>>>
>>>>
>>>> On Tue, Aug 19, 2014 at 11:50 AM, Dan Bohea <[email protected]> wrote:
>>>>
>>>>>  Thanks to some advice from elsewhere, I did try to run "shell: which 
>>>>> sqlite3" from within my playbook and then compared the output to what 
>>>>> I receive when I run "which sqlite3" in the command line. The results 
>>>>> are the same.
>>>>>
>>>>> If there was a PATH issue with Ansible trying to run sqlite3, wouldn't 
>>>>> the above test fail (i.e. output from each command wouldn't match)?
>>>>>
>>>>> On Tuesday, 19 August 2014 17:07:38 UTC+1, Mark McCoy wrote:
>>>>>>
>>>>>> It's probable something to do with the PATH in your bash environment. 
>>>>>>  When you login interactively, the .profile rc file gets run and 
>>>>>> normally 
>>>>>> sets up the PATH. I would imagine that when you login via ansible you 
>>>>>> don't 
>>>>>> have the directory for PlistBuddy or sqlite3 in your PATH so those 
>>>>>> commands 
>>>>>> fail.
>>>>>>
>>>>>> You can either fiddle with your ssh_args in the ansible config files 
>>>>>> to tell ssh to make the shell a login shell, or you can just put the 
>>>>>> full 
>>>>>> path to Sqlite3 and PlistBuddy on those lines of your .bashrc file.
>>>>>>
>>>>>>
>>>>>> ----
>>>>>> Mark McCoy <http://markmccoy.us>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Aug 19, 2014 at 4:16 AM, Dan Bohea <[email protected]> wrote:
>>>>>>
>>>>>>> I'm writing a Mac setup playbook and am borrowing heavily from 
>>>>>>> various "dotfiles" around the web to help with configuring certain 
>>>>>>> aspects 
>>>>>>> of OS X.
>>>>>>>
>>>>>>> Here's my current dotfile which is effectively just a bash script:
>>>>>>>
>>>>>>> https://bitbucket.org/dbohea/mac-setup-playbook/src/0b4d30a3
>>>>>>> e44a16462d94808c66e15eba0aa44f7d/osx.sh?at=master
>>>>>>>
>>>>>>> This runs just fine directly from the command line. Oddly, when run 
>>>>>>> from an Ansible playbook, none of the PlistBuddy or sqlite3 commands 
>>>>>>> seem 
>>>>>>> to work.
>>>>>>>
>>>>>>> Anyone know why this may be or what I can do to fix it?
>>>>>>>
>>>>>>>
>>>>>>> PS - Before anyone suggests it, it's nothing to do with the if 
>>>>>>> statement at the end of the file - I've tested this.
>>>>>>>
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "Ansible Project" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/ansible-project/3d8b6856-
>>>>>>> 9fb6-479e-a15b-7367d073264c%40googlegroups.com 
>>>>>>> <https://groups.google.com/d/msgid/ansible-project/3d8b6856-9fb6-479e-a15b-7367d073264c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> 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 [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/ansible-project/5bc8a7ec-e0ff-437d-9f33-
>>>>> ba305726833a%40googlegroups.com 
>>>>> <https://groups.google.com/d/msgid/ansible-project/5bc8a7ec-e0ff-437d-9f33-ba305726833a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/ansible-project/CAP2%3DG9OU2fJBZskiMivMcV7PkJ6tJbeb
>>>> 3bwaOTOWDwbR2yGDQQ%40mail.gmail.com 
>>>> <https://groups.google.com/d/msgid/ansible-project/CAP2%3DG9OU2fJBZskiMivMcV7PkJ6tJbeb3bwaOTOWDwbR2yGDQQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/bb810cc3-e386-4a39-ba49-43e47d11c0d9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/bb810cc3-e386-4a39-ba49-43e47d11c0d9%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/498d8ade-9ef5-428f-b753-73c0c4a08f91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to