2014-10-05 40 views
2

我想自动创建我的Debian镜像。用Preseed在/etc/apt/sources.list中设置镜像

使用Packer 0.7.1和Preseed这个目前工作得很好,我唯一不能正确的是/etc/apt/sources.list的内容。

我希望它是这样的:

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 

以我目前的剧本,我只能得到最后两行是不够的通过apt-get install安装软件。

这是我尝试设置了反光镜和易于在我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 

此外,这里是我的packer JSON file和完整preseed_wheezy.cfg

我很高兴为每个建议。

+0

您是否曾经发现预包含的文件对于Packer应该是什么样子?如果是这样,请添加答案! – 2015-11-18 13:43:01

回答

0

作为解决办法,这是我配置通过包装机以.json文件我sources.list方式:

{ 
    "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", 

    ] 
}, 

虽然我没有得到的preseed来设置sources.list内容,该解决方案为我工作。