Re: [packer] packer environment trying to setup on centos 7

2018-03-07 Thread Rickard von Essen
Ensure that tools_upload_flavor is empty, see
https://www.packer.io/docs/builders/vmware-iso.html#tools_upload_flavor

On Mar 8, 2018 07:26, "talha jilal"  wrote:

> Hello Friends ,
>
> I currently trying to setup another envirnoment on Centos 7.  My idea is
> to create a Esxi template by using redhat or centos 7 VM in vcenter and
> reproduce templates.
>
>
> 1- Centos 7 VM.
> 2- Packer (
> packer  -v
> 1.2.1
> 3-  VMware packages installed ,
>
> VMware-VIX-1.15.0-2985596.x86_64.bundle
> VMware-ovftool-4.1.0-2459827-lin.x86_64.bundle
> VMware-vSphere-CLI-5.0.0-615831.x86_64.tar.gz
> VMware-Player-7.1.2-2780323.x86_64.bundle
>
> 4- I am having the following error , please also find my json file at the
> bottom.
>
> packer  build esxi-template.json
> vmware-iso output will be in this color.
>
> Build 'vmware-iso' errored: Couldn't find VMware tools for 'linux'! VMware
> often downloads these
> tools on-demand. However, to do this, you need to create a fake VM
> of the proper type then click the 'install tools' option in the
> VMware GUI.
>
> ==> Some builds didn't complete successfully and had errors:
> --> vmware-iso: Couldn't find VMware tools for 'linux'! VMware often
> downloads these
> tools on-demand. However, to do this, you need to create a fake VM
> of the proper type then click the 'install tools' option in the
> VMware GUI.
>
> ==> Builds finished but no artifacts were created.
>
>
>
>
>
> ## JSON FILE   cat  esxi-template.json
> ##
>
>
>
> {
>   "provisioners": [
> {
>   "type": "shell",
>   "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash
> '{{.Path}}'",
>   "script": "scripts/ansible.sh"
> }
>   ],
>   "builders": [
> {
>   "type": "vmware-iso",
>   "boot_command": [
> " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort
> }}/ks.cfg"
>   ],
>   "boot_wait": "10s",
>   "disk_size": 81920,
>   "guest_os_type": "centos-64",
>   "headless": true,
>   "http_directory": "http",
>   "iso_urls": [
> "CentOS-7-x86_64-Minimal-1708.iso",
> "CentOS-7-x86_64-Minimal-1708.iso"
>   ],
>   "iso_checksum_type": "sha256",
>   "iso_checksum": "bba314624956961a2ea31dd460cd86
> 0a77911c1e0a56e4820a12b9c5dad363f5",
>   "ssh_username": "vagrant",
>   "ssh_password": "vagrant",
>   "ssh_port": 22,
>   "ssh_wait_timeout": "1s",
>   "shutdown_command": "echo 'vagrant'|sudo -S /sbin/halt -h -p",
>   "remote_host": "192.168.2.50",
>   "remote_datastore": "datastore1",
>   "remote_username": "root",
>   "remote_password": "somepass",
>   "ssh_username": "root",
>   "ssh_password": "vagrant",
>   "ssh_wait_timeout": "60m",
>   "tools_upload_flavor": "linux",
>   "http_directory": ".",
>   "boot_wait": "5s",
>   "vmx_data": {
> "memsize": "2048",
> "numvcpus": "2",
> "ethernet0.present": "TRUE",
> "ethernet0.startConnected": "TRUE",
> "ethernet0.virtualDev": "e1000",
> "ethernet0.addressType": "generated",
> "ethernet0.generatedAddressOffset": "0",
> "ethernet0.wakeOnPcktRcv": "FALSE"
>  },
>   "tools_upload_flavor": "linux",
>   "vm_name": "vmware-template",
>   "vmx_data": {
> "cpuid.coresPerSocket": "2",
> "memsize": "2048",
> "numvcpus": "2"
>   }
> }
>   ],
>   "post-processors": [
> {
> "type": "vsphere",
> "host": "192.168.2.50",
> "insecure": true,
> "username": "root",
> "password": "somepass",
> "datacenter": "some",
> "vm_name": "packer-build-centos7",
> "vm_folder": "vagrant",
> "datastore": "datastore1",
> "cluster": "some"
>
> }
> ]
> }
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/6460479d-d45a-4ac7-8a78-1efbcf23643c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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

[packer] packer environment trying to setup on centos 7

2018-03-07 Thread talha jilal
Hello Friends , 

I currently trying to setup another envirnoment on Centos 7.  My idea is to 
create a Esxi template by using redhat or centos 7 VM in vcenter and 
reproduce templates. 


1- Centos 7 VM. 
2- Packer ( 
packer  -v
1.2.1
3-  VMware packages installed , 

VMware-VIX-1.15.0-2985596.x86_64.bundle
VMware-ovftool-4.1.0-2459827-lin.x86_64.bundle
VMware-vSphere-CLI-5.0.0-615831.x86_64.tar.gz
VMware-Player-7.1.2-2780323.x86_64.bundle

4- I am having the following error , please also find my json file at the 
bottom. 

packer  build esxi-template.json
vmware-iso output will be in this color.

Build 'vmware-iso' errored: Couldn't find VMware tools for 'linux'! VMware 
often downloads these
tools on-demand. However, to do this, you need to create a fake VM
of the proper type then click the 'install tools' option in the
VMware GUI.

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Couldn't find VMware tools for 'linux'! VMware often 
downloads these
tools on-demand. However, to do this, you need to create a fake VM
of the proper type then click the 'install tools' option in the
VMware GUI.

==> Builds finished but no artifacts were created.





## JSON FILE   cat  esxi-template.json 
##



{
  "provisioners": [
{
  "type": "shell",
  "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash 
'{{.Path}}'",
  "script": "scripts/ansible.sh"
}
  ],
  "builders": [
{
  "type": "vmware-iso",
  "boot_command": [
" text ks=http://{{ .HTTPIP }}:{{ .HTTPPort 
}}/ks.cfg"
  ],
  "boot_wait": "10s",
  "disk_size": 81920,
  "guest_os_type": "centos-64",
  "headless": true,
  "http_directory": "http",
  "iso_urls": [
"CentOS-7-x86_64-Minimal-1708.iso",
"CentOS-7-x86_64-Minimal-1708.iso"
  ],
  "iso_checksum_type": "sha256",
  "iso_checksum": 
"bba314624956961a2ea31dd460cd860a77911c1e0a56e4820a12b9c5dad363f5",
  "ssh_username": "vagrant",
  "ssh_password": "vagrant",
  "ssh_port": 22,
  "ssh_wait_timeout": "1s",
  "shutdown_command": "echo 'vagrant'|sudo -S /sbin/halt -h -p",
  "remote_host": "192.168.2.50",
  "remote_datastore": "datastore1",
  "remote_username": "root",
  "remote_password": "somepass",
  "ssh_username": "root",
  "ssh_password": "vagrant",
  "ssh_wait_timeout": "60m",
  "tools_upload_flavor": "linux",
  "http_directory": ".",
  "boot_wait": "5s",
  "vmx_data": {
"memsize": "2048",
"numvcpus": "2",
"ethernet0.present": "TRUE",
"ethernet0.startConnected": "TRUE",
"ethernet0.virtualDev": "e1000",
"ethernet0.addressType": "generated",
"ethernet0.generatedAddressOffset": "0",
"ethernet0.wakeOnPcktRcv": "FALSE"
 },
  "tools_upload_flavor": "linux",
  "vm_name": "vmware-template",
  "vmx_data": {
"cpuid.coresPerSocket": "2",
"memsize": "2048",
"numvcpus": "2"
  }
}
  ],
  "post-processors": [
{
"type": "vsphere",
"host": "192.168.2.50",
"insecure": true,
"username": "root",
"password": "somepass",
"datacenter": "some",
"vm_name": "packer-build-centos7",
"vm_folder": "vagrant",
"datastore": "datastore1",
"cluster": "some"

}
]
}

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/6460479d-d45a-4ac7-8a78-1efbcf23643c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Skip shutdown

2018-03-07 Thread Rickard von Essen
Then I would end my provisioning with a file provisioner which downloads a
marker (empty) file and then a script that exits with 1. And then wrap the
Packer build in a script that checks if the marker file exists.

On 7 March 2018 at 18:56, valli nayagam  wrote:

> I'm using vmware-iso builder and would like to use the machine for other
> operations without power on again.
>
> *Example:*
> Step 1: Building Debian server and installing an app using ansible
> provision.
> Step 2: Run automation scripts and tests against above provisioned machine.
>
> Regards
> Vallinayagam.K
>
> On Wednesday, 7 March 2018 22:52:06 UTC+5:30, Rickard von Essen wrote:
>>
>> No in general it's not. Which builder do you use and what's the reason
>> for this?
>>
>> On Mar 7, 2018 17:02, "valli nayagam"  wrote:
>>
>> Hi All
>>
>> Is it possible to skip the shutdown operation after build and
>> provisioning the machine?
>>
>> I'm not sure whether my understanding is valid, but looking for some
>> answers.
>>
>> Thanks in advance.
>>
>> Regards
>> Vallinayagam. K
>>
>> --
>> 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/ms
>> gid/packer-tool/19e1a8e4-95d8-446b-bc09-432fdce5e3ba%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/3ff6adc6-04c6-4795-a9f7-ee7747cab193%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt8-T8POz0ALNFPzX0tRCiGWmQQzeMYqhrP1wJ%3DHFGKtEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Getting region from AWS profile

2018-03-07 Thread Rickard von Essen
You can either do:

A) packer build -var region=$(aws configure --profile  get region)
template.json

Or (IMHO better)

B) Use the metadata on the instance, see
https://stackoverflow.com/questions/4249488/find-region-from-within-an-ec2-instance

On 7 March 2018 at 18:07, John Mc Quillan  wrote:

> Does anyone know how to get the region from the AWS profile and use it to
> set a user variable so that it can be passed through to provisioners.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/06f531e6-67ba-44c1-b0db-4594564fa1da%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9szYBscFd4aQO5y287n%2BtH%3DeD8Gcn%2Bu1bAqiaxF46Xog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Skip shutdown

2018-03-07 Thread valli nayagam
I'm using vmware-iso builder and would like to use the machine for other 
operations without power on again.

*Example:*
Step 1: Building Debian server and installing an app using ansible 
provision. 
Step 2: Run automation scripts and tests against above provisioned machine.

Regards
Vallinayagam.K

On Wednesday, 7 March 2018 22:52:06 UTC+5:30, Rickard von Essen wrote:
>
> No in general it's not. Which builder do you use and what's the reason for 
> this? 
>
> On Mar 7, 2018 17:02, "valli nayagam"  
> wrote:
>
> Hi All
>
> Is it possible to skip the shutdown operation after build and provisioning 
> the machine? 
>
> I'm not sure whether my understanding is valid, but looking for some 
> answers.
>
> Thanks in advance.
>
> Regards
> Vallinayagam. K
>
> -- 
> 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/19e1a8e4-95d8-446b-bc09-432fdce5e3ba%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/3ff6adc6-04c6-4795-a9f7-ee7747cab193%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Skip shutdown

2018-03-07 Thread Rickard von Essen
No in general it's not. Which builder do you use and what's the reason for
this?

On Mar 7, 2018 17:02, "valli nayagam"  wrote:

Hi All

Is it possible to skip the shutdown operation after build and provisioning
the machine?

I'm not sure whether my understanding is valid, but looking for some
answers.

Thanks in advance.

Regards
Vallinayagam. K

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/packer-tool/19e1a8e4-95d8-446b-bc09-432fdce5e3ba%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9C9ibn0onSmu0KDS5evH-ixQzFc-f7GuwnZodGdr9F1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[packer] Getting region from AWS profile

2018-03-07 Thread John Mc Quillan
Does anyone know how to get the region from the AWS profile and use it to 
set a user variable so that it can be passed through to provisioners.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/06f531e6-67ba-44c1-b0db-4594564fa1da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[packer] Skip shutdown

2018-03-07 Thread valli nayagam
Hi All

Is it possible to skip the shutdown operation after build and provisioning 
the machine? 

I'm not sure whether my understanding is valid, but looking for some 
answers.

Thanks in advance.

Regards
Vallinayagam. K

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/19e1a8e4-95d8-446b-bc09-432fdce5e3ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Ansible + Docker instead of multiple Dockerfiles. Should I use multiple Packer template files?

2018-03-07 Thread Loric Brevet
Thank you for your precise explanation, and for having posted this code as 
example on GitHub.

These conditions on provisioning can effectively bring some interest for 
this purpose.

Usually, docker-compose files contain less that 10 containers. So it maybe 
possible to keep them definitely in the same file.

In the end, it seem to be more a matter of readability and maintenance to 
decide to split them into separate JSON files.

What I can notice however – correct me if I am wrong – is that it is not 
possible to have multiple builders provisioned only once by one 
provisioning script.
It seems the provisioning is triggered once per builder.

In Ansible, we usually define an inventory as followed.

[git]
xenial-git

[vim]
xenial-vim

And so launching the playbook would at once match the corresponding builder 
from the inventory and install the git package in the git container, and 
the vim package in the vim container.

That behavior does not seem possible with Packer + Ansible + Docker.

That would correspond to a Packer JSON file more or less as below.

{
"variables": {
},
"builders": [
{
"commit": true,
"image": "ubuntu:xenial",
"pull": true,
"type": "docker",
"name": "xenial-vim",
"run_command": [
"-d","-t","{{.Image}}",
"/bin/bash","-l"
]
},
{
"commit": true,
"image": "ubuntu:xenial",
"pull": true,
"type": "docker",
"name": "xenial-git",
"run_command": [
"-d","-t","{{.Image}}",
"/bin/bash","-l"
]
}
],
"post-processors": [
{
"only": [ "xenial-vim" ],
"repository": "xenial-vim",
"tag": "latest",
"type": "docker-tag"
},
{
"only": [ "xenial-git" ],
"repository": "xenial-git",
"tag": "latest",
"type": "docker-tag"
}
],
"provisioners": [
{
"type": "ansible",
"playbook_file": "ansible/myplaybook.yml"
}
]
}

Packer could process to this sequence of actions:

   - Create xenial-vim base image from the first builder
   - Create xenial-git base image from the second builder
   - Create a dynamic inventory for Ansible
   - Execute only once the provisioning to provision at once the two 
   previous builder images
   - Commit, tag and push xenial-vim to the xenial-vim repository
   - Commit, tag and push xenial-git to the xenial-git repository


Can you confirm this is not really doable with Packer? Or at least the 
provisioning would be launched twice?

Thank you so much,
Loric


On Wednesday, 7 March 2018 12:05:21 UTC+1, Alvaro Miranda Aguilera wrote:
>
> Hello
>
> Yes, can be done
>
>
>
>
>
> TL;DR check this:
> https://github.com/kikitux/packer-multidocker
>
>
>
>
> for many many dockers, I would suggest have one json per docker and have 
> something like a make file
>
> but for 2 its still doable
>
> say you have 2 dockers, and you want 3 provision to run, one shared and 
> one local
>
> the feature you need is inside each build you can use a name.
>
> "builders": [
>
> {
>
> ..
>
> "image": "ubuntu:xenial",
>
> ..
>
> "type": "docker",
>
> "name": "xenial-vim",
>
> ..
>
> },
>
>
>
>
>
> for your request, imagine you have db and www but to keep things simple i 
> just used vim/git
>
>
> for this example i did
>
> xenial-vim
> xenial-git
>
> both get htop installed but then a local script run vim gets vim, git gets 
> git
>
> root@ubuntu-1604-vmware:/vagrant/multidocker# docker run --rm xenial-vim 
> which htop vim git
>
> /usr/bin/htop
>
> /usr/bin/vim
>
> root@ubuntu-1604-vmware:/vagrant/multidocker# docker run --rm xenial-git 
> which htop vim git
>
> /usr/bin/htop
>
> /usr/bin/git
>
> root@ubuntu-1604-vmware:/vagrant/multidocker#
>
>
> so when you build you can run provisioners like shell, if you filter with 
> `only` you can have an specific one
>
>
> as you have names on each builder then you can filter on post-processor to 
> have a tag on the one you want to tag, 
>
> git -> git
> vim -> vim
>
>
> Let me know if there is any question, I think the json in the repo is 
> clear, but feel free to reach out if not.
>
>
>
> Thanks
> Alvaro
>
>
>
> On Wed, Mar 7, 2018 at 11:16 AM, Loric Brevet  > wrote:
>
>> Hello,
>>
>> I am planning to move one of my projects from plain Dockerfiles to Packer 
>> builds.
>>
>> I currently have two images built with Dockerfiles composing one 
>> docker-compose.yml project as followed.
>>
>> version: '3'
>> services:
>>   web:
>> build: Dockerfile.web
>> ports:
>>  - "5000:5000"
>>   db:
>> build: Dockerfile.db
>>
>>
>> My question was: should I use one package.json per Dockerfile or should I 
>> build both images from the 

Re: [packer] Re: passing command line arguments to packer fails with "No such file or directory"

2018-03-07 Thread Alvaro Miranda Aguilera
hello

I think you are trying to go to a complex workaround and you could make
things simple.

create a file with all the variables you need

then using file provisioning copy the file to the VM/Docker
then using shell provisioning run an script that use that file



On Wed, Mar 7, 2018 at 12:29 PM, Bubunia Patra 
wrote:

> Hi,
>
> Is there a way I can pass the inline params to the provisioner scripts for
> example instead of var1 /varlist[0]/[1]  or that needs to be  passed script
> and script need to do parsing??
>
> Regards
> Pradeep
>
> execute_command": "{{.Vars}} var1={{user `arg1`}} var2={{user `arg2`}} sudo
> -E -S bash '{{.Path}' "
>
> On Tuesday, March 6, 2018 at 11:02:49 PM UTC+8, Bubunia Patra wrote:
>>
>>
>> Hi,
>>
>> The below method you suggested works perfect for me :
>>
>> "execute_command": "{{.Vars}} var1={{user `arg1`}} var2={{user `arg2`}} sudo
>> -E -S bash '{{.Path}' "
>>
>> But when the var1=test-packer-prov or var1=test.packer.prov then it fails
>> with the "command not found" error.
>>  Where as if var1=test_packer_prov it works perfectly.
>>
>> What I tried to add the escape \ with - the JSON parsing fails.
>>
>> I am trying to use inline/file provision upload method(
>> https://groups.google.com/forum/#!topic/packer-tool/G2TKbBQOGcQ)
>>
>> Regards
>> Pradeep
>>
>>
>>
>>
>> On Tuesday, March 6, 2018 at 4:14:52 PM UTC+8, Alvaro Miranda Aguilera
>> wrote:
>>>
>>> hello
>>>
>>> if you can share what and how are you doing (and theres time explaining
>>> why?) then will be easier to help you
>>>
>>> so far you are to the point you can have variables in packer and then
>>> use them in the guest vm
>>>
>>> if you are having issues, perhaps you can use a file
>>>
>>> packer can provision a file and then on the script you can source the
>>> file to have all the variables.
>>>
>>> special characters are hard since it may be interpreted somewhere.
>>>
>>> if I had to do this, probably will use shell local to put put the
>>> variables in a file, or have them in a file already and then use them in
>>> the VM.
>>>
>>> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/fb6e09f8-e4e7-43e8-b6af-8588e3b737ea%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CAHqq0eza-%2BZ3Un9Zxy7ngGC_Qv67Bk4KghbLiPEWtUeiDDpAwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Re: passing command line arguments to packer fails with "No such file or directory"

2018-03-07 Thread Bubunia Patra
Hi,

Is there a way I can pass the inline params to the provisioner scripts for 
example instead of var1 /varlist[0]/[1]  or that needs to be  passed script 
and script need to do parsing??

Regards
Pradeep

execute_command": "{{.Vars}} var1={{user `arg1`}} var2={{user `arg2`}} sudo 
-E -S bash '{{.Path}' "

On Tuesday, March 6, 2018 at 11:02:49 PM UTC+8, Bubunia Patra wrote:
>
>
> Hi,
>
> The below method you suggested works perfect for me :
>
> "execute_command": "{{.Vars}} var1={{user `arg1`}} var2={{user `arg2`}} sudo 
> -E -S bash '{{.Path}' "
>
> But when the var1=test-packer-prov or var1=test.packer.prov then it fails 
> with the "command not found" error.
>  Where as if var1=test_packer_prov it works perfectly.
>
> What I tried to add the escape \ with - the JSON parsing fails.
>
> I am trying to use inline/file provision upload method(
> https://groups.google.com/forum/#!topic/packer-tool/G2TKbBQOGcQ)
>
> Regards
> Pradeep
>
>
>
>
> On Tuesday, March 6, 2018 at 4:14:52 PM UTC+8, Alvaro Miranda Aguilera 
> wrote:
>>
>> hello
>>
>> if you can share what and how are you doing (and theres time explaining 
>> why?) then will be easier to help you
>>
>> so far you are to the point you can have variables in packer and then use 
>> them in the guest vm
>>
>> if you are having issues, perhaps you can use a file
>>
>> packer can provision a file and then on the script you can source the 
>> file to have all the variables.
>>
>> special characters are hard since it may be interpreted somewhere.
>>
>> if I had to do this, probably will use shell local to put put the 
>> variables in a file, or have them in a file already and then use them in 
>> the VM.
>>
>> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/fb6e09f8-e4e7-43e8-b6af-8588e3b737ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Ansible + Docker instead of multiple Dockerfiles. Should I use multiple Packer template files?

2018-03-07 Thread Alvaro Miranda Aguilera
Hello

Yes, can be done





TL;DR check this:
https://github.com/kikitux/packer-multidocker




for many many dockers, I would suggest have one json per docker and have
something like a make file

but for 2 its still doable

say you have 2 dockers, and you want 3 provision to run, one shared and one
local

the feature you need is inside each build you can use a name.

"builders": [

{

..

"image": "ubuntu:xenial",

..

"type": "docker",

"name": "xenial-vim",

..

},





for your request, imagine you have db and www but to keep things simple i
just used vim/git


for this example i did

xenial-vim
xenial-git

both get htop installed but then a local script run vim gets vim, git gets
git

root@ubuntu-1604-vmware:/vagrant/multidocker# docker run --rm xenial-vim
which htop vim git

/usr/bin/htop

/usr/bin/vim

root@ubuntu-1604-vmware:/vagrant/multidocker# docker run --rm xenial-git
which htop vim git

/usr/bin/htop

/usr/bin/git

root@ubuntu-1604-vmware:/vagrant/multidocker#


so when you build you can run provisioners like shell, if you filter with
`only` you can have an specific one


as you have names on each builder then you can filter on post-processor to
have a tag on the one you want to tag,

git -> git
vim -> vim


Let me know if there is any question, I think the json in the repo is
clear, but feel free to reach out if not.



Thanks
Alvaro



On Wed, Mar 7, 2018 at 11:16 AM, Loric Brevet 
wrote:

> Hello,
>
> I am planning to move one of my projects from plain Dockerfiles to Packer
> builds.
>
> I currently have two images built with Dockerfiles composing one
> docker-compose.yml project as followed.
>
> version: '3'
> services:
>   web:
> build: Dockerfile.web
> ports:
>  - "5000:5000"
>   db:
> build: Dockerfile.db
>
>
> My question was: should I use one package.json per Dockerfile or should I
> build both images from the same package.json?
>
> I have seen we can use several builders and post-processors with Packer
> but of what I understand, this feature mostly targets the use case of
> building the same image for various platforms (e.g. Docker + Vagrant) at
> the same time.
>
> For my case here, I would like to build two different images not related
> to each others and using different provisioning roles in a same playbook.
>
> Usually, a unique Ansible playbook script is used to provision several
> images according to its inventory (here I would have the web container and
> db container in the inventory), but I am not sure I can do this with Packer.
>
> Thanks in advance,
>
> Loric
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/726b1a9c-484a-4989-943f-2716edcdc567%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CAHqq0ezOB6jrQ3wVfUNLBifj5biO-SS0Lxj14SHk33obD8eB0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[packer] Ansible + Docker instead of multiple Dockerfiles. Should I use multiple Packer template files?

2018-03-07 Thread Loric Brevet
Hello,

I am planning to move one of my projects from plain Dockerfiles to Packer 
builds.

I currently have two images built with Dockerfiles composing one 
docker-compose.yml project as followed.

version: '3'
services:
  web:
build: Dockerfile.web
ports:
 - "5000:5000"
  db:
build: Dockerfile.db


My question was: should I use one package.json per Dockerfile or should I 
build both images from the same package.json?

I have seen we can use several builders and post-processors with Packer but 
of what I understand, this feature mostly targets the use case of building 
the same image for various platforms (e.g. Docker + Vagrant) at the same 
time.

For my case here, I would like to build two different images not related to 
each others and using different provisioning roles in a same playbook.

Usually, a unique Ansible playbook script is used to provision several 
images according to its inventory (here I would have the web container and 
db container in the inventory), but I am not sure I can do this with Packer.

Thanks in advance,

Loric

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/726b1a9c-484a-4989-943f-2716edcdc567%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.