Ansible 和流浪者

问题描述 投票:0回答:1

我是使用 ansible 和 vagrant 的新手。 当我执行这个命令时: $流浪者向上 我收到此错误: (item=apt-transport-https) => {"ansible_loop_var": "item", "changed": false, "item": "apt-transport-https", "msg": "无法更新 apt 缓存: 未知原因”}

谁能帮我解决这个问题吗?

ansible vagrant
1个回答
0
投票

我有这个设置。流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 2
  end

config.vm.define "vm-local-1" do | me |
  me.vm.box = 'generic/rocky8'
  me.vm.hostname = "vm-local-1"
  me.vm.network :forwarded_port, guest: 22, host: 65530, id: 'ssh'
  me.vm.network :forwarded_port, guest: 3000, host: 3000, id: 'test'
  me.vm.network "private_network", ip: "10.0.0.110"
  me.vm.provision "ansible" do |ansible|
      ansible.playbook = "playbook.yml"
      ansible.compatibility_mode = "2.0"
      ansible.inventory_path = "./inventory.ini"
      end
  end
end

在同一个文件夹中,我的 inventory.ini:

[local_test]
vm-local-1 ansible_ssh_user=vagrant ansible_ssh_host=127.0.0.1 ansible_ssh_port=65530 ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key

[local_test:vars]
ansible_python_interpreter=/usr/bin/python3

然后是playbook.yml

---
- hosts: local_test
  become: true
  gather_facts: false
  tasks:
    - shell: echo

确保已安装 virtualbox,进行部署

vagrant up

连接到盒子:
ssh -i ~/.vagrant.d/insecure_private_key -p 65530 [email protected]

最后,

© www.soinside.com 2019 - 2024. All rights reserved.