silpion / ansible-packerio

Install the latest version of packer.io.
Apache License 2.0
1 stars 4 forks source link

Local actions should sudo:no #1

Closed HelloGrayson closed 9 years ago

HelloGrayson commented 10 years ago

Because I have sudo set higher up the line, it attempts to sudo for local_action, which is incorrect.

TASK: [groover.ansible-packerio | Assert platform is supported] ***************
ok: [192.168.50.30]

TASK: [groover.ansible-packerio | include_vars {{ansible_system}}.yml] ********
ok: [192.168.50.30]

TASK: [groover.ansible-packerio | include_vars {{ansible_os_family}}.yml] *****
ok: [192.168.50.30]

TASK: [groover.ansible-packerio | Install unarchive module dependencies] ******
ok: [192.168.50.30] => (item=tar)
ok: [192.168.50.30] => (item=unzip)

TASK: [groover.ansible-packerio | Ensure local download directory] ************
failed: [192.168.50.30] => {"failed": true, "item": "", "parsed": false}
invalid output was: [sudo via ansible, key=dtabasjkajrrrtcmzmuhnsoxfbiayyvl] password:

FATAL: all hosts have already failed -- aborting

What do you think?

jgrowl commented 10 years ago

Not sure what the solution should be but I seem to be running into the same problem. I am calling the role from another playbook where I set sudo to true.

ghost commented 10 years ago

Hi,

ansible_local_data_path defaults to /usr/local/... which requires root access to create files here. I treat this directory as persistent layer so it doesn't default to something like /tmp. Users might have /tmp configured for tmpfs with very small size as well. I want the persistent layer to be usable for any user calling ansible on the management node. Your option would be to tell ansible-playbook the --ask-sudo-pass argument. That's the intention. If you have better ideas, I'd appreciate any further feedback!

jgrowl commented 10 years ago

I have a suggestion. Remove the local_action commands all together. Just default with downloading the zip directly from the packerio to the node that is under control. I assume you wanted the persistent layer to keep from downloading packer from packerio every time you used the role. I think this would be better achieved by leveraging a source URL parameter and then externally setting up a local mirror of the zips inside of your network. This will keep things simple.

ghost commented 10 years ago

Hey, thought about that... I feel this will generate the necessity at larger sites to install/provide a local mirror in order to reduce bandwidth for both sides of the download.

Currently I'm thinking of

At a first glance this seems to work well (at least for me) and doesn't force anyone to do anything special to have the role running at their site.

ghost commented 10 years ago

I've pushed the change noticed above to the hotfix/ansible-data-path branch. Would be delighted if that is an acceptable solution for everyone.

ghost commented 10 years ago

Implemented in version 0.8.1.

rvangundy commented 10 years ago

I'm getting the same error using the latest version. I'm using the ansible provisioner via Vagrant which runs ansible in local mode. Before digging in to specifically why this is happening for me, is there anything I'm expected to configure? I just installed the packerio role and listed it in my main playbook.

ghost commented 10 years ago

Hm. Did the following a second ago:

install -d /tmp/packerio/ansible
$EDITOR /tmp/packerio/Vagrantfile # see below
$EDITOR /tmp/packerio/ansible/playbook.yml # see below
cd /tmp/packerio
git init
git add .
git commit -m 'Root commit'
git submodule add -- git@github.com:silpion/ansible-packerio.git ansible/roles/packerio
ANSIBLE_NOCOWS=1 vagrant up
VAGRANT_API_VERSION = '2'
Vagrant.configure(VAGRANT_API_VERSION) do |config|

  config.vm.box = 'hashicorp/precise64'

  config.vm.define :packerio do |d|

    d.vm.hostname = 'packerio'
    d.vm.synced_folder '.', '/vagrant', id: 'vagrant-root', disabled: true

    d.vm.provision :ansible do |ansible|
      ansible.playbook = 'ansible/playbook.yml'
      ansible.tags = ENV['ANSIBLE_TAGS']
      ansible.groups = {
        'vagrant' => ['packerio']
      }
      ansible.limit = 'vagrant'

      ::File.directory?('.vagrant/provisioners/ansible/inventory/') do
        ansible.inventory_path = '.vagrant/provisioners/ansible/inventory/'
      end

    end

    d.vm.provider :virtualbox do |v|
      v.customize 'pre-boot', ['modifyvm', :id, '--nictype1', 'virtio']
      v.customize [ 'modifyvm', :id, '--name', 'packerio', '--memory', '512', '--cpus', '1' ]
    end

  end
end
---
- hosts: all
  sudo: yes
  sudo_user: root
  roles:
    - { role: packerio }
==> packerio: Running provisioner: ansible...

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [packerio]

TASK: [packerio | Assert platform is supported] ******************************* 
ok: [packerio]

TASK: [packerio | include_vars {{ansible_system}}.yml] ************************ 
ok: [packerio]

TASK: [packerio | include_vars {{ansible_os_family}}.yml] ********************* 
ok: [packerio]

TASK: [packerio | Install unarchive module dependencies] ********************** 
ok: [packerio] => (item=tar)
changed: [packerio] => (item=unzip)

TASK: [packerio | Install packer.io download directory (local)] *************** 
ok: [packerio]

TASK: [packerio | Download packer.io distribution (local)] ******************** 
ok: [packerio]

TASK: [packerio | Ensure installation directory] ****************************** 
changed: [packerio]

TASK: [packerio | Install packer] ********************************************* 
changed: [packerio]

TASK: [packerio | Gathering installed binaries] ******************************* 
changed: [packerio]

TASK: [packerio | Linking binaries into system PATH] ************************** 
changed: [packerio] => (item=/opt/packerio/0.6.0/packer)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-amazon-chroot)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-amazon-ebs)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-amazon-instance)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-digitalocean)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-docker)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-googlecompute)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-null)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-openstack)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-parallels-iso)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-parallels-pvm)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-qemu)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-virtualbox-iso)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-virtualbox-ovf)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-vmware-iso)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-builder-vmware-vmx)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-command-build)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-command-fix)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-command-inspect)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-command-validate)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-post-processor-docker-import)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-post-processor-docker-push)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-post-processor-vagrant)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-post-processor-vsphere)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-ansible-local)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-chef-client)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-chef-solo)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-file)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-puppet-masterless)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-puppet-server)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-salt-masterless)
changed: [packerio] => (item=/opt/packerio/0.6.0/packer-provisioner-shell)

PLAY RECAP ******************************************************************** 
packerio                   : ok=11   changed=5    unreachable=0    failed=0

Worked well for me. No inventory, no configuration of the role. Might still be related to the availability of passwordless sudo on the local workstation (e.g. I've seen some completely annoying bugs with non-passwordless sudo in the unarchive module).

What I would need to dig deeper:

ghost commented 9 years ago

Latest versions have this issue fixed. Sorry, lost track on this one.