Last active
July 31, 2017 10:56
-
-
Save irfn/5b0c857cfd1d3615e215dc36ffeba722 to your computer and use it in GitHub Desktop.
pull ec2 hosts to dnsmasq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cd $CHEF_INFRA_HOME/infrastructure;knife search node -a ipaddress "name:*p-* and chef_environment:production" | sed -e ':a' -e 'N' -e '$!ba' -e "s/:\n ipaddress:/ /g" | sed -e '/^\s*$/d' | awk '{print $2" "$1}'> /usr/local/etc/chef_hosts | |
cat /usr/local/etc/chef_hosts | awk '{print "host "$2"\n hostname " $1 "\n user ubuntu\n port 22\n IdentityFile ~/.ssh/id_rsa\n"}' > /usr/local/etc/ssh_config/chef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/etc/resolver/dev | |
nameserver 127.0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/local/etc/dnsmasq.conf | |
domain-needed | |
bogus-priv | |
no-resolv | |
no-poll | |
no-hosts | |
resolv-file=/usr/local/etc/resolv.dnsmasq | |
addn-hosts=/usr/local/etc/hosts | |
address=/.dev/127.0.0.1 | |
server=84.200.69.80 # DNS.WATCH | |
server=8.8.8.8 # Google | |
server=8.26.56.26 # Comodo Secure DNS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
aws ec2 describe-instances --output text --query "Reservations[*].Instances[*].[PrivateIpAddress,Tags[0].[Value][0]][0]" | grep -v "None" > /usr/local/etc/hosts | |
cat /usr/local/etc/hosts | awk '{print "host "$2"\n hostname " $1 "\n user ubuntu\n port 22\n IdentityFile ~/.ssh/id_rsa\n"}' > /usr/local/etc/ssh_config⏎ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
aws ec2 describe-instances --output text --query "Reservations[*].Instances[*].[PrivateIpAddress,Tags[0].[Value][0]][0]" | grep -v "None" > /usr/local/etc/hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat /usr/local/etc/hosts | awk '{print "host "$2"\n hostname " $1 "\n user ubuntu\n port 22\n IdentityFile ~/.ssh/id_rsa\n"}' > /usr/local/etc/ssh_config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Finally include via ~/ssh/config directive Include /usr/local/etc/ssh_config
Include /usr/local/etc/ssh_config/*