Code Monkey home page Code Monkey logo

Comments (7)

drybjed avatar drybjed commented on July 24, 2024 1

You need to use lookup('file_src', 'sshkey/mykey.pub') lookup plugin. file is the "normal" one.

from debops-tools.

drybjed avatar drybjed commented on July 24, 2024 1

No problem. I know what is happening here. The file module is used to get the contents of a specified file. The DebOps file_src is used to select a specific file from a set of possible paths. It was written for cases like this:

- copy:
    src: '{{ lookup("file_src", "relative/path/to/file") }}'
    dest: '/remote/file'

The main reason being, so that role contents could stay static and be able to be updated via git, and you could still modify what the role does externally via the configuration file.

In your case, you are using the file_src lookup in the wrong place. You would instead need to do something like this:

sshkeys:
  - '{{ lookup("file", lookup("file_src", "sshkeys/mykey.pub")) }}'

So basically, first find the absolute path to a file you want, and then get its contents. That should make it work.

from debops-tools.

drybjed avatar drybjed commented on July 24, 2024

After debops script generates the ansible.cfg configuration file, ansible command can be used and has the same functionality that debops-task has. I am all in favor of fixing this bug and removing debops-task.

from debops-tools.

dvigueras avatar dvigueras commented on July 24, 2024

Great, I'll use ansible command then.

from debops-tools.

dvigueras avatar dvigueras commented on July 24, 2024

debops command doesn't work well too, it looks like it's trying to read the old inventory file, instead of the file set in ansible.cfg.

I think it could be something related to the function find_inventorypath, but I'm not an expert in Python.

from debops-tools.

tallandtree avatar tallandtree commented on July 24, 2024

I'm running debops (with ansible-playbook 2.1.0.0, from fedora 21) and it looks like the myproject/.debops.cfg is not being read. If I set file-paths in .debops.cfg,

[paths]
file-paths: /home/myname/cm-sys-servers/ansible/files

[ "{{ lookup('file', 'sshkeys/mykey.pub') }}" ] still does not find the file, but searches in the default location only:

fatal: [mymachine]: FAILED! => {"failed": true, "msg": "the file_name '/home/myname/.local/share/debops/debops-playbooks/playbooks/sshkeys/mykey.pub' does not exist, or is not readable"}

from debops-tools.

tallandtree avatar tallandtree commented on July 24, 2024

Indeed, when I use file_src, the file is found. But there is a difference between lookup('file_src', 'sshkey/mykey.pub') and lookup('file', '/home/myname/cm-sys-servers/ansible/files/sshkeys/mykey.pub'). The latter reads contents of the file, while the first only reads the path with filename. I get an invalid key specified:

sshkeys: [ "{{ lookup('file_src', 'sshkeys/mykey.pub') }}" ]
gives the following error in the log:


whereas 
`sshkeys: [ "{{ lookup('file', '/home/myname/cm-sys-servers/ansible/roles/users/files/mykey.pub') }}" ]`
gives something like:

"sshkeys": ["ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"], "state": "present", "system": false, "uid": 1001, "update_password": "on_create"}, "name": "users", "state": "present", "system": false}


Not sure if this is the intended behaviour or I'm doing something else wrong again. (apologies if I should be creating a new issue instead)

from debops-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.