IT notes

Python quit unexpectedly macOS Catalina

When running something depending on OpenSSL you may get something like this on macOS 10.15.2: The output of the report: To fix: brew reinstall openssl Then: cd /usr/local/lib sudo ln -s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib sudo ln -s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib

Ansible ad-hoc

To send a command to all the servers within a playbook: $ ansible all -a "service chronyd restart" -u devops --become What’s an ad-hoc command? An ad-hoc command is something that you might type in to do something really quick, but don’t want to save for later.

Ansible Patterns

To match hosts only starting with certain string a regex could be used for example to match hosts starting with the word fabrik: --- - hosts: ~fabrik.* become: True tasks: - name: uname shell: uname -a register: uname - debug: var: uname.stdout notice the ~


Reboot and wait until server is reachable/usable: - name: Something that may reboot shell: echo "true" register: should_reboot - name: Rebooting ... shell: sleep 2 && /sbin/shutdown -r now "Reboot required" async: 1 poll: 0 ignore_errors: true register: rebooting when: should_reboot.stdout == "true" - name: Wait for rebooted servers to come back wait_for_connection: connect_timeout: 20 sleep: 5 delay: 5 timeout: 60 when: rebooting|changed For checking/testing if a remote host/service is up:

ansible ImportError: No module named boto3

When using ansible (macOS) to fix this problem update your library: pip install --upgrade --user boto3 notice the –user it will update, your local $HOME/Library/Python/2.7/lib/python/site-packages By using --upgrade it will recreate the site-packages. Or create PYTHONPATH system variable: export PYTHONPATH=/usr/local/lib/python2.7/site-packages paramiko In case you get this error: Unicode-objects must be encoded before hashing", "unreachable": true Try: pip install --upgrade --user paramiko==2.0.6 To upgrade,reinstall ansible just in case: