openstack: fatal: [default]: FAILED! => {"msg": "Missing sudo password"}

Hi all,

I have a issue about sudo password when using packer to build image and Ansible for provisioning. The error as title.

below is my json file and playbook. Please help me resolve this issue.

packer.json

{
“builders”: [
{
“type”: “openstack”,
“identity_endpoint”: “URL://”,
“tenant_name”: “tenant”,
“username”: “hvtoan”,
“password”: “hvtoan”,
“availability_zone”: “nova”,
“region”: “RegionOne”,
“image_name”: “Test_image_Packer”,
“source_image”: “d3e5cbab-061d-4f7f-987d-c0d69b7e0bff”,
“ssh_username”: “abc”,
“ssh_password”: “xyz”,
“flavor”: “m1.small”,
“security_groups”: “default”,
“insecure”: “true”,
“networks”: [
“9b2bc188-4e27-4cdf-81ef-82287c3dce5c”
]
}
],
“provisioners”: [
{
“type”: “ansible”,
“playbook_file”: “./create_image.yml”
}
]
}

create_image.yml

(attachments)

Make an entry for Sudo passwd in your ansible.cfg or keep your sudo passwd in your Json as you kept for ssh pass

(attachments)

Thanks Vino, i added to Json file as below, it runs successfully, but I don’t understand command in yellow. Can you explain to me that command?

{
“type”: “shell”,
“execute_command”: “echo ‘{{user ssh_pass}}’ | {{ .Vars }} sudo -E -S sh ‘{{ .Path }}’”,
“inline”: [
“echo ‘%sudo ALL=(ALL) NOPASSWD:ALL’ >> /etc/sudoers”]
},
{
“type”: “ansible”,
“playbook_file”: “./create_image.yml”
}
],

“variables”: {
“ssh_pass”: “shipped!!”
}

Vào 12:29:37 UTC+7 Thứ Hai, ngày 22 tháng 7 năm 2019, Vino Thiyagu đã viết: