diff --git a/.gitignore b/.gitignore index f289a46..369649c 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,5 @@ venv.bak/ # Ansible *.retry + +roles/toallab.infrastructure/backup/ \ No newline at end of file diff --git a/roles/toallab.infrastructure/README.md b/roles/toallab.infrastructure/README.md new file mode 100644 index 0000000..4bf50a3 --- /dev/null +++ b/roles/toallab.infrastructure/README.md @@ -0,0 +1,40 @@ +Role Name +========= + +Provisions home lab infrastructure. + +Requirements +------------ + +Really, you need my home lab setup. This role isn't really reusable in that regard. + +Role Variables +-------------- + +TBD + +Dependencies +------------ + +My Home Lab + +Example Playbook +---------------- + +TODO + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +MIT + +Author Information +------------------ + +Patrick Toal - ptoal@takeflight.ca - https://toal.ca diff --git a/roles/toallab.infrastructure/defaults/main.yml b/roles/toallab.infrastructure/defaults/main.yml new file mode 100644 index 0000000..f3ab138 --- /dev/null +++ b/roles/toallab.infrastructure/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for toallab.infrastructure \ No newline at end of file diff --git a/roles/toallab.infrastructure/handlers/main.yml b/roles/toallab.infrastructure/handlers/main.yml new file mode 100644 index 0000000..d827d7e --- /dev/null +++ b/roles/toallab.infrastructure/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for toallab.infrastructure \ No newline at end of file diff --git a/roles/toallab.infrastructure/meta/main.yml b/roles/toallab.infrastructure/meta/main.yml new file mode 100644 index 0000000..3a212a9 --- /dev/null +++ b/roles/toallab.infrastructure/meta/main.yml @@ -0,0 +1,53 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.4 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + \ No newline at end of file diff --git a/roles/toallab.infrastructure/tasks/main.yml b/roles/toallab.infrastructure/tasks/main.yml new file mode 100644 index 0000000..abfd521 --- /dev/null +++ b/roles/toallab.infrastructure/tasks/main.yml @@ -0,0 +1,33 @@ +--- +# tasks file for toallab.infrastructure + +- name: Backup IOS Config + connection: network_cli + become: yes + ios_config: + backup: yes + +- name: Install base configuration + connection: network_cli + become: yes + ios_config: + lines: + - enable secret 5 $1$7h96$Q7sso70QqSgFIpY91SuQC0 + - username ptoal privilege 15 secret 5 $1$j4aN$xbLbABGihOTnnHl5PFm4g1 + - aaa new-model + - ip domain-name lan.toal.ca + - ip name-server 192.168.1.1 + - no cdp run + - lldp run + - ip ssh authentication-retries 2 + - ip ssh rsa keypair-name ssh2 + - ip ssh version 2 + - ntp server 0.ca.pool.ntp.org + - ntp server 0.pool.ntp.org + - ntp server ip 1.pool.ntp.org + +- name: Save changes + become: yes + connection: network_cli + ios_config: + save_when: changed diff --git a/roles/toallab.infrastructure/tests/inventory b/roles/toallab.infrastructure/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/toallab.infrastructure/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/toallab.infrastructure/tests/test.yml b/roles/toallab.infrastructure/tests/test.yml new file mode 100644 index 0000000..72749aa --- /dev/null +++ b/roles/toallab.infrastructure/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - toallab.infrastructure \ No newline at end of file diff --git a/roles/toallab.infrastructure/vars/main.yml b/roles/toallab.infrastructure/vars/main.yml new file mode 100644 index 0000000..6c196c0 --- /dev/null +++ b/roles/toallab.infrastructure/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for toallab.infrastructure \ No newline at end of file diff --git a/site.yml b/site.yml index 41f0969..4597f2f 100644 --- a/site.yml +++ b/site.yml @@ -1,10 +1,27 @@ # Toal Lab Site Playbook - name: Common Lab Machine Setup - hosts: all + hosts: all,!switch01 become: true roles: - toal-common +- name: Set Network OS from Netbox info. + gather_facts: no + hosts: switch01 + tasks: + - name: Set network os type for Cisco + set_fact: ansible_network_os="ios" + when: "'Cisco IOS' in platforms" + +- name: Configure infrastructure + hosts: switch01 + become_method: enable + connection: network_cli + gather_facts: no + + roles: + - toallab.infrastructure + - name: Ansible Red Demo Environment hosts: ansible-red become: false