我有使用docker provider和chef-solo provision的Vagrant配置,并且在vagrant up -provider = docker命令之后,Vagrant在chef_solo提供步骤失败:
CentOS失败
==> node1: Machine booted and ready!
==> node1: Running provisioner: chef_solo...
==> node1: Detected Chef (latest) is already installed
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.
和 Suse失败
==> node2: Machine booted and ready!
==> node2: Running provisioner: chef_solo...
node2: Installing Chef (latest)...
Vagrant attempted to execute the capability 'chef_install'
on the detect guest OS 'suse', but the guest doesn't
support that capability. This capability is required for your
configuration of Vagrant. Please either reconfigure Vagrant to
avoid this capability or fix the issue by creating the capability.
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.synced_folder "cnf/", "/home/vagrant/cnf_templates"
config.vm.network "private_network", type: "dhcp"
# node1 - CentOS 6.7
config.vm.define "node1" do |node1|
node1.vm.provider "docker" do |d|
d.build_dir = "centos/"
d.has_ssh = true
#d.ports = ["3306:3306"]
d.privileged = true
#d.remains_running = false
end
node1.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "../../../../recipes/cookbooks"
chef.roles_path = "."
chef.add_role "docker1"
end
end
# node2 - OpenSuSE 13
config.vm.define "node0" do |node2|
node2.vm.provider "docker" do |d|
d.build_dir = "sles/"
d.has_ssh = true
#d.ports = ["3306:3306"]
d.privileged = true
end
node2.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "../../../../recipes/cookbooks"
chef.roles_path = "."
chef.add_role "docker2"
end
end
end
CentOS的Dockerfile
FROM centos:6.7
#ENV SHELL /bin/bash
RUN yum update -y && \
yum clean all && \
yum --assumeyes install openssh-server openssh-clients sudo curl wget iptables
yum clean all
RUN /etc/init.d/sshd start
RUN sed -i 's/.*requiretty$/Defaults !requiretty/' /etc/sudoers
# Create and configure vagrant user
RUN groupadd vagrant && \
useradd -c "Vagrant" -g vagrant -d /home/vagrant -m -s /bin/bash vagrant &&
echo 'vagrant:vagrant' | chpasswd && \
mkdir -p /etc/sudoers.d && \
echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/vagrant
chmod 0440 /etc/sudoers.d/vagrant
# Configure SSH access
RUN mkdir -pm 700 /home/vagrant/.ssh && \
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YV
chmod 0600 /home/vagrant/.ssh/authorized_keys && \
chown -R vagrant:vagrant /home/vagrant/.ssh
# Clean up when done.
#RUN yum clean all
# daemonize sshd
CMD ["/usr/sbin/sshd", "-D", "-e"]
EXPOSE 22
Suse的Dockerfile
FROM opensuse:latest
RUN zypper -n --gpg-auto-import-keys ar http://download.opensuse.org/factory/repo/oss/ OSS
RUN zypper -n ref && \
zypper -n up --skip-interactive && \
zypper --non-interactive --gpg-auto-import-keys install -y openSSH sudo wget iptables SuSefirewall2
ENV SHELL /bin/bash
RUN sed -i 's/UsePAM no/UsePAM yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config
#RUN sed -i 's/#ChallengeResponseAuthentication no/ChallengeREsponseAuthentication ...
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
#RUN echo 'root:13579Rh' | chpasswd
CMD ["/bin/bash", "-c", "rcsshd restart"]
RUN sed -i 's/.*requiretty$/Defaults !requiretty/' /etc/sudoers
# Create and configure vagrant user
RUN groupadd vagrant && \
useradd -m -g vagrant -d /home/vagrant -s /bin/bash vagrant && \
echo 'vagrant:vagrant' && \
echo 'vagrant ALL=(ALL) ALL' >> /etc/sudoers.d/vagrant && \
chmod 0440 /etc/sudoers.d/vagrant
# create ssh host keys for sshd
RUN ssh-keygen -A
# Configure SSH access
RUN mkdir -p /home/vagrant/.ssh && \
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YV$
chmod 0600 /home/vagrant/.ssh/authorized_keys && \
chown -R vagrant:vagrant /home/vagrant/.ssh && \
chmod 0700 /home/vagrant/.ssh
# Install chef
#RUN wget -O - https://www.opscode.com/chef/install.sh | /bin/bash
# Clean up APT when done.
#zypper clean
#RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
CMD ["/usr/sbin/sshd", "-D"]
EXPOSE 22
我的配置有什么问题?我尝试了几乎所有的厨师版安装:omnibus插件,由bash脚本(wget chef.sh | bash)安装的手册厨师和基本的厨师提供。
P.S。 Chef-solo仅适用于Ubuntu 14.04和流浪汉码头提供商。
谢谢, 基里尔
答案 0 :(得分:0)
这很简单,只需使用chef-container或者使用chef-solo和shell provision脚本安装食谱手册:
RUN curl -L https://www.opscode.com/chef/install.sh | bash -s - -P容器