Giter Site home page Giter Site logo

ansible-known_hosts's Introduction

ansible-known_hosts

Add or remove a host from the known_hosts file using ansible.

This is especially useful for a new machine where you want to do something like use the 'git' module with ssh. If you don't prime the known_hosts file, ansible will hang because it is waiting for input you can't give it.

How To Use

Copy the known_hosts bash script into a library folder adjacent to your ansible playbook. You can then define a task like this:

---
- hosts: myhosts
  user: deploy
  tasks:
    - name: Ensure github is in the known_hosts file
      known_hosts: host=github.com state=present

host

Required. The host to add or remove. Will also look up the IP address and add that as well.

port

The ssh port. Defaults to 22

file

The known_hosts file to append/remove the keys from. Defaults to $HOME/.ssh/known_hosts

state

'present' to add the host, 'absent' to remove it. Defaults to 'present'

owner

Username of the owner of 'known_hosts' file, usually useful in case you specified custom filepath in 'file' attribute.

NOTE

Python is considered good form for Ansible modules, but for now it was much easier to convert something I already had written in bash. It does the job, but I may some day convert it to Python in order to submit it to ansible.cc

LICENSE

MIT -- See LICENSE file.

ansible-known_hosts's People

Contributors

brycebaril avatar darkone23 avatar fcoury avatar

Watchers

 avatar  avatar

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.