Ansible+MacOS10.13 HighSierraでのfork()の不具合回避策
Ansibleの学習のため、MacOS10.13 HighSierraにインストールしたAnsible*1で、WindowServer2016に接続することを試していた。しかし次のエラーメッセージが表示され、何回試してもクラッシュしてしまう。
$ ansible -i hosts windows -m win_ping objc[1371]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. objc[1371]: +[__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.
エラーメッセージを参考に調べたところ、issueが見つかった。
Preforking issue on OSX (10.13) when attempting to connect to windows server via WinRM #34056
https://github.com/ansible/ansible/issues/34056#issuecomment-352862252
このissueによると、MacOS 10.13のpythonにおけるfork()の不具合によって、AnsibleからWinRMで接続時にpythonがクラッシュするようだった。
上記で示されている回避策である、MacOSへの次の環境変数の追加
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
によって回避できることを確認できた。