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
-
evc.yml
-
name: Install ECV
hosts: all
become_user: root
become_method: sudo
become: yesroles:
- ansible-vault-install
- ansible-consul-install
- ansible-envoy
- ansible-vault-cluster # next
- ansible-tls-utils
- ansible-vault-connect-pki
- ansible-consul-cluster
- ansible-vault
Do you know what can I do to resolve it?
Regards
RG