Greengrass: Adding device fails first time

Hi
i am having some issue adding a new device D35 to greengrass .
The first time the role is run on devices newly added to {{ api_greengrass_group_thing_list }} the playbook will fail at this point but then running the playbook a second time the error will go away.

TASK [aws.greengrass : Template out device config] *************************************************************************
fatal: [zzz-ops-greengrass-1]: FAILED! => {“changed”: false, “msg”: “AnsibleUndefinedVariable: ‘dict object’ has no attribute u’D35_cert_arn’”}
[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin (<ansible.plugins.callback.mail.CallbackModule
object at 0x7f2a1bdfda50>): [Errno 111] Connection refused

Need some hints what could me the issue.

There are two error first the variable it is looking for it didn’t get and the connection is not established try to resolve this, then try again.