Last active
February 19, 2020 14:11
-
-
Save cidrblock/b382667163823fba5e48596443a80254 to your computer and use it in GitHub Desktop.
Build an ansible environment with network collections from source
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/bash | |
| ############ | |
| # run this file as `source build.sh` | |
| ############ | |
| # venv | |
| python3 -m venv venv | |
| source venv/bin/activate | |
| pip install wheel | |
| pip install paramiko | |
| # gather repos | |
| function clone { | |
| local [email protected]:$1/$2.git | |
| echo $REPO_URL | |
| [ ! -d $3 ] && git clone $REPO_URL $3 | |
| } | |
| # ansible-base | |
| SRC_ORG=ansible-collection-migration | |
| SRC_REPO=ansible-base | |
| DEST=$SRC_REPO | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| pip install -r $DEST/requirements.txt | |
| source $DEST/hacking/env-setup | |
| # collections | |
| COL_DEST=collections/ansible_collections | |
| mkdir -p $COL_DEST | |
| SRC_ORG=ansible-collections | |
| # ansible netcommon | |
| mkdir -p $COL_DEST/ansible | |
| SRC_REPO=netcommon | |
| DEST=$COL_DEST/ansible/netcommon | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| # arista | |
| mkdir -p $COL_DEST/arista | |
| SRC_REPO=eos | |
| DEST=$COL_DEST/arista/eos | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| # cisco | |
| mkdir -p $COL_DEST/cisco | |
| SRC_REPO=ios | |
| DEST=$COL_DEST/cisco/ios | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| SRC_REPO=iosxr | |
| DEST=$COL_DEST/cisco/iosxr | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| SRC_REPO=nxos | |
| DEST=$COL_DEST/cisco/nxos | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| # junipernetworks | |
| mkdir -p $COL_DEST/junipernetworks | |
| SRC_REPO=junos | |
| DEST=$COL_DEST/junipernetworks/junos | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| # vyos | |
| mkdir -p $COL_DEST/vyos | |
| SRC_REPO=vyos | |
| DEST=$COL_DEST/vyos/vyos | |
| clone $SRC_ORG $SRC_REPO $DEST | |
| # sample ansible.cfg | |
| FILE="ansible.cfg" | |
| /bin/cat <<EOM >$FILE | |
| [defaults] | |
| collection_paths=$PWD | |
| host_key_checking=False | |
| EOM | |
| # sample inventory | |
| FILE="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