3

I'd like to automate the creation of my Debian images.

Using Packer 0.7.1 and Preseed this has worked pretty well so far, the only thing I can't get right is the content of /etc/apt/sources.list.

I want it to be like this:

deb http://http.debian.net/debian wheezy main
deb-src http://http.debian.net/debian wheezy main

deb http://http.debian.net/debian wheezy-updates main
deb-src http://http.debian.net/debian wheezy-updates main

deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

With my current scripts I'm only able to get the last two lines which is not enough to install software via apt-get install.

This is how I try to set up the mirrors and apt in my preseed_wheezy.cfg:

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string http.debian.net
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i mirror/suite string wheezy

### Apt setup
d-i apt-setup/use_mirror boolean true
d-i apt-setup/hostname      string http.debian.net
d-i apt-setup/directory     string /debian/
d-i apt-setup/non-free  boolean true
d-i apt-setup/contrib   boolean true
d-i apt-setup/security-updates      boolean true
d-i apt-setup/security-updates-fail string security.debian.org

apt-mirror-setup apt-setup/use_mirror boolean true
apt-mirror-setup mirror/http/hostname    string http.debian.net
apt-mirror-setup apt-setup/contrib  boolean true
apt-mirror-setup apt-setup/non-free     boolean true

Additionally, here is my packer JSON file and the complete preseed_wheezy.cfg.

I'm happy for each suggestion.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171

1 Answers1

2

As a workaround, this is the way I configured my sources.list via the Packer .json file:

{
  "type": "shell",
  "execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
  "inline": [
    "echo deb http://security.debian.org/ wheezy/updates main > /etc/apt/sources.list",
    "echo deb http://http.debian.net/debian wheezy main >> /etc/apt/sources.list",
    "echo deb http://http.debian.net/debian wheezy-updates main >> /etc/apt/sources.list",

    "apt-get update" ,
    "apt-get install python-pip python-dev git -y",
    "pip install PyYAML jinja2 paramiko httplib2",
    "pip install ansible",

  ]
},

Although I didn't get Preseed to set the contents of sources.list, this solution works for me.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171