正如Mxx所写,最好的方法是配置Vagrant盒,以便从本地机器使用Ansible配置它 . 然后你只需要键入 vagrant up [name of the box] ,这将启动机器并进行配置 . 下面我附上了一个使用Ansible配置Vagrant框的简单示例,您可以找到有关Ansible provisioner here的所有详细信息 .
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Example of vagrant box provisioned using Ansible
# Start box: "vagrant up dev"
config.vm.define "dev" do |dev|
dev.vm.box = "Centos-6.5-minimal-x86_64-20140116"
dev.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
dev.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm", :id,
"--name", "example-vagrant-box",
"--memory", 1024,
"--cpus", 2,
]
end
dev.vm.network :private_network, ip: "10.0.0.1"
dev.vm.hostname = "vagrant.local"
# Provision the box using Ansible provisioner
dev.vm.provision "ansible" do |ansible|
# Path to the inventory file
ansible.inventory_path = "./inventories/local"
# Path to playbook that should be run against the machine
ansible.playbook = "someplaybook.yml"
# Provisioning verbosity level
# "v", "vv", "vvv", "vvvv". 4 x v for the most verbose debugging info
ansible.verbose = "vvvv"
# Limit provisioning to the following groups
# This defines all the servers (or server groups) which should be provisioned to
# These are defined in the inventory file.
ansible.limit = ["db_servers"]
# Determines whether Ansible ask for Ansible Vault password when provisioner encounter encrypted file
# ansible.ask_vault_pass = "true"
# Optionally Ansible Vault password can be stored in the seperate file and passed like this
ansible.vault_password_file = "./vault-password"
end
end
1 回答
正如Mxx所写,最好的方法是配置Vagrant盒,以便从本地机器使用Ansible配置它 . 然后你只需要键入
vagrant up [name of the box]
,这将启动机器并进行配置 . 下面我附上了一个使用Ansible配置Vagrant框的简单示例,您可以找到有关Ansible provisioner here的所有详细信息 .