Search code examples
pythonmacosansibleapple-m1

Installing Ansible on a M1 Mac


Trying to install Ansible locally on my M1. When launching, the following appears:

➜  ~ ansible
Unhandled error:
 Traceback (most recent call last):
  File "/opt/homebrew/Cellar/ansible/6.2.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 547, in get_config_value_and_origin
    value = ensure_type(value, defs[config].get('type'), origin=origin)
  File "/opt/homebrew/Cellar/ansible/6.2.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 89, in ensure_type
    value = int(value)
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/ansible/6.2.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 619, in update_config_data
    value, origin = self.get_config_value_and_origin(config, configfile)
  File "/opt/homebrew/Cellar/ansible/6.2.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 554, in get_config_value_and_origin
    raise AnsibleOptionsError('Invalid type for configuration option %s: %s' %
ansible.errors.AnsibleOptionsError: Invalid type for configuration option setting: DEFAULT_GATHER_TIMEOUT : invalid literal for int() with base 10: ''


ERROR: Invalid settings supplied for DEFAULT_GATHER_TIMEOUT: Invalid type for configuration option setting: DEFAULT_GATHER_TIMEOUT : invalid literal for int() with base 10: ''
. Invalid type for configuration option setting: DEFAULT_GATHER_TIMEOUT : invalid literal for int() with base 10: ''

For installing methods, I tried using brew and pip, both give the same error.

Here is my pip freeze and macos version info

➜  ~ pip freeze          
ansible==6.2.0
ansible-core==2.13.2
cffi==1.15.1
cryptography==37.0.4
Jinja2==3.1.2
MarkupSafe==2.1.1
packaging==21.3
pycparser==2.21
pyparsing==3.0.9
PyYAML==6.0
resolvelib==0.8.1
six @ file:///AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/python3/python3-110/six-1.15.0-py2.py3-none-any.whl
 ➜  ~ sw_vers 
ProductName:    macOS
ProductVersion: 12.5
BuildVersion:   21G72

Solution

  • Should have taken stack trace literally...

    Invalid type for configuration option setting: DEFAULT_GATHER_TIMEOUT : invalid literal for int() with base 10: ''
    

    points to a bad Ansible config file which existed in ~/.ansible.cfg