概述'vagrant provision'之后的Ansible给出了这个错误:“无法导入python模块:apt,apt_pkg。 请安装python-apt软件包。“
我有一个非常简单的Vagrantfile和Ansible Playbook。 我只是想testing安装httpd。 但是每当我在虚拟机启动后运行vagrant provision ,我得到这个错误:
Rons-MacBook-Pro:development you$ vagrant provision [default] Running provisioner: ansible… PLAY [Install and start apache] *********************************************** GATHERING FACTS *************************************************************** <10.0.0.111> EXEC [\’/bin/sh\’,\’-c\’,\’mkdir -p $HOME/.ansible/tmp/ansible-1384111346.71-231091208956411 && echo $HOME/.ansible/tmp/ansible-1384111346.71-231091208956411\’] <10.0.0.111> REMOTE_MODulE setup <10.0.0.111> PUT /var/folders/h7/3b23bqhs5g39w_jntlkz3hpm0000gn/T/tmpQ3Hvaw TO /Users/you/.ansible/tmp/ansible-1384111346.71-231091208956411/setup <10.0.0.111> EXEC [\’/bin/sh\’,\’/usr/bin/python2.6 /Users/you/.ansible/tmp/ansible-1384111346.71-231091208956411/setup; rm -rf /Users/you/.ansible/tmp/ansible-1384111346.71-231091208956411/ >/dev/null 2>&1\’] ok: [10.0.0.111] TASK: [Update apt cache] ****************************************************** <10.0.0.111> EXEC [\’/bin/sh\’,\’mkdir -p $HOME/.ansible/tmp/ansible-1384111347.33-79837739787852 && echo $HOME/.ansible/tmp/ansible-1384111347.33-79837739787852\’] <10.0.0.111> REMOTE_MODulE apt upgrade=yes update_cache=yes <10.0.0.111> PUT /var/folders/h7/3b23bqhs5g39w_jntlkz3hpm0000gn/T/tmpr5r1YH TO /Users/you/.ansible/tmp/ansible-1384111347.33-79837739787852/apt <10.0.0.111> EXEC [\’/bin/sh\’,\’/usr/bin/python2.6 /Users/you/.ansible/tmp/ansible-1384111347.33-79837739787852/apt; rm -rf /Users/you/.ansible/tmp/ansible-1384111347.33-79837739787852/ >/dev/null 2>&1\’] Failed: [10.0.0.111] => {\”Failed\”: true} msg: Could not import python modules: apt,apt_pkg. Please install python-apt package. FATAL: all hosts have already Failed — aborting PLAY RECAP ******************************************************************** to retry,use: –limit @/Users/you/playbook.retry 10.0.0.111 : ok=1 changed=0 unreachable=0 Failed=1 Ansible Failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.
这是我的stream浪文件:
Vagrant.configure(\”2\”) do |config| # Every Vagrant virtual environment requires a Box to build off of. config.vm.Box = \”development-precise64\” # config.vm.host_name = \”development.somethingwithcomputers.com\” # The url from where the \’config.vm.Box\’ Box will be fetched if it # doesn\’t already exist on the user\’s system. config.vm.Box_url = \”http://files.vagrantup.com/precise64.Box\” config.vm.network \”private_network\”,ip: \”10.0.0.111\” # Share an additional folder to the guest VM. The first argument is # an IDentifIEr,the second is the path on the guest to mount the # folder,and the third is the path on the host to the actual folder. # config.vm.share_folder \”v-data\”,\”/vagrant_data\”,\”../data\” config.vm.synced_folder \”/Users/rontalman/Public/DropBox/Development/Code/Webdevelopment/htdocs/mgc.com\”,\”/var/www\”,ID: \”vagrant-root\”,:nfs => false config.vm.usable_port_range = (2200..2250) config.vm.provIDer :virtualBox do |virtualBox| virtualBox.customize [\”modifyvm\”,:ID,\”–name\”,\”mgc\”] virtualBox.customize [\”modifyvm\”,\”–natdnshostresolver1\”,\”on\”] virtualBox.customize [\”modifyvm\”,\”–memory\”,\”512\”] virtualBox.customize [\”setexTradata\”,\”–VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root\”,\”1\”] end # SSH config.ssh.username = \”vagrant\” config.ssh.shell = \”bash -l\” config.ssh.keep_alive = true config.ssh.forward_agent = false config.ssh.forward_x11 = false config.vagrant.host = :detect # Ansible config.vm.provision \”ansible\” do |ansible| ansible.inventory_path = \”provisioning/inventory.yml\” ansible.playbook = \”provisioning/playbook.yml\” ansible.verbose = \”vvvv\” end end
这是我的简单的playbook.yml:
— – name: Install and start apache hosts: all user: root tasks: – name: Update apt cache apt: upgrade=yes update_cache=yes – name: Install httpd apt: pkg=httpd – name: Start httpd service: name=httpd state=running
我的inventory.yml:
Emacs tramp在linux上编辑windows上的远程文件
基于主机名的Nginx TCP转发
如何使用emacs访问windows共享文件夹
在VM共享目录中运行`grunt`
Ubuntu的错误与可靠的configuration
[vagrant] # Set at config.vm.network in the Vagrantfile 10.0.0.111 ansible_connection=local ansible_ssh_port=2222 ansible_ssh_user=root ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python2.6
我没有在虚拟机上安装python-apt软件包,但仍然没有骰子。 如果有人有任何提示,我很乐意听到他们。
Rails 4,Puma,Nginx – ActionController :: live Streaming在发送第一个块后死亡
当我连接到stream浪的centos 6时,我得到了警告setlocale LC_CTYPE 6
如何做到在windows上与ffserver简单的vIDeostream?
在windows 7上通过QTcpsocketstream式传输图像
puppet exec返回1而不是
我看到你正在使用python2.6的特定python解释器,并且你正在使用Ubuntu Precise 64镜像。 我相信apt-get的Precise 64软件包是python 2.7(每apt-cache show python-apt )。 假设你使用apt和默认的源代码来安装python-apt,我不认为apt软件包将可用于2.6解释器。
我使用的解决方法是将apt-get packgages安装在单独的角色中 ,而不显式设置ansible_python_interpreter 。 然后在其中设置了ansible_python_interpreter的下一个角色中休息。 希望这可以帮助。
总结
以上是内存溢出为你收集整理的'vagrant provision'之后的Ansible给出了这个错误:“无法导入python模块:apt,apt_pkg。 请安装python-apt软件包。“全部内容,希望文章能够帮你解决'vagrant provision'之后的Ansible给出了这个错误:“无法导入python模块:apt,apt_pkg。 请安装python-apt软件包。“所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
请登录后查看评论内容