Windows ami with Packer and Ansible

194 views
Skip to first unread message

gigit1000

unread,
Apr 4, 2019, 3:26:26 PM4/4/19
to Packer


Hello,

I’m trying to use Packer to create a windows ami in aws with an Ansible provisioner and a Powershell provisioner. Without the Ansible provisioner my template works, but when I add the Ansible provisioner it fails with an authentication error: "msg": "Authentication or permission failure.

 

I tried changing the position of the Ansible provisioner to run after the Powershell provisioner, in which case it fails with a different error:
"msg": "failed to resolve remote temporary directory from ansible-tmp-1554400367


I am very new to Packer. I’m I going about this wrong? Is it even possible to use two provisioners in the same template? 
thanks much for any help, my code is below:

 

"provisioners": [

        {

            "type": "ansible",

            "playbook_file": "./play-win2016-base-v2-pack.yaml"          

        },

        {

            "type": "powershell",

            "inline": [

              "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",

              "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"

            ]

        }

gigit1000

unread,
Apr 4, 2019, 5:41:04 PM4/4/19
to Packer
I was able to get this to work by using a packer.py (connection plugin) however only one of my Tasks will work when running a playbook this way. It's a task to create a local directory. Any other task, like to download a file from s3 or run windows updates will fail with a generic error. I'm guessing you must be limited in the tasks/ansible modules you can run from Packer? or maybe there is something additional you need to add to make them work? 
Reply all
Reply to author
Forward
0 new messages