ERROR! Unexpected Exception, this is probably a bug: 'AnsibleLoader' object has no attribute 'get_single_data' - ansible

When I repeat the command "ansible-playbook single.yml" to set the environment.
I got an ansible error "ERROR! Unexpected Exception, this is probably a bug: 'AnsibleLoader' object has no attribute 'get_single_data' to see the full traceback, use -vvv".
[root#localhost data]# ansible --version
ansible 2.8.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
I am not familiar with ansible, and I don't know why it worked before, but now I get an error, and I don't know how to solve it. It is my first time to ask questions here. Thank you for your reply.

Related

How to install Ansible Galaxy Role ontic.fonts?

I try to install the Ansible Galaxy role https://github.com/ontic/ansible-role-fonts and don't find any help in connection with the error message.
Here is what happens:
$ ansible-galaxy install ontic.fonts
Starting galaxy role install process
- downloading role 'fonts', owned by ontic
- downloading role from https://github.com/ontic/ansible-role-fonts/archive/v2.4.0.tar.gz
[WARNING]: - ontic.fonts was NOT installed successfully: this role does not appear to have a meta/Debian.yml file.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
Obviously there is no meta/Debian.yml, correct. But why is it even needed?
Maybe it's a local issue?
$ ansible-galaxy --version
ansible-galaxy [core 2.13.6]
config file = .../ansible/test/ansible.cfg
configured module search path = ['/home/.../.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = .../ansible6/lib/python3.8/site-packages/ansible
ansible collection location = /home/.../.ansible/collections:/usr/share/ansible/collections
executable location = ...ansible6/bin/ansible-galaxy
python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
jinja version = 3.1.2
libyaml = True
I scrambled my local python virtual env, after creating a new one the issue was not reproducible anymore.

Why is ansible-core 2.12 not running Ansible core 2.12?

I've been updating an Ansible project, and as part of that I tried to update an assertion about the Ansible version:
- name: Check Ansible version
assert:
that:
- ansible_version.major == 2 and ansible_version.minor >= 5
I figured the version corresponded to the version of the ansible-core package installed, but that doesn't seem to be the case: it's installing ansible-core 2.12.3 and ansible 5.5.0, but changing the assertion to ansible_version.major == 2 and ansible_version.minor >= 12 results in a failure. If ansible_version corresponds to neither version, what does it correspond to?
The project is still using Python 3.6 (don't worry, upgrading it is on the way), which is no longer supported:
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.9 (default, Dec 8 2021, 21:08:43) [GCC 8.4.0]. This feature will be removed from ansible-core in version 2.12.
I was wondering why that was an error rather than a warning, considering I'm actually running Ansible (core) 2.12. But the very next line indicates that core 2.12 is capable of running with an older core:
ansible-playbook [core 2.11.9]

Ansible install collection offline

I'm trying to install
Ansible from a tar file, but I seem to face issue regarding that:
ansible-galaxy collection install azure-azcollection-1.10.0.tar.gz
Ansible version is 2.10
00:03:08.902 [0mansible-galaxy 2.10.15
00:03:08.902 config file = None
00:03:08.902 configured module search path = ['/plugins/modules', '/ansible/library']
00:03:08.902 ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
00:03:08.902 executable location = /usr/local/bin/ansible-galaxy
00:03:08.902 python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Error I'm getting is:
0:03:25.896 [91m[0;31mERROR! Invalid collection name 'azure-azcollection-1.10.0.tar.gz', name must be in the format <namespace>.<collection>.
I followed this guide : https://www.redhat.com/sysadmin/install-ansible-disconnected-node
Any suggestions?
This is the error you will receive if you specify a file that does not exist.
ec2-user#honest-nyoijizai ~ $ ansible-galaxy --version
ansible-galaxy 2.10.15
config file = None
configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ec2-user/.local/lib/python3.7/site-packages/ansible
executable location = /home/ec2-user/.local/bin/ansible-galaxy
python version = 3.7.10 (default, Jun 3 2021, 00:02:01) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)]
ec2-user#honest-nyoijizai ~ $ ansible-galaxy collection install azure-azcollection-1.10.1.tar.gz
Starting galaxy collection install process
Process install dependency map
ERROR! Invalid collection name 'azure-azcollection-1.10.1.tar.gz', name must be in the format <namespace>.<collection>.
Please make sure namespace and collection name contains characters from [a-zA-Z0-9_] only.
ec2-user#honest-nyoijizai ~ $ ansible-galaxy collection install azure-azcollection-1.10.0.tar.gz
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'azure.azcollection:1.10.0' to '/home/ec2-user/.ansible/collections/ansible_collections/azure/azcollection'
azure.azcollection (1.10.0) was installed successfully

Can't run Ansible Playbook on M1 Mac

When I run ansible-playbook command I get the following error:
ERROR! unexpected parameter type in action: <class 'bool'>
The error appears to be in '/Users/mycomputer/.ansible/roles/wtanaka.jq/tasks/compat_sudo.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: install python-apt on ansible < 1.6.0 and ubuntu et al
^ here
I took a look at that playbook, and I'm not seeing anything that sticks out at me:
---
- name: install python-apt on ansible < 1.6.0 and ubuntu et al
sudo: yes
Ansible Version:
ansible 2.10.7
config file = /Users/mycomputer/Tools/xeno-ansible/ansible.cfg
configured module search path = ['/Users/mycomputer/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/3.1.0/libexec/lib/python3.9/site-packages/ansible
executable location = /opt/homebrew/bin/ansible
python version = 3.9.2 (default, Mar 26 2021, 15:28:17) [Clang 12.0.0 (clang-1200.0.32.29)]
Would this be an issue with Ansible and my M1 Mac or is there something in the playbook that is wrong?
In my case, the issue was that I was using an old playbook that isn't compatible with Ansible 2.9+. I had to install ansible using Rosetta2, similar to this.

Cannot find neither ~/.ansible.cfg or etc/ansible

I installed ansible using pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo pip install ansible
But I cannot find either ~/.ansible.cfg or etc/ansible in macOS.
$ansible --version
WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error.
ansible 2.10.0.dev0
config file = None
configured module search path = [u'/Users/nethminiromina/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/nethminiromina/Library/Python/2.7/lib/python/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.16 (default, Oct 17 2019, 17:14:30) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s
How can I find or setup inventory file?
Q: "Cannot find etc/ansible"
A: pip show -f ansible should show the installed files. If the configuration file is missing create one. See Configuring Ansible.
Q: "How can I find or setup inventory file?"
A: See Where to store Ansible host file on Mac OS X.
You can use ansible-config to show the config file location
% ansible-config --version
ansible-config [core 2.13.1]
config file = None
configured module search path = ['/Users/myusername/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ansible
ansible collection location = /Users/myusername/.ansible/collections:/usr/share/ansible/collections
executable location = /Library/Frameworks/Python.framework/Versions/3.9/bin/ansible-config
python version = 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15) [Clang 6.0 (clang-600.0.57)]
jinja version = 3.1.2
libyaml = True
In this case I had no configuration file (config file = None) so I generated an empty one (option --disabled means all entries are commented out) in the current directory with
% ansible-config init --disabled > ansible.cfg
Now ansible-config can find a configuration file in the current directory /localDir
% ansible-config --version
ansible-config [core 2.13.1]
config file = /localDir/ansible.cfg
[ . . . ]
Note: consider security issues Avoiding security risks with ansible.cfg in the current directory.
Here's the priority list of places where Ansible will search for a config file (see configuration file):
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg

Resources