Skip to content

Instantly share code, notes, and snippets.

@srbharadwaj
Last active May 15, 2020 11:38
Show Gist options
  • Save srbharadwaj/3740b2e829c18c4855f8f6222ad3db39 to your computer and use it in GitHub Desktop.
Save srbharadwaj/3740b2e829c18c4855f8f6222ad3db39 to your computer and use it in GitHub Desktop.
#!/bin/bash
############
# run this file as `source build.sh`
############
# venv
python3.7 -m venv venv
source venv/bin/activate
pip install wheel
pip install paramiko
# gather repos
#https://github.com/ansible-collections/ansible.netcommon.git
function clone {
local REPO_URL=https://github.com/$1/$2.git
echo $REPO_URL
[ ! -d $3 ] && git clone $REPO_URL $3
}
# clone ansible
SRC_ORG=ansible
SRC_REPO=ansible
DEST=$SRC_REPO
clone $SRC_ORG $SRC_REPO $DEST
pip install -r $DEST/requirements.txt
source $DEST/hacking/env-setup
# create dir ansible-collections
COL_DEST=collections/ansible_collections
mkdir -p $COL_DEST
SRC_ORG=ansible-collections
# create dir ansible under ansible-collections
mkdir -p $COL_DEST/ansible
SRC_REPO=ansible.netcommon
DEST=$COL_DEST/ansible/netcommon
clone $SRC_ORG $SRC_REPO $DEST
# cisco
mkdir -p $COL_DEST/cisco
SRC_REPO=cisco.nxos
DEST=$COL_DEST/cisco/nxos
clone $SRC_ORG $SRC_REPO $DEST
# sample inventory
FILE="sample-inventory.yaml"
/bin/cat <<EOM >$FILE
all:
vars:
ansible_user: "{{ lookup('env', 'ansible_user') }}"
ansible_password: "{{ lookup('env', 'ansible_password') }}"
ansible_become_pass: "{{ lookup('env', 'ansible_become_pass') }}"
ansible_become: True
ansible_become_method: ansible.netcommon.enable
ansible_connection: ansible.netcommon.network_cli
ansible_python_interpreter: python
hosts:
ios101:
ansible_network_os: cisco.ios.ios
nxos101:
ansible_network_os: cisco.nxos.nxos
eos101:
ansible_network_os: arista.eos.eos
vyos101:
ansible_network_os: vyos.vyos.vyos
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment