jhaals / ansible-vault

ansible lookup plugin for secrets stored in Vault(by HashiCorp)
BSD 3-Clause "New" or "Revised" License
347 stars 65 forks source link

Python Crashes when using this Plugin in OSX High Sierra #60

Open ajrgrubbs opened 7 years ago

ajrgrubbs commented 7 years ago

Summary: Attempting to use this plugin on High Sierra is causing a python crash. Reproduced on both Python 2.7.14 and 3.6.2 (installed with brew). Unable to reproduce with other lookup plugins.

Reproduction: A simple playbook with a debug step will do:

- hosts: localhost
  tasks:
    - debug:
        msg: "{{ lookup('vault', 'secret/dev/test', 'hello') }}"

Symptoms: In the terminal which executes this playbook, the output looks like:

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [debug] *******************************************************************
objc[34976]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[34976]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Additional notes: This appears to be due to some low-level objective-C changes introduced in High Sierra. This article (http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html) has more details. It also provides a workaround: Setting the environment variable OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES. Setting this before running ansible provides successful results.

I'll be honest, I have no clue what the "correct" fix is here, or even if it can be made in this plugin (as opposed to ansible or python itself). Mostly I'm documenting this here in case others come across this issue - I hope someone finds this useful. I'm content with using the environment variable for the time being.

qaisjp commented 6 years ago

I get this same error when using the requests API, on High Sierra.

Probably related to this https://bugs.python.org/issue30837

qaisjp commented 6 years ago

https://github.com/ansible/ansible/issues/31869#issuecomment-337769174

See this solution

(just seen that this solution is mentioned above. wow i should read more)

mikedlr commented 6 years ago

@ajrgrubbs please could you retest using the latest python version from python.org. My testing on a the aws_ssm lookup module seems to show that there is some fix included there.

mikedlr commented 6 years ago

See also https://github.com/ansible/ansible/pull/31500 https://github.com/ansible/ansible/issues/34056 https://github.com/ansible/ansible/issues/32499 and https://github.com/ansible/ansible/issues/31869

ajrgrubbs commented 6 years ago

@mikedlr unfortunately no longer have the means to retest - traded the mac for a PC since I created this issue. My apologies!

snoby commented 6 years ago

I would also mention that you need to export no_proxy='*' as found on this webpage. Otherwise you will get messages like ERROR! A worker was found in a dead state. I'm running in macOS 10.13.3 , a python virtualenv with python version 2.7.10 and tip of master.

z00m1n commented 6 years ago

@snoby : That's true, but not related to the issue; I get the worker was found in a dead state issue on macOS 10.12, but the may have been in progress in another thread issue on macOS 10.13.

alexlopes commented 2 years ago

I would also mention that you need to export no_proxy='*' as found on this webpage. Otherwise you will get messages like ERROR! A worker was found in a dead state. I'm running in macOS 10.13.3 , a python virtualenv with python version 2.7.10 and tip of master.

the first env var stopped working here so setting no_proxy='*' saved me now :), tks!