Skip to content

Instantly share code, notes, and snippets.

@nmarley
Last active October 25, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmarley/2a4325ecd2e21556dc00 to your computer and use it in GitHub Desktop.
Save nmarley/2a4325ecd2e21556dc00 to your computer and use it in GitHub Desktop.
Ansible ssh host key scan and set variable
#! /bin/bash
ansible-playbook -e hostname=github.com ssh-host-key-lookup.yml
---
- hosts: localhost
sudo: false
vars:
node_host_key: "{{ lookup('pipe', 'ssh-keyscan -p 22 ' + hostname) }}"
tasks:
- debug:
msg: "The host key is: {{ node_host_key }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment