Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Ansible roles/sonic-common and more complete implementation #3

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 234 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# config file for ansible -- http://ansible.com/
# ==============================================

# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]

# some basic default values...

inventory = /etc/ansible/hosts
library = library:library/ixia
remote_tmp = $HOME/.ansible/tmp
pattern = *
forks = 5
poll_interval = 15
sudo_user = root
#ask_sudo_pass = True
#ask_pass = True
transport = smart
#remote_port = 22
module_lang = C

# plays will gather facts by default, which contain information about
# the remote system.
#
# smart - gather by default, but don't regather if already gathered
# implicit - gather by default, turn off with gather_facts: False
# explicit - do not gather by default, must say gather_facts: True
gathering = smart

# additional paths to search for roles in, colon separated
#roles_path = /etc/ansible/roles

# uncomment this to disable SSH key host checking
#host_key_checking = False
host_key_checking = False
UserKnownHostsFile=/dev/null

# change this for alternative sudo implementations
sudo_exe = sudo

# what flags to pass to sudo
#sudo_flags = -H

# SSH timeout
timeout = 10

# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
#remote_user = root

# logging is off by default unless this path is defined
# if so defined, consider logrotate
#log_path = /var/log/ansible.log

# default module name for /usr/bin/ansible
#module_name = command

# use this shell for commands executed under sudo
# you may need to change this to bin/bash in rare instances
# if sudo is constrained
#executable = /bin/sh

# if inventory variables overlap, does the higher precedence one win
# or are hash values merged together? The default is 'replace' but
# this can also be set to 'merge'.
#hash_behaviour = replace

# list any Jinja2 extensions to enable here:
#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n

# if set, always use this private key file for authentication, same as
# if passing --private-key to ansible or ansible-playbook
#private_key_file = /path/to/file

# format of string {{ ansible_managed }} available within Jinja2
# templates indicates to users editing templates files will be replaced.
# replacing {file}, {host} and {uid} and strftime codes with proper values.
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}

# by default, ansible-playbook will display "Skipping [host]" if it determines a task
# should not be run on a host. Set this to "False" if you don't want to see these "Skipping"
# messages. NOTE: the task header will still be shown regardless of whether or not the
# task is skipped.
#display_skipped_hosts = True

# by default (as of 1.3), Ansible will raise errors when attempting to dereference
# Jinja2 variables that are not set in templates or action lines. Uncomment this line
# to revert the behavior to pre-1.3.
#error_on_undefined_vars = False

# by default (as of 1.6), Ansible may display warnings based on the configuration of the
# system running ansible itself. This may include warnings about 3rd party packages or
# other conditions that should be resolved if possible.
# to disable these warnings, set the following value to False:
#system_warnings = True

# by default (as of 1.4), Ansible may display deprecation warnings for language
# features that should no longer be used and will be removed in future versions.
# to disable these warnings, set the following value to False:
#deprecation_warnings = True

# (as of 1.8), Ansible can optionally warn when usage of the shell and
# command module appear to be simplified by using a default Ansible module
# instead. These warnings can be silenced by adjusting the following
# setting or adding warn=yes or warn=no to the end of the command line
# parameter string. This will for example suggest using the git module
# instead of shelling out to the git command.
# command_warnings = False


# set plugin path directories here, separate with colons
action_plugins = plugins/action
# callback_plugins = /usr/share/ansible_plugins/callback_plugins
connection_plugins = plugins/connection
# lookup_plugins = /usr/share/ansible_plugins/lookup_plugins
# vars_plugins = /usr/share/ansible_plugins/vars_plugins
# filter_plugins = /usr/share/ansible_plugins/filter_plugins
callback_whitelist = profile_tasks

# by default callbacks are not loaded for /bin/ansible, enable this if you
# want, for example, a notification or logging callback to also apply to
# /bin/ansible runs
#bin_ansible_callbacks = 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

# don't like colors either?
# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1
#nocolor = 1

# the CA certificate path used for validating SSL certs. This path
# should exist on the controlling node, not the target nodes
# common locations:
# RHEL/CentOS: /etc/pki/tls/certs/ca-bundle.crt
# Fedora : /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
# Ubuntu : /usr/share/ca-certificates/cacert.org/cacert.org.crt
#ca_file_path =

# the http user-agent string to use when fetching urls. Some web server
# operators block the default urllib user agent as it is frequently used
# by malicious attacks/scripts, so we set it to something unique to
# avoid issues.
#http_user_agent = ansible-agent

# if set to a persistent type (not 'memory', for example 'redis') fact values
# from previous runs in Ansible will be stored. This may be useful when
# wanting to use, for example, IP information from one group of servers
# without having to talk to them in the same playbook run to get their
# current IP information.
fact_caching = memory


# retry files
#retry_files_enabled = False
#retry_files_save_path = ~/.ansible-retry

[privilege_escalation]
#become=True
become_method='sudo'
#become_user='root'
#become_ask_pass=False

[paramiko_connection]

# uncomment this line to cause the paramiko connection plugin to not record new host
# keys encountered. Increases performance on new host additions. Setting works independently of the
# host key checking setting above.
#record_host_keys=False

# by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this
# line to disable this behaviour.
#pty=False

[ssh_connection]

# ssh arguments to use
# Leaving off ControlPersist will result in poor performance, so use
# paramiko on older platforms rather than removing it
ssh_args = -o ControlMaster=auto -o ControlPersist=120s -o UserKnownHostsFile=/dev/null


# The path to use for the ControlPath sockets. This defaults to
# "%(directory)s/ansible-ssh-%%h-%%p-%%r", however on some systems with
# very long hostnames or very long path names (caused by long user names or
# deeply nested home directories) this can exceed the character limit on
# file socket names (108 characters for most platforms). In that case, you
# may wish to shorten the string below.
#
# Example:
# control_path = %(directory)s/%%h-%%r
#control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r

# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
# By default, this option is disabled to preserve compatibility with
# sudoers configurations that have requiretty (the default on many distros).
#
pipelining = True

# if True, make ansible use scp if the connection type is ssh
# (default is sftp)
#scp_if_ssh = True

[accelerate]
accelerate_port = 5099
accelerate_timeout = 30
accelerate_connect_timeout = 5.0

# The daemon timeout is measured in minutes. This time is measured
# from the last activity to the accelerate daemon.
accelerate_daemon_timeout = 30

# If set to yes, accelerate_multi_key will allow multiple
# private keys to be uploaded to it, though each user must
# have access to the system via SSH to add a new key. The default
# is "no".
#accelerate_multi_key = yes

[selinux]
# file systems that require special treatment when dealing with security context
# the default behaviour that copies the existing context or uses the user default
# needs to be changed to use the file system dependant context.
#special_context_filesystems=nfs,vboxsf,fuse
11 changes: 11 additions & 0 deletions ansible/deploy_sonic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# This Playbook would deploy to all the devices.

- hosts: sonic
gather_facts: no
vars_files:
- vars/docker_registry.yml
roles:
- role: sonic-common
- { role: sonicv1 , when: "sonic_version == 'v1'" }
- { role: sonicv2 , when: "sonic_version == 'v2'" }
49 changes: 49 additions & 0 deletions ansible/group_vars/sonic/vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
ansible_ssh_user: acsadmin
ansible_ssh_pass: password
ansible_become_pass: password
acsadmin_password: password
acsadmin_initial_password: 123456

sonic_version: "v2"

broadcom_hwskus: [ 'ACS-S6000', 'Force10-S6000' ]

mellanox_hwskus: [ 'ACS-MSN2700' ]

sensor_hwskus: [ "ACS-S6000", "ACS-MSN2700", "Force10-S6000" ]

## Note:
## Docker volumes should be list instead of dict. However, if we want to keep code DRY, we
## need to merge dictionaries, and convert them to list
## Ref:
## 1. http://stackoverflow.com/questions/9254178/is-there-yaml-syntax-for-sharing-part-of-a-list-or-map
## 2. https://groups.google.com/forum/#!msg/ansible-project/M-FNUK9Wz98/gH63Ka4hDAAJ

syncd_docker_volumes_dict:
"/host/machine.conf:/etc/machine.conf":

syncd_docker_volumes: "{{ syncd_docker_volumes_dict.keys() }}"

orchagent_docker_volumes_dict:
"/etc/ssw/:/etc/ssw/:ro":
"/etc/network/interfaces:/etc/network/interfaces:ro":
"/etc/network/interfaces.d/:/etc/network/interfaces.d/:ro":
"/host/machine.conf:/host/machine.conf":

orchagent_docker_volumes: "{{ orchagent_docker_volumes_dict.keys() }}"

apt_repo_ip: "10.0.0.5"

# ntp variables
ntp_servers: ['10.0.0.1', '10.0.0.2']

# syslog variables
syslog_servers: ['10.0.0.5', '10.0.0.6']

# dns variables
dns_servers: ['10.0.0.5', '10.0.0.6']

# snmp variables
snmp_rocommunity: public
snmp_location: testlab

20 changes: 20 additions & 0 deletions ansible/group_vars/sonic_latest/package_versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
linux_image: { name: linux-image-3.16.0-4-amd64 , version: 3.16.7-ckt11-2+acs8u2 }
platform_modules_s6000: { name: platform-modules-s6000 , version: "*" }
opennslv2: { name: opennsl-modules-3.16.0-4-amd64 , version: "6.4.10*" }
version_sx_kernel: "*"
version_mlnxsdk: "*"
version_iproute2_mlnx: "1.mlnx*"
version_docker_engine: 1.11.1-0~jessie
version_sonic_cli: "*"

image_id_database: docker-database:latest
image_id_snmp: docker-snmp:latest
image_id_lldp: docker-lldp:latest
image_id_platform_monitor: docker-platform-monitor:latest

image_id_syncd: docker-syncd:latest
image_id_syncd_mlnx: docker-syncd-mlnx:latest
image_id_syncd_mlnx_rpc: docker-syncd-mlnx-rpc:latest
image_id_orchagent: docker-orchagent:latest
image_id_orchagent_mlnx: docker-orchagent-mlnx:latest
image_id_fpm: docker-fpm:latest
12 changes: 12 additions & 0 deletions ansible/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[sonic_stable]

[sonic_latest]
switch1 ansible_host=10.0.0.100 sonic_version=v2 sonic_hwsku=Force10-S6000
switch2 ansible_host=10.0.0.101 sonic_version=v2 sonic_hwsku=ACS-MSN2700

[sonic:children]
sonic_stable
sonic_latest

[ptf]
ptf-1 ansible_host=10.0.0.200 ansible_ssh_user=root ansible_ssh_pass=password
Loading