Commit 9001bf36 authored by Dónal Cunningham's avatar Dónal Cunningham
Browse files

DC - Initial commit

parents
---
- name: Set up Apache
hosts: webservers
vars:
http_port: 80
- name: Set up Apache
hosts: webservers
vars_files:
- external_vars.yml
$ tree
.
├── ansible.cfg
├── hosts
└── group_vars
│   └── all.yaml
│   └── webservers.yaml
└── host_vars
│   └── web1.yaml
│   └── web2.yaml
│   └── db1.yaml
│   └── db2.yaml
├── setup_apache_playbook.yaml
└── setup_mysql_playbook.yaml
---
devices:
- routers
- switches
- firewalls
vlan:
name: DMZ
id: 10
subnet: 10.1.20.0/24
acl: DMZ_from_internet_v4
vlans:
- Management:
vlan_id: 99
description: ‘Management OOB’
ipv4_subnets: 193.1.219.0/24
- DNS_AUTH:
vlan_id: 10
description: ‘Authoritative DNS servers’
ipv4_subnets: 193.1.220.0/26
dhcp_servers:
- 193.1.2.1
- 193.1.3.1
[defaults]
deprecation_warnings=False
# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
nocows = 1
# You can only have one 'stdout' callback type enabled at a time. The default
# is 'default'. The 'yaml' or 'debug' stdout callback plugins are easier to read.
#
stdout_callback = default
#stdout_callback = yaml
#stdout_callback = debug
inventory = hosts
---
- name: Change the hostname
hosts: veos
gather_facts: no
become: yes
vars:
ansible_connection: network_cli
ansible_network_os: eos
tasks:
- name: run the hostname command
arista.eos.eos_config:
lines:
- 'hostname rumplestiltskin'
[guinea_pigs]
veos ansible_connection=ssh ansible_host=localhost ansible_port=9022 ansible_user=zork ansible_ssh_pass=swordfish
# Show version with `--step`
You need to update the hosts file : replace the "veos" host
with one to which you can log on with ssh.
Run ``ansible-playbook -i hosts --step show-version.yaml``
and follow the prompts.
[defaults]
deprecation_warnings=False
# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
nocows = 1
# You can only have one 'stdout' callback type enabled at a time. The default
# is 'default'. The 'yaml' or 'debug' stdout callback plugins are easier to read.
#
stdout_callback = default
#stdout_callback = yaml
#stdout_callback = debug
inventory = hosts
[guinea_pigs]
veos ansible_connection=ssh ansible_host=localhost ansible_port=9022 ansible_user=zork ansible_password=swordfish
---
- name: Show version
hosts: veos
gather_facts: "no"
connection: network_cli
tasks:
- name: Gather version
raw: 'show version | include Software'
register: showvers
- name: Print output
debug: var=showvers.stdout_lines[0]
---
- name: Play to install service daemons
hosts: localhost
gather_facts: False
tasks:
- name: Install web servers
debug:
msg: “Installing web servers”
tags: webservers
- name: Install the db servers
debug:
msg: “Installing db servers”
tags: dbservers
# Viewing a vault file
```
$ ansible-vault view secrets_encrypted.yaml
Vault password:
---
ansible_user: zork
ansible_password: swordfish
```
[defaults]
deprecation_warnings=False
# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
nocows = 1
# You can only have one 'stdout' callback type enabled at a time. The default
# is 'default'. The 'yaml' or 'debug' stdout callback plugins are easier to read.
#
stdout_callback = default
#stdout_callback = yaml
#stdout_callback = debug
inventory = hosts,hosts.cfg,hosts.ini,hosts.yml,hosts.yaml
veos ansible_host=localhost ansible_port=9022 ansible_network_os=eos
# veos ansible_connection=ssh ansible_host=localhost ansible_port=9022
veos ansible_connection=ssh ansible_host=localhost ansible_port=9022 ansible_user=zork ansible_ssh_pass=swordfish
$ANSIBLE_VAULT;1.1;AES256
37353032393065373731303737373035366230386435613732346333383964623830636135323232
3132626139303264643037373937336231316531666333620a383330366531343130343262363637
35326532373235623632383537343165373637376435336261313462643639656130313035636662
3264376334333864640a366561303231303666646638666333376634393034366432633936633934
32333630356662363031323234303333336130343036633030336366616262343933303666343736
35316139336638373033633233646138633863633563363231333839303732373666356433656131
353334346133663663303734383863633334
---
ansible_user: zork
ansible_password: swordfish
---
- name: Show version
hosts: veos
gather_facts: "no"
connection: network_cli
vars:
ansible_connection: network_cli
ansible_network_os: eos
tasks:
- name: Include plaintext secrets
include_vars: secrets_plaintext.yaml
- name: Show Ansible username
debug: var=ansible_user
- name: Show Ansible password
debug: var=ansible_password
---
- name: Show version
hosts: veos
gather_facts: "no"
connection: network_cli
tasks:
- name: Include plaintext secrets
include_vars: secrets_plaintext.yaml
# - name: Show Ansible username
# debug: var=ansible_user
#
# - name: Show Ansible password
# debug: var=ansible_password
- name: Gather version from switch
raw: 'show version | include Software'
register: showvers
- name: Print output
debug: var=showvers.stdout_lines[0]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment