Fix code-blocks to use correct syntax highlighting

This commit is contained in:
Toshio Kuratomi 2017-01-07 08:50:10 -08:00
commit 08d6990e67
20 changed files with 244 additions and 223 deletions

View file

@ -48,11 +48,24 @@ author:
'''
EXAMPLES = '''
ansible host -m slurp -a 'src=/tmp/xx'
host | success >> {
"content": "aGVsbG8gQW5zaWJsZSB3b3JsZAo=",
"encoding": "base64"
}
# Find out what the remote machine's mounts are:
- slurp:
src: /proc/mounts
register: mounts
- debug:
msg: "{{ mounts['content'] | b64decode }}"
# From the commandline, find the pid of the remote machine's sshd
# $ ansible host -m slurp -a 'src=/var/run/sshd.pid'
# host | SUCCESS => {
# "changed": false,
# "content": "MjE3OQo=",
# "encoding": "base64",
# "source": "/var/run/sshd.pid"
# }
# $ echo MjE3OQo= | base64 -d
# 2179
'''
import base64

View file

@ -216,112 +216,113 @@ options:
'''
EXAMPLES='''
The following examples are working examples that I have run in the field. I followed follow the structure:
```
|_/inventory/cloud-hosts
| /group_vars/openstack-stage.yml
| /host_vars/controller-01.openstack.host.com
| /host_vars/controller-02.openstack.host.com
|_/playbook/library/nmcli.py
| /playbook-add.yml
| /playbook-del.yml
```
## inventory examples
### groups_vars
```yml
---
#devops_os_define_network
storage_gw: "192.0.2.254"
external_gw: "198.51.100.254"
tenant_gw: "203.0.113.254"
#Team vars
nmcli_team:
- conn_name: tenant
ip4: '{{ tenant_ip }}'
gw4: '{{ tenant_gw }}'
- conn_name: external
ip4: '{{ external_ip }}'
gw4: '{{ external_gw }}'
- conn_name: storage
ip4: '{{ storage_ip }}'
gw4: '{{ storage_gw }}'
nmcli_team_slave:
- conn_name: em1
ifname: em1
master: tenant
- conn_name: em2
ifname: em2
master: tenant
- conn_name: p2p1
ifname: p2p1
master: storage
- conn_name: p2p2
ifname: p2p2
master: external
#bond vars
nmcli_bond:
- conn_name: tenant
ip4: '{{ tenant_ip }}'
gw4: ''
mode: balance-rr
- conn_name: external
ip4: '{{ external_ip }}'
gw4: ''
mode: balance-rr
- conn_name: storage
ip4: '{{ storage_ip }}'
gw4: '{{ storage_gw }}'
mode: balance-rr
nmcli_bond_slave:
- conn_name: em1
ifname: em1
master: tenant
- conn_name: em2
ifname: em2
master: tenant
- conn_name: p2p1
ifname: p2p1
master: storage
- conn_name: p2p2
ifname: p2p2
master: external
#ethernet vars
nmcli_ethernet:
- conn_name: em1
ifname: em1
ip4: '{{ tenant_ip }}'
gw4: '{{ tenant_gw }}'
- conn_name: em2
ifname: em2
ip4: '{{ tenant_ip1 }}'
gw4: '{{ tenant_gw }}'
- conn_name: p2p1
ifname: p2p1
ip4: '{{ storage_ip }}'
gw4: '{{ storage_gw }}'
- conn_name: p2p2
ifname: p2p2
ip4: '{{ external_ip }}'
gw4: '{{ external_gw }}'
```
### host_vars
```yml
---
storage_ip: "192.0.2.91/23"
external_ip: "198.51.100.23/21"
tenant_ip: "203.0.113.77/23"
```
# These examples are using the following inventory:
#
# ## Directory layout:
#
# |_/inventory/cloud-hosts
# | /group_vars/openstack-stage.yml
# | /host_vars/controller-01.openstack.host.com
# | /host_vars/controller-02.openstack.host.com
# |_/playbook/library/nmcli.py
# | /playbook-add.yml
# | /playbook-del.yml
# ```
#
# ## inventory examples
# ### groups_vars
# ```yml
# ---
# #devops_os_define_network
# storage_gw: "192.0.2.254"
# external_gw: "198.51.100.254"
# tenant_gw: "203.0.113.254"
#
# #Team vars
# nmcli_team:
# - conn_name: tenant
# ip4: '{{ tenant_ip }}'
# gw4: '{{ tenant_gw }}'
# - conn_name: external
# ip4: '{{ external_ip }}'
# gw4: '{{ external_gw }}'
# - conn_name: storage
# ip4: '{{ storage_ip }}'
# gw4: '{{ storage_gw }}'
# nmcli_team_slave:
# - conn_name: em1
# ifname: em1
# master: tenant
# - conn_name: em2
# ifname: em2
# master: tenant
# - conn_name: p2p1
# ifname: p2p1
# master: storage
# - conn_name: p2p2
# ifname: p2p2
# master: external
#
# #bond vars
# nmcli_bond:
# - conn_name: tenant
# ip4: '{{ tenant_ip }}'
# gw4: ''
# mode: balance-rr
# - conn_name: external
# ip4: '{{ external_ip }}'
# gw4: ''
# mode: balance-rr
# - conn_name: storage
# ip4: '{{ storage_ip }}'
# gw4: '{{ storage_gw }}'
# mode: balance-rr
# nmcli_bond_slave:
# - conn_name: em1
# ifname: em1
# master: tenant
# - conn_name: em2
# ifname: em2
# master: tenant
# - conn_name: p2p1
# ifname: p2p1
# master: storage
# - conn_name: p2p2
# ifname: p2p2
# master: external
#
# #ethernet vars
# nmcli_ethernet:
# - conn_name: em1
# ifname: em1
# ip4: '{{ tenant_ip }}'
# gw4: '{{ tenant_gw }}'
# - conn_name: em2
# ifname: em2
# ip4: '{{ tenant_ip1 }}'
# gw4: '{{ tenant_gw }}'
# - conn_name: p2p1
# ifname: p2p1
# ip4: '{{ storage_ip }}'
# gw4: '{{ storage_gw }}'
# - conn_name: p2p2
# ifname: p2p2
# ip4: '{{ external_ip }}'
# gw4: '{{ external_gw }}'
# ```
#
# ### host_vars
# ```yml
# ---
# storage_ip: "192.0.2.91/23"
# external_ip: "198.51.100.23/21"
# tenant_ip: "203.0.113.77/23"
# ```
## playbook-add.yml example
```yml
---
- hosts: openstack-stage
remote_user: root
@ -360,42 +361,40 @@ tenant_ip: "203.0.113.77/23"
- '{{ nmcli_team_slave }}'
###### Working with all cloud nodes - Bonding
# - name: try nmcli add bond - conn_name only & ip4 gw4 mode
# nmcli:
# type: bond
# conn_name: '{{ item.conn_name }}'
# ip4: '{{ item.ip4 }}'
# gw4: '{{ item.gw4 }}'
# mode: '{{ item.mode }}'
# state: present
# with_items:
# - '{{ nmcli_bond }}'
#
# - name: try nmcli add bond-slave
# nmcli:
# type: bond-slave
# conn_name: '{{ item.conn_name }}'
# ifname: '{{ item.ifname }}'
# master: '{{ item.master }}'
# state: present
# with_items:
# - '{{ nmcli_bond_slave }}'
- name: try nmcli add bond - conn_name only & ip4 gw4 mode
nmcli:
type: bond
conn_name: '{{ item.conn_name }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
mode: '{{ item.mode }}'
state: present
with_items:
- '{{ nmcli_bond }}'
- name: try nmcli add bond-slave
nmcli:
type: bond-slave
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
master: '{{ item.master }}'
state: present
with_items:
- '{{ nmcli_bond_slave }}'
##### Working with all cloud nodes - Ethernet
# - name: nmcli add Ethernet - conn_name only & ip4 gw4
# nmcli:
# type: ethernet
# conn_name: '{{ item.conn_name }}'
# ip4: '{{ item.ip4 }}'
# gw4: '{{ item.gw4 }}'
# state: present
# with_items:
# - '{{ nmcli_ethernet }}'
```
- name: nmcli add Ethernet - conn_name only & ip4 gw4
nmcli:
type: ethernet
conn_name: '{{ item.conn_name }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
state: present
with_items:
- '{{ nmcli_ethernet }}'
## playbook-del.yml example
```yml
---
- hosts: openstack-stage
remote_user: root
@ -421,7 +420,7 @@ tenant_ip: "203.0.113.77/23"
- conn_name: team-p1p2
- conn_name: team-p2p1
- conn_name: team-p2p2
```
# To add an Ethernet connection with static IP configuration, issue a command as follows
- nmcli:
conn_name: my-eth1
@ -464,7 +463,7 @@ tenant_ip: "203.0.113.77/23"
- nmcli:
ctype: ethernet
name: my-eth1
ifname: *
ifname: '*'
state: present
# To change the property of a setting e.g. MTU, issue a command as follows:
@ -474,20 +473,20 @@ tenant_ip: "203.0.113.77/23"
type: ethernet
state: present
Exit Status's:
- nmcli exits with status 0 if it succeeds, a value greater than 0 is
returned if an error occurs.
- 0 Success - indicates the operation succeeded
- 1 Unknown or unspecified error
- 2 Invalid user input, wrong nmcli invocation
- 3 Timeout expired (see --wait option)
- 4 Connection activation failed
- 5 Connection deactivation failed
- 6 Disconnecting device failed
- 7 Connection deletion failed
- 8 NetworkManager is not running
- 9 nmcli and NetworkManager versions mismatch
- 10 Connection, device, or access point does not exist.
# Exit Status's:
# - nmcli exits with status 0 if it succeeds, a value greater than 0 is
# returned if an error occurs.
# - 0 Success - indicates the operation succeeded
# - 1 Unknown or unspecified error
# - 2 Invalid user input, wrong nmcli invocation
# - 3 Timeout expired (see --wait option)
# - 4 Connection activation failed
# - 5 Connection deactivation failed
# - 6 Disconnecting device failed
# - 7 Connection deletion failed
# - 8 NetworkManager is not running
# - 9 nmcli and NetworkManager versions mismatch
# - 10 Connection, device, or access point does not exist.
'''
# import ansible.module_utils.basic
import os