Hi there

Did you get this working at all?

I am trying to figure how to get packer to work with ansible roles i have 
created.  I dont want to use one playbook file.

cheers


On Friday, 15 July 2016 02:05:13 UTC+8, Nirav Radia wrote:
>
> My use-case is to run a playbook which installs Oracle JDK, GIT etc and 
> "synchronize" a folder (say /home/ubuntu/abc) lying on my 
> ansible-controller with ansible-host (at /tmp/abc).
>
>
> Reading the documentation of ansible-remote 
> <https://www.packer.io/docs/provisioners/ansible.html>, I thought using 
> ansible provisioner would be good. But when I did that, to my surprise, the 
> playbook was synchronizing the folder from /home/ubuntu/abc with /tmp/abc 
> on the SAME MACHINE where I am running packer.
>
>
> Is it possible that I can use machine running PACKER as ansible controller 
> and use machine provisioned by packer as host?
>
>
> Here is my packer.json:
> {
>
>
>
> "builders": [
>
> {
>
> "type": "amazon-ebs",
>
> "access_key": "<<my_key_id>>",
>
> "secret_key": "<<my_secret_key>>",
>
> "ami_name": "CentOS 7 AMI by packer - {{timestamp}}",
>
> "ami_description": "AMI created using packer",
>
> "region": "us-west-2",
>
> "source_ami": "ami-d2c924b2",
>
> "instance_type": "t2.micro",
>
> "ssh_username": "centos",
>
> "user_data_file": "disable_tty.sh",
>
> "ami_name": "packer-example-{{timestamp}}",
>
> "tags": {
>
> "Name": "web-nginx"
>
> }
>
> }
>
> ],
>
> "provisioners": [
>
> {
>
> "type": "ansible",
>
> "playbook_file": "ansible/install-binaries.yml",
>
> "user": "centos",
>
> "extra_arguments": ["-vvvv"],
>
> "sftp_command": "/usr/libexec/openssh/sftp-server"
>
> }
>
> ]
>
> }
>
>
> install-binaries.yml
>
>
> ---
>
>
>
> - name: Install JAVA 1.8 if needed
>
>   hosts: all
>
>   become: true
>
>   roles:
>
>    - williamyeh.oracle-java
>
>
>
>
> - name: Install git
>
>   hosts: all
>
>   become: true
>
>   roles:
>
>    - davidkarban.git
>
>    
>
> - name: Install rsync
>
>   hosts: all
>
>   become: true
>
>   roles:
>
>    - kbrebanov.rsync
>
>
>
>
> - name: Copy my directory
>
>   hosts: all
>
>   become: true
>
>   roles:
>
>
>     - ABC.myrole
>
>
>
>
> tasks/main.yml of role ABC.myrole
>
>
> ---
>
>
> - name: Remove installation if exists
>
>   file: path="{{deploy_dir}}" state="absent"
>
>
>
>
> - name: Synchronize installation
>
>   synchronize: src="{{src_dir}}/" dest="{{deploy_dir}}"
>
>
>
>
> - name: Make shell scripts executable
>
>   shell: "find ./ -name '*.sh' -exec chmod +x {} \\;"
>
>   args:
>
>     chdir: "{{deploy_dir}}"
>
>
>
> disable_tty.sh
>
> #!/bin/bash
> sed -i '/Defaults \+requiretty/s/^/#/' /etc/sudoers
>
>
>
> The variable values are:
>
> deploy_dir: "/tmp/myDirectory"
>
> src_dir: ".~/ansible/myDirectory" 
>
>
> Directory structure:
>
> /home/ubuntu/
>
> -- packer.json
>
> -- disable_tty.sh (Need this for "become: true" in playbook on CentOS 7 
> image which I am using)
>
> -- ansible
>
>    -- roles (all the roles are inside this)
>
>    -- install-binaries.yml
>
> -- myDirectory
>
> The task "Synchronize installation" takes too long (waited till 15 
> minutes and then stopped it !!!) and meanwhile, I observed there is 
> myDirectory created in /tmp of the PACKER HOST (of course I can't check on 
> host which PACKER is providing the temp instance it is in creation state)
> The size of myDirectory is more than 550 MB and it contains a LOT of 
> little files and binaries.
>
> Machine I am running packer is Ubuntu 14.04
> Source AMI is Centos 7 from its official website.
>
>

-- 
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/2a4aa2f2-b5f4-4651-9bfa-bf5057ae143c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to