GithubHelp home page GithubHelp logo

Comments (3)

bengland2 avatar bengland2 commented on August 23, 2024

This playbook works, and is sufficient to get user's ssh public key installed without python on the target system. What do you think Will? This seems simple and breaks the dependency trap.

[bengland@localhost ansible-sshkeys]$ cat raw.yml
---
#
# Ansible playbook to manage SSH keys
#

- hosts: servers
  gather_facts: no
  remote_user: root
  vars:
    ssh_public_key_file: ~/.ssh/id_rsa.pub
    ssh_auth_keys: ~/.ssh/authorized_keys
  tasks:
  - name: read default ssh public key
    local_action: command cat "{{ ssh_public_key_file }}"
    register: ssh_public_key

  - name: install public key in target account .ssh/authorized_keys
    raw: "echo {{ ssh_public_key.stdout_lines[0] }} > {{ ssh_auth_keys }}"

  - name: install python so rest of ansible works!
    raw: "dnf install -y python3 && ln -sv /usr/bin/python3 /usr/bin/python"

So for example if I run this:

ansible-playbook --ssh-common-args '-o StrictHostKeyChecking=no'   -i hosts -e ansible_ssh_pass=password raw.yml

Then I can run:

ansible all -u root -i hosts -m shell -a uptime

from ansible-sshkeys.

bengland2 avatar bengland2 commented on August 23, 2024

https://github.com/bengland2/ocp4_upi_baremetal/blob/master/install_public_key.yml solves my problem, so I stopped using this. I think this is a better approach for RHEL8 since it assumes less about the state of the target system. But I haven't tried it for RHEL7.

from ansible-sshkeys.

sadsfae avatar sadsfae commented on August 23, 2024

Closing this (it's quite old). It's not unreasonable to assume Python is present on a remote host and this playbook requires it.

from ansible-sshkeys.

Related Issues (1)

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.