Hello Akhilesh,

Thank you very much for your reply.

It worked as expected ;)

Take care


Regards
RG

On Friday, 10 July 2020 14:07:19 UTC+1, Akhilesh Verma wrote:
>
> See if playbook has "become: yes" to run all the commands as root user 
> permission.
> Also from the source container use non-root user to run ansible-playbook.
>
> Thanks,
> Akhilesh Verma
>
> On Fri, Jul 10, 2020 at 4:12 PM Renato Marcandier <[email protected] 
> <javascript:>> wrote:
>
>> Hello guys,
>>
>>
>> I am facing this error when I try to create an new image with packer 
>> using my ansible roles:
>>
>>
>> amazon-ebs: TASK [Install a list of packages] 
>> **********************************************
>> amazon-ebs: fatal: [default]: FAILED! => {“changed”: false, “msg”: “You 
>> need to be root to perform this command.\n”, “rc”: 1, “results”: [“Loaded 
>> plugins: fastestmirror, versionlock\n”]}
>> amazon-ebs: to retry, use: --limit @/root/docker-ecv/AWS/packages.retry
>> amazon-ebs:
>> amazon-ebs: PLAY RECAP 
>> *********************************************************************
>> amazon-ebs: default : ok=1 changed=0 unreachable=0 failed=1
>> amazon-ebs:
>> ==> amazon-ebs: Provisioning step had errors: Running the cleanup 
>> provisioner, if present…
>>
>>
>>
>>
>>
>> ----------------------------------------------------------------------------------------------------------------------------
>>
>> packer.json:
>>
>>
>> {
>> “variables” : {
>> “aws_access_key”: “{{env AWS_ACCESS_KEY }}”,
>> “aws_secret_key”: “{{env AWS_SECRET_KEY }}”
>> },
>> “builders”: [{
>> “vpc_id”: “vpc-xxxxx”,
>> “subnet_id”: “subnet-xxxxxx”,
>> “security_group_id”: “sg-xxxxxxxx”,
>> “region”: “us-east-1”,
>> “type”:“amazon-ebs”,
>> “instance_type”: “t2.micro”,
>> “ssh_username”: “centos”,
>> “ami_name”: “packer-ecv-{{timestamp}}”,
>> “access_key”: “{{user aws_access_key}}”,
>> “secret_key”: “{{user aws_secret_key}}”,
>>
>>     "source_ami_filter": {
>>         "filters" : {
>>             "virtualization-type": "hvm",
>>             "root-device-type":"ebs",
>>             "name" : "CiscoHardened-CentOS7_HVM_EBS-*"
>>         }, 
>>     "owners" : [352039262102],
>>     "most_recent": true
>>     }
>> }],
>> "provisioners" : [{
>>     "type" : "ansible",
>>     "ansible_env_vars": [ "ANSIBLE_NOCOLOR=True" ],
>>     "extra_arguments": [ "--become" ],
>>     "playbook_file" : "packages.yml"
>> },
>> {    
>>     "type" : "ansible",
>>     "playbook_file" : "ecv.yml"
>> }]
>>
>> }
>>
>>
>> --------------------------------------------------------------------------------------------------------
>> ------------------------------
>>
>> packages.yml
>> ------------------------------
>>
>>    - 
>>    
>>    name: Install packages
>>    hosts: all
>>    become_user: root
>>    become_method: sudo
>>    become: yes
>>    tasks:
>>    - 
>>       
>>       name: Install a list of packages
>>       yum:
>>       name:
>>       - unzip
>>       - bzip2
>>       - deltarpm
>>       - epel-release
>>       - python3
>>       state: present
>>       - 
>>       
>>       name: ensure a list of packages installed
>>       yum:
>>       name: “{{ packages }}”
>>       vars:
>>       packages:
>>       - unzip
>>       - bzip2
>>       - deltarpm
>>       - epel-release
>>       - python3
>>       
>>
>> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>> ------------------------------
>>
>> Do you know what can I do to resolve it?
>>
>> Regards
>> RG
>>
>> -- 
>> This mailing list is governed under the HashiCorp Community Guidelines - 
>> https://www.hashicorp.com/community-guidelines.html. Behavior in 
>> violation of those guidelines may result in your removal from this mailing 
>> list.
>>  
>> GitHub Issues: https://github.com/hashicorp/packer/issues
>> IRC: #packer-tool on Freenode
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Packer" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/49c1b65d-03b7-40a3-9b9a-bf6a0718c5e8o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/49c1b65d-03b7-40a3-9b9a-bf6a0718c5e8o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/c43041fe-eb04-4a7c-af8d-1bbc3f1ea621o%40googlegroups.com.

Reply via email to