This is the error I get when I run this code.
[my-host]
19.3.112.97 ansible_ssh_pass=mypass ansible_ssh_user=root
The play book is
---
- hosts: localhost
connection: local
tasks:
- vsphere_guest:
guest: newvm001
vmware_guest_facts: yes
Error:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last): File
"/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py",
line 1879, in
main() File "/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py",
line 1748, in main
viserver.connect(vcenter_hostname, username, password) File "/Library/Python/2.7/site-packages/pysphere/vi_server.py", line 71, in
connect
,FaultTypes.PARAMETER_ERROR) pysphere.resources.vi_exception.VIException: [Parameter Error]: 'host'
should be a string with the ESX/VC url.
fatal: [9.1.142.86]: FAILED! => {"changed": false, "failed": true,
"invocation": {"module_name": "vsphere_guest"}, "module_stderr":
"Traceback (most recent call last):\n File
\"/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py\",
line 1879, in \n main()\n File
\"/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py\",
line 1748, in main\n viserver.connect(vcenter_hostname, username,
password)\n File
\"/Library/Python/2.7/site-packages/pysphere/vi_server.py\", line 71,
in connect\n
,FaultTypes.PARAMETER_ERROR)\npysphere.resources.vi_exception.VIException:
[Parameter Error]: 'host' should be a string with the ESX/VC url.\n",
"module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
Why do i get this error?
You are currently supplying two parameters to vsphere_guest, guest and vmware_guest_facts. However, the documentation lists several more parameters as being required:
password
username
vcenter_hostname
If I had to guess, vcenter_hostname is defaulting to None (Python's null equivalent) and so the code that expects it to be a URI string throws the exception you see there.
Related
I want an empty file to be created by CloudFormation.
I tried providing an empty string in the 'content' field in my CloudFormation template yaml file.
Resources:
Instance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
files:
/var/log/app.log:
content: ""
mode: '000646'
I get the following error: File specified without source or content
2023-01-10 14:32:55,132 [DEBUG] Writing content to /var/log/app.log
2023-01-10 14:32:55,132 [ERROR] Error encountered during build of config: File specified without source or content
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 579, in run_config
CloudFormationCarpenter(config, self._auth_config, self.strict_mode).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 267, in build
self._config.files, self._auth_config)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/file_tool.py", line 131, in apply
self._write_file(f, attribs, auth_config)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/file_tool.py", line 221, in _write_file
raise ToolError("File specified without source or content")
cfnbootstrap.construction_errors.ToolError: File specified without source or content
2023-01-10 14:32:55,137 [ERROR] -----------------------BUILD FAILED!------------------------
2023-01-10 14:32:55,137 [ERROR] Unhandled exception during build: File specified without source or content
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 181, in <module>
worklog.build(metadata, configSets, strict_mode)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 137, in build
Contractor(metadata, strict_mode).build(configSets, self)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 567, in build
self.run_config(config, worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 579, in run_config
CloudFormationCarpenter(config, self._auth_config, self.strict_mode).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 267, in build
self._config.files, self._auth_config)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/file_tool.py", line 131, in apply
self._write_file(f, attribs, auth_config)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/file_tool.py", line 221, in _write_file
raise ToolError("File specified without source or content")
cfnbootstrap.construction_errors.ToolError: File specified without source or content
I get the same error if I omit the 'content' field.
Can you tell me the proper way to instruct CloudFormation to create an empty file?
You need to specify a content. If you really want to create an empty file, then I suggest to use commands.
As brushtakopo pointed out, CloudFormation Init doesn't support creating empty files so the only option appears to be to use a command.
I just wanted to include the corresponding command since he didn't include it in his answer.
Resources:
Instance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
commands:
a_createLogFile:
command: "touch /var/log/app.log"
test: "test ! -e /var/log/app.log"
b_chmodLogFile:
command: "chmod 646 /var/log/app.log"
test: "test -e /var/log/app.log"
Note: The command prefixed with a_ creates the file and the command prefixed with b_ changes its access permissions. The prefixes are to ensure the first command is executed before the second command since CloudFormation executes commands in alphabetical order.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html
The commands are processed in alphabetical order by name.
While trying to create a super user for this application using manage.py I am getting the following error.
root#taiga-back-675fcdbd67-rx552:/taiga-back# ./manage.py createsuperuser
Username: testuser
Email address: testuser#abc.com
Password:
Password (again):
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/amqp/transport.py", line 173, in _connect
host, port, family, socket.SOCK_STREAM, SOL_TCP)
File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname
This is the CELERY Configuration. Sorry, it's Nano
This application running as a pod in a Kubernetes cluster. I searched for this but could not find anything meaningful to begin troubleshooting. Any hints/answer would help.
Ansible 2.9.17 - During inventory check facing parsing.dataloader module not found error
Did not see this issue with Ansible 2.6.
Configs:
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /opt/ansible/2.9.17/lib/python2.7/site-packages/ansible
I can see dataloader.py in the above python module location.
Below error:
Friday 26 February 2021 05:36:33 +0000 (0:00:06.250) 0:00:06.283 *******
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named parsing.dataloader
fatal: [xts-vm-tsa5-centos -> xts-vm-diag9]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 102, in <module>\r\n _ansiballz_main()\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 40, in invoke_module\r\n runpy.run_module(mod_name='ansible.modules.inventory_checks', init_globals=None, run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n fname, loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n mod_name, mod_fname, mod_loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n exec code in run_globals\r\n File \"/tmp/ansible_inventory_checks_payload_8R32eJ/ansible_inventory_checks_payload.zip/ansible/modules/inventory_checks.py\", line 11, in <module>\r\nImportError: No module named parsing.dataloader\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
I m trying to execute the folowing python code:
import logging
import sys
import docker, boto3
from base64 import b64decode
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
LOCAL_REPOSITORY = '111111111111.dkr.ecr.us-east-1.amazonaws.com/my_repo:latest'
image = '111111111111.dkr.ecr.us-east-1.amazonaws.com/my_repo'
ecr_registry, _ = image.split('/', 1)
client = docker.from_env()
# Get login credentials from AWS for the ECR registry.
ecr = boto3.client('ecr')
response = ecr.get_authorization_token()
token = b64decode(response['authorizationData'][0]['authorizationToken'])
username, password = token.decode('utf-8').split(':', 1)
# Log in to the ECR registry with Docker.
client.login(username, password, registry=ecr_registry)
logging.info("loggined")
client.images.pull(image, auth_config={
username: username,
password: password
})
And got exception:
C:\myPath>python app/pull_example.py
INFO:botocore.credentials:Found credentials in environment variables.
INFO:root:loggined
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\docker\api\client.py", line 261, in _raise_for_status
response.raise_for_status()
File "C:\Python3\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localnpipe/v1.35/images/create?fromImage=111111111111.dkr.ecr.us-east-1.amazonaws.com%2Fmy_repo
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "app/pull_example.py", line 41, in <module>
password: password
File "C:\Python3\lib\site-packages\docker\models\images.py", line 445, in pull
repository, tag=tag, stream=True, **kwargs
File "C:\Python3\lib\site-packages\docker\api\image.py", line 415, in pull
self._raise_for_status(response)
File "C:\Python3\lib\site-packages\docker\api\client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "C:\Python3\lib\site-packages\docker\errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("Get https://111111111111.dkr.ecr.us-east-1.amazonaws.com/v2/my_repo/tags/list: no basic auth credentials")
What is the problem? Why I can not pull image even after client.login call which happens wihtout any exeptions. What is the correct way to perform login and pull image from ECR repository and dockerpy?
This was happen due to - https://github.com/docker/docker-py/issues/2157
Deleting ~/.docker/config.json fixed the issue.
I am trying to create an AWS EC2 Auto-Scaling Group using the cloud module ec2_asg.
I have a playbook that is creating Security Groups, Elastic Load Balancer, Launch Config, tags the assets, etc. Everything is working. When I try to create a new ASG, I am getting a failure. Below is the playbook code, and then the -vvv output of the module failure. I am running ansible 2.2.1.0
Any help in troubleshooting is greatly appreciated
#setup Logstash Autoscaling group
- name: ELkstack LogStash ASG
ec2_asg:
name: "pro-ELK-LogStash-ASG"
launch_config_name: "test-test-asg"
health_check_period: 300
health_check_type: EC2
replace_all_instances: yes
replace_batch_size: 1
min_size: 1
max_size: 4
desired_capacity: 1
region: us-east-1
-vvv Error Output
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py", line 875, in <module>
main()
File "/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py", line 864, in main
create_changed, asg_properties=create_autoscaling_group(connection, module)
File "/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py", line 437, in create_autoscaling_group
launch_config=launch_configs[0],
IndexError: list index out of range
fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "ec2_asg"
},
"module_stderr": "Traceback (most recent call last):\n File \"/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py\", line 875, in <module>\n main()\n File \"/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py\", line 864, in main\n create_changed, asg_properties=create_autoscaling_group(connection, module)\n File \"/var/folders/08/x2n75q_925l5xc9hfjc1gz9c0000gn/T/ansible_38fX0z/ansible_module_ec2_asg.py\", line 437, in create_autoscaling_group\n launch_config=launch_configs[0],\nIndexError: list index out of range\n",
"module_stdout": "",
"msg": "MODULE FAILURE"
}
It was a spacing issue, feel dumb, but wanted to post to close this out and in case anyone else runs into this.