"Error reading package header" when using the Ansible yum install module - yaml

I have an ansible script that looks like this, and it was working properly yesterday -
- name: Dockerfile
hosts: localhost
connection: local
tasks:
- name: Install repositories packages
yum:
name: "{{ item }}"
state: present
with_items:
- https://centos7.iuscommunity.org/ius-release.rpm
- http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.10/CentOS/glusterfs-epel.repo
However this morning when I ran it, I got the following error -
failed: [localhost] (item=[u'https://centos7.iuscommunity.org/ius-release.rpm', u'http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.10/CentOS/glusterfs-epel.repo']) => {"failed": true, "invocation": {"module_name": "yum"}, "item": ["https://centos7.iuscommunity.org/ius-release.rpm", "http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.10/CentOS/glusterfs-epel.repo"], "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_mdVzzz/ansible_module_yum.py\", line 1064, in <module>\n main()\n File \"/tmp/ansible_mdVzzz/ansible_module_yum.py\", line 1053, in main\n disablerepo, disable_gpg_check, exclude, repoquery)\n File \"/tmp/ansible_mdVzzz/ansible_module_yum.py\", line 969, in ensure\n res = install(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)\n File \"/tmp/ansible_mdVzzz/ansible_module_yum.py\", line 595, in install\n pkg_name = local_name(module, package)\n File \"/tmp/ansible_mdVzzz/ansible_module_yum.py\", line 492, in local_name\n header = ts.hdrFromFdno(fd)\n File \"/usr/lib64/python2.7/site-packages/rpm/transaction.py\", line 160, in hdrFromFdno\n raise rpm.error(\"error reading package header\")\n_rpm.error: error reading package header\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
The actual error description is
raise rpm.error(\"error reading package header\")\n_rpm.error: error reading package header\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
Did I break something? Or is this more of an issue with the gluster RPM?

Did you try this one:
- name: Install repositories packages
yum:
name: "{{ item }}"
state: present
with_items:
- https://centos7.iuscommunity.org/ius-release.rpm
- name: Install the gluster repo
get_url:
url: "http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.10/CentOS/glusterfs-epel.repo"
dest: "/etc/yum.repos.d/glusterfs-epel.repo"
mode: 0644

Related

ansible error when use unarchive module on local system

Pls. Help
I`m have this playbook:
---
- name: Install service
hosts: some_host
vars:
app: "{{ app_name }}-{{ tag }}.war"
app_folder: "{{ client_dir }}/{{ app_name }}"
tasks:
- name: Unpack archive Java
unarchive:
src={{ java_distrib }}
dest={{ app_folder }}
creates="{{ app_folder }}/{{ java_home }}"
mode=0555
all work fine when i install on remote host.
But when hosts is same machine from i run ansible-playbook i got this error:
TASK [Unpack archive Java] *********************************************************************************************************
fatal: [10.2.9.6]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 10.2.9.6 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/stend/.ansible/tmp/ansible-tmp-1586175452.58-42679814338845/AnsiballZ_unarchive.py\", line 114, in <module>\r\n _ansiballz_main()\r\n File \"/home/stend/.ansible/tmp/ansible-tmp-1586175452.58-42679814338845/AnsiballZ_unarchive.py\", line 106, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/stend/.ansible/tmp/ansible-tmp-1586175452.58-42679814338845/AnsiballZ_unarchive.py\", line 49, in invoke_module\r\n imp.load_module('__main__', mod, module, MOD_DESC)\r\n File \"/tmp/ansible_unarchive_payload_f_poEj/__main__.py\", line 157, in <module>\r\n File \"/tmp/ansible_unarchive_payload_f_poEj/ansible_unarchive_payload.zip/ansible/module_utils/urls.py\", line 402, in <module>\r\nAttributeError: 'module' object has no attribute 'HTTPSConnection'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
and im not understand whats going on. Why connection closed? im try unarchive to local machine. Where i`m wrong? Pls help !
Problem solved, i`m re install python and library libssl1.1

How can I merge lists with ansible 2.6.3

In the past I used ansible 2.3.1.0 and now want to use ansible 2.6.3.
I now want to install some packages with apt. therefore I have to source lists and I want to merge them in one. In ansible 2.3.1.0 I just used the following:
apt_packages:
- "{{ packages_list1 + packages_list2 }}"
And I am getting the following error:
Traceback (most recent call last):\r\n File \"/tmp/ansible_k0tmag/ansible_module_apt.py\", line 1128, in <module>\r\n main()\r\n File \"/tmp/ansible_k0tmag/ansible_module_apt.py\", line 1106, in main\r\n
allow_unauthenticated=allow_unauthenticated\r\n File \"/tmp/ansible_k0tmag/ansible_module_apt.py\", line 521, in install\r\n pkgspec = expand_pkgspec_from_fnmatches(m, pkgspec, cache)\r\n File \"/tmp/ansible_k0tmag/ansible_module_apt.py\", line 439, in expand_pkgspec_from_fnmatches\r\n
pkgname_pattern, version = package_split(pkgspec_pattern)\r\n File \"/tmp/ansible_k0tmag/ansible_module_apt.py\", line 312, in package_split\r\n
parts = pkgspec.split('=', 1)\r\nAttributeError: 'list' object has no attribute 'split'\r\n", "msg": "MODULE FAILURE", "rc": 1}
Content of the role:
apt:
state: present
name: "{{ apt_packages }}"
force: yes
when: apt_packages is defined```
With apt_packages: "{{ packages_list1 + packages_list2 }}"(without the -), it will work.
Working sample:
- hosts: localhost
gather_facts: no
vars:
pkgs1:
- perl
- python
pkgs2:
- vim
- tar
packages: "{{ pkgs1 + pkgs2 }}"
tasks:
- apt:
name: "{{ packages }}"
state: present

How fix ValueError: too many values to unpack in Ansible?

I have a simple task.
- name: Install executor package
apt:
name: '{{ item }}'
state: present
with_items:
- python-dev
- python-pip
- python-setuptools
- pip:
name: pipenv
He worked. But making a check, I discovered such a mistake.
TASK [pip] ********************************************************************************
fatal: []: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_WJSCVE/ansible_module_pip.py\", line 601, in \r\n main()\r\n File \"/tmp/ansible_WJSCVE/ansible_module_pip.py\", line 561, in main\r\n is_present = _is_present(pkg, version, pkg_list, pkg_cmd)\r\n File \"/tmp/ansible_WJSCVE/ansible_module_pip.py\", line 283, in _is_present\r\n pkg_name, pkg_version = pkg.split(' ')\r\nValueError: too many values to unpack\r\n", "msg": "MODULE FAILURE", "rc": 0}
I can not understand what the problem is.

An exception occurred during task execution in ansible playbook to launch ec2 instance

---
- hosts: localhost
gather_facts: false
vars:
keypair: id_rsa
instance_type: t2.micro
image: ami-6f68cf0f
region: us-west-2
tasks:
- name: launch ec2-instance
ec2:
key_name: "{{ keypair }}"
instance_type: "{{ instance_type }}"
image: ami-6f68cf0f
wait: true
group: wide-open
region: "{{ region }}"
aws_access_key: '************'
aws_secret_key: '********************************'
register: ec2
This what I run but it shows the following error
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 3628, in <module>
main()
File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 1413, in main
(instance_dict_array, new_instance_ids, changed) = create_instances(module, ec2, vpc)
File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 898, in create_instances
grp_details = ec2.get_all_security_groups()
File "/usr/lib/python2.6/site-packages/boto/ec2/connection.py", line 2984, in get_all_security_groups
[('item', SecurityGroup)], verb='POST')
File "/usr/lib/python2.6/site-packages/boto/connection.py", line 1186, in get_list
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>5d241900-6b6e-4398-aba3-16d5738fb6d5</RequestID></Response>
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "ec2"}, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 3628, in <module>\n main()\n File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 1413, in main\n (instance_dict_array, new_instance_ids, changed) = create_instances(module, ec2, vpc)\n File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 898, in create_instances\n grp_details = ec2.get_all_security_groups()\n File \"/usr/lib/python2.6/site-packages/boto/ec2/connection.py\", line 2984, in get_all_security_groups\n [('item', SecurityGroup)], verb='POST')\n File \"/usr/lib/python2.6/site-packages/boto/connection.py\", line 1186, in get_list\n raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>5d241900-6b6e-4398-aba3-16d5738fb6d5</RequestID></Response>\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
The error message you received is a fairly good one in this case:
AWS was not able to validate the provided access credentials
The credentials in question here are those for your AWS account. In particular, your aws_access_key and aws_secret_key variables.
You just need to get the right values for those variables, check what you have against what you were given by whoever issued those credentials/your backup of them if it was yourself.

Error during Creation of VPC in AWS via Ansible

I am trying to create a VPC with the following code.
- name: VPC | Creating an AWS VPC inside mentioned Region
local_action:
module: ec2_vpc
region: "{{ vpc_region }}"
state: present
aws_access_key:
aws_secret_key:
cidr_block: "{{ vpc_cidr_block }}"
resource_tags: { "Name":"{{ vpc_name }}-vpc" }
subnets: "{{ vpc_subnets }}"
internet_gateway: yes
route_tables: "{{ public_subnet_rt }}"
register: vpc
passing the localhost as the host.
But I am facing the following error.
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc", line 2944, in <module>
main()
File "/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc", line 731, in main
(vpc_dict, new_vpc_id, subnets_changed, igw_id, changed) = create_vpc(module, vpc_conn)
File "/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc", line 339, in create_vpc
previous_vpc = find_vpc(module, vpc_conn, id, cidr_block)
File "/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc", line 199, in find_vpc
previous_vpcs = vpc_conn.get_all_vpcs(None, {'cidr': cidr, 'state': 'available'})
AttributeError: 'NoneType' object has no attribute 'get_all_vpcs'
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "ec2_vpc"}, "module_stderr": "Traceback (most recent call last):\n File \"/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc\", line 2944, in <module>\n main()\n File \"/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc\", line 731, in main\n (vpc_dict, new_vpc_id, subnets_changed, igw_id, changed) = create_vpc(module, vpc_conn)\n File \"/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc\", line 339, in create_vpc\n previous_vpc = find_vpc(module, vpc_conn, id, cidr_block)\n File \"/Users/Merv/.ansible/tmp/ansible-tmp-1462873251.31-168428606517499/ec2_vpc\", line 199, in find_vpc\n previous_vpcs = vpc_conn.get_all_vpcs(None, {'cidr': cidr, 'state': 'available'})\nAttributeError: 'NoneType' object has no attribute 'get_all_vpcs'\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
I moved my boto version to 2.40.0 yet facing this issue.
yes It is a bug in the boto library. I installed the latest one. Also, this error persists if, the region name is wrong. So i changed my "{{ vpc_region }}" and this error went away.
Looks like, it a bug in boto library.
Found this: https://github.com/ansible/ansible-modules-core/issues/1772
For a temporary fix(as mentioned in the link):
To manually fix you can
add into each init.py
/usr/lib/python2.7/dist-packages/boto/ec2/init.py
your endpoints for example...
I added to the RegionData for this...
'eu-west-1a': 'ec2.eu-west-1.amazonaws.com',
'eu-west-1b': 'ec2.eu-west-1.amazonaws.com',
'eu-west-1c': 'ec2.eu-west-1.amazonaws.com',

Resources