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

222 views
Skip to first unread message

Toan Huynh Van

unread,
Jul 21, 2019, 11:02:51 PM7/21/19
to Ansible Project
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

---
- hosts: all
  gather_facts: no
  ignore_errors: no
  become: yes
  become_method: sudo
  roles:
    - packer_test

/etc/ansible/roles/packer_test/tasks/main.yml

---
 - name: create user
   become: yes
   become_method: sudo
   user:
     name: hvtoan
     comment: Huynh Toan
 - name: install apache2
   apt:
     name: httpd
     state: latest
     update_cache: yes
 - name: restart apache
   service:
     name: httpd
     state: restarted

Vino Thiyagu

unread,
Jul 22, 2019, 1:29:37 AM7/22/19
to ansible...@googlegroups.com
Make an entry for Sudo passwd in your ansible.cfg or keep your sudo passwd in your Json as you kept for ssh pass

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f671b7f8-6225-4689-b9b5-4174687b8ec3%40googlegroups.com.

Toan Huynh Van

unread,
Jul 22, 2019, 11:02:07 PM7/22/19
to Ansible Project
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:
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages