Guidance on how to properly use the galaxy_force_install parameter

29 views
Skip to first unread message

Piya

unread,
Mar 17, 2020, 10:05:50 AM3/17/20
to Packer
Hello!

First off, Packer is great - I'm finding it's a dream to work with.

I'm posting here as I think I'm doing something silly which is slowing me down.

Versions
packer 1.5.4
ansible 2.8.6

High level
I'm trying to ask Packer to execute something akin to the below command with a combination of arguments inside an ansible provisioner.
`ansible-galaxy install -r provisioners/test/ansible/requirements.yaml --roles-path ./roles --force`

Expected behaviour

Given this block in packer.json

{
"type": "ansible",
"galaxy_file": "provisioners/{{ user `product` }}/ansible/requirements.yaml",
"galaxy_force_install": true,
"roles_path": "roles",
"playbook_file": "provisioners/{{ user `product` }}/ansible/playbook.yaml",
"user": "ec2-user",
"ansible_env_vars": [
"INVALID_TASK_ATTRIBUTE_FAILED=False"
],
"extra_arguments": [
"-v",
"--extra-vars", "env={{ user `env` }} product_version={{ user `product_version` }}"
]
},

Where galaxy file reads a file looking like this:

---
- name: 'my-test-role'
scm: git
src: 'g...@bitbucket.myaccount/my-test-role.git'
version: 'master'


I expect packer to install all requirements at the roles_path in this case just roles/ in cwd and force overwrite (if exists) because galaxy_force_install is set true.

Actual behaviour
The role is installed the first time packer build is invoked, but on subsequent runs where it has already been installed at roles_path, packer will print the galaxy error: amazon-ebs: [WARNING]: - ansible-role-testing was NOT installed successfully and the build will fail.

Workaround
Deleting the local role and running packer build allows the role to be reinstalled correctly, so I have been doing this every time I need to re-run packer build.

Question
Am I interpreting galaxy_force_install correctly or is this just a galaxy bug?

It would appear it once was, but should be fixed in my version: https://github.com/ansible/galaxy-issues/issues/249

Thanks and hope to hear from you soon!

Alvaro Miranda Aguilera

unread,
Mar 22, 2020, 5:33:29 AM3/22/20
to packe...@googlegroups.com
per documentation it should add --force to the arguments

can you try removing galaxy_force_install and setting --force as extra argument to test if does what you expect ?



this should to confirm where the issue may be

alvaro

--
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/mitchellh/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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/201b73d8-f5e0-4980-9b40-de95d0aa2f8a%40googlegroups.com.


--
Alvaro

Piya

unread,
Mar 26, 2020, 8:37:07 AM3/26/20
to Packer
Thanks Alvaro,

I removed galaxy_force_install and now packer/galaxy checks the contents of roles and if a role is already installed that will be skipped.

That's good - I envisage this will be a problem if the roles being checked out are updated but it gets me around my immediate problem.

Couldn't find a way to add --force as an extra argument to ansible-galaxy but I'll leave this for now.

Thanks for your help!
To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.


--
Alvaro

Alvaro Miranda Aguilera

unread,
Mar 29, 2020, 10:23:00 AM3/29/20
to packe...@googlegroups.com
hello

i mean add --force like "--force", in "extra_arguments"

 here

"extra_arguments": [
"-v",
"--extra-vars", "env={{ user `env` }} product_version={{ user `product_version` }}"
]

alvaro


To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/27c9edb3-cf16-47e3-ac79-1001a8958d90%40googlegroups.com.


--
Alvaro

Reply all
Reply to author
Forward
0 new messages