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!

On Sunday, March 22, 2020 at 9:33:29 AM UTC, Alvaro Miranda Aguilera wrote:
>
> 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
>
> On Tue, Mar 17, 2020 at 3:06 PM Piya <[email protected] <javascript:>> 
> wrote:
>
>> 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: '[email protected]/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!
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/201b73d8-f5e0-4980-9b40-de95d0aa2f8a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/201b73d8-f5e0-4980-9b40-de95d0aa2f8a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/27c9edb3-cf16-47e3-ac79-1001a8958d90%40googlegroups.com.

Reply via email to