├── Modulefile.tmpl
├── README.md
├── build.sh
├── device.conf
├── gems
└── acirb-0.7.gem
├── lib
└── puppet
│ ├── provider
│ └── apic
│ │ └── apic.rb
│ ├── type
│ └── apic.rb
│ └── util
│ └── network_device
│ ├── apic.rb
│ └── apic
│ └── device.rb
├── manifests
├── README.txt
└── site.pp
├── pkg
├── cisco-apic-0.7.156.tar.gz
└── cisco-apic-0.7.156
│ ├── Modulefile
│ ├── Modulefile.tmpl
│ ├── README.md
│ ├── build.sh
│ ├── checksums.json
│ ├── device.conf
│ ├── env.sh
│ ├── gems
│ └── acirb-0.7.gem
│ ├── lib
│ └── puppet
│ │ ├── provider
│ │ └── apic
│ │ │ └── apic.rb
│ │ ├── type
│ │ └── apic.rb
│ │ └── util
│ │ └── network_device
│ │ ├── apic.rb
│ │ └── apic
│ │ └── device.rb
│ ├── manifests
│ ├── README.txt
│ └── site.pp
│ ├── metadata.json
│ ├── package.sh
│ ├── puppetdevice.sh
│ ├── puppetmaster.sh
│ └── tests
│ └── init.pp
├── puppetdevice.sh
├── puppetmaster.sh
└── tests
└── init.pp
/Modulefile.tmpl:
--------------------------------------------------------------------------------
1 | name 'cisco-apic'
2 | version '$VERSION'
3 | source 'Cisco Advanced Services'
4 | author 'palesiak@cisco.com'
5 | license 'Apache License, Version 2.0'
6 | summary 'Provider and types for managing Cisco APIC'
7 | description 'Contains the providers and types for managing the Cisco APIC via the Northbound REST API'
8 | project_page 'www.cisco.com'
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cisco APIC Puppet Module
2 | ## Overview
3 | This module enables configuration of the Cisco ACI fabric via the Puppet configuration management system. By converting puppet manifests into APIC northbound REST API calls, this module can configure any features available via the APIC GUI, to achieve the desired end state.
4 | ## Dependencies
5 | This module depends on the acirb ruby GEM, which is included in the gems directory, but is also available from http://github.com/datacenter/acirb. You will first need to install the ACIrb gem, using:
6 | gem install acirb-version.gem
7 |
8 | Note that this package supports Ruby 1.9. Please ensure that whatever version of ruby puppet is utilizing is the same version of gem used to install the ACIrb gem
9 | ## Deployment
10 | Given that APIC is a network device, this module is implemented using the **puppet device** framework, meaning that a puppet agent is not run directly on the controller, but rather a intermediary device will proxy between a puppet master and the target device.
11 |
12 | You'll need the following components in order to use this module:
13 | - Puppet master
14 | - Proxy device (this can run on the master if needed)
15 | - Configuration manifest
16 | - Device configuration
17 | - ACI controller
18 |
19 | A sample manifest is provided in the manifests folder, and a sample device.conf is provided in the root folder. Once you have updated these to match your environment, you can use **puppetmaster.sh** to start up a puppetmaster, and then invoke **puppetdevice.sh** to run the module and apply the configuration. Note that both of these have heavy debug enabled by default, so you may want to remove the "--debug" and "--trace" flags, unless you're debugging or just interested in the output.
20 |
21 | ## Manifests
22 | Manifests are simple to write, as you can take an existing deployed configuration from an APIC, save it as XML or JSON and just substitute the payload into the config parameter.
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | version=$(ruby -e 'require "acirb"; puts ACIrb::VERSION')
3 | echo "Using ACIrb Gem version $version"
4 |
5 | # increment build number
6 | set +e
7 | test -e .build
8 | if [ $? -eq 1 ] ; then
9 | echo 0 > .build
10 | fi
11 | build=$(cat .build)
12 | build=$((build+1))
13 | echo $build > .build
14 |
15 | # insert new version into Modulefile
16 | sed -e "s/\$VERSION/$version.$build/g" < Modulefile.tmpl > Modulefile
17 |
18 | FAILED=0
19 | puppet module build --verbose || FAILED=1
20 | if [ $FAILED -ne 0 ] ; then
21 | echo "Puppet module build did not complete successfully. Printing trace"
22 | puppet module build --trace
23 | exit 1
24 | fi
25 | puppet module uninstall cisco-apic || true
26 | puppet module install -f pkg/cisco-apic-$version.$build.tar.gz
27 |
28 |
--------------------------------------------------------------------------------
/device.conf:
--------------------------------------------------------------------------------
1 | [apic.cisco.com]
2 | type apic
3 | url https://admin:password@apic/
4 |
5 |
--------------------------------------------------------------------------------
/gems/acirb-0.7.gem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datacenter/puppet-aci/f68959f4b3cd39ce13d0d3052d5a229767a48a24/gems/acirb-0.7.gem
--------------------------------------------------------------------------------
/lib/puppet/provider/apic/apic.rb:
--------------------------------------------------------------------------------
1 | require 'acirb'
2 | require 'puppet'
3 | require 'rexml/document'
4 | require 'rubygems'
5 |
6 | Puppet::Type.type(:apic).provide :apic do
7 | desc 'Manage APIC'
8 |
9 | def loadconfig(config_type, config)
10 | if config_type == 'xml'
11 | mo = ACIrb::Loader.load_xml_str(config)
12 | elsif config_type == 'json'
13 | mo = ACIrb::Loader.load_json_str(config)
14 | elsif config_type == 'hash'
15 | mo = ACIrb::Loader.load_hash(config)
16 | end
17 | mo
18 | end
19 |
20 | def restclient(url, user, password)
21 | begin
22 | device = Puppet::Util::NetworkDevice.current
23 | rescue
24 | device = nil
25 | end
26 |
27 | if device
28 | info('Using NetworkDevice rest')
29 | return device.rest
30 | else
31 | info('Establishing new REST session')
32 | return ACIrb::RestClient.new(url: url, user: user, password: password)
33 | end
34 | end
35 |
36 | def create
37 | info('Invoking %s' % __method__.to_s)
38 |
39 | url ||= @resource[:address] || @property_hash[:address]
40 | user ||= @resource[:user] || @property_hash[:user]
41 | password ||= @resource[:password] || @property_hash[:password]
42 |
43 | rest = restclient(url, user, password)
44 |
45 | mo = loadconfig(@resource[:config_type], @resource[:config])
46 |
47 | mocreate = mo.create(rest)
48 | end
49 |
50 | def destroy
51 | info('Invoking %s' % __method__.to_s)
52 |
53 | url ||= @resource[:address] || @property_hash[:address]
54 | user ||= @resource[:user] || @property_hash[:user]
55 | password ||= @resource[:password] || @property_hash[:password]
56 |
57 | rest = restclient(url, user, password)
58 |
59 | mo = loadconfig(@resource[:config_type], @resource[:config])
60 |
61 | mo.destroy(rest)
62 | end
63 |
64 | def exists?
65 | info('Invoking %s' % __method__.to_s)
66 | url ||= @resource[:address] || @property_hash[:address]
67 | user ||= @resource[:user] || @property_hash[:user]
68 | password ||= @resource[:password] || @property_hash[:password]
69 |
70 | rest = restclient(url, user, password)
71 |
72 | config_type ||= @resource[:config_type] || @property_hash[:config_type]
73 | config ||= @resource[:config] || @property_hash[:config]
74 |
75 | mo = loadconfig(config_type, config)
76 |
77 | moexists = mo.exists(rest, true)
78 |
79 | @property_hash[:address] = url
80 |
81 | moexists
82 | end
83 |
84 | def self.instances
85 | raise Puppet::DevError, "Provider #{self.name} has not defined the 'instances' class method"
86 |
87 | # Need more details on the specific use cases for this invocation
88 | info('Invoking %s' % __method__.to_s)
89 |
90 | syntaxString = 'The following environment variables must be defined
91 | APIC_DN: Distinguished name of the tree to query
92 | APIC_ROOT: Parent to tree to query
93 | APIC_ADDRESS: IP address of the controller
94 | APIC_USERNAME: Username for the APIC
95 | APIC_PASSWORD: Password for the APIC
96 |
97 | These should be assigned using export or pre-pended to the puppet command, e.g.,
98 |
99 | export APIC_ADDRESS=10.0.0.1
100 | export APIC_USERNAME=admin
101 | export APIC_PASSWORD=cisco
102 | export APIC_DN=uni/tn-Cisco
103 | export APIC_ROOT=uni
104 | puppet resource apic
105 | '
106 |
107 | required = %w(APIC_DN APIC_ROOT APIC_ADDRESS APIC_USERNAME APIC_PASSWORD)
108 | required.each do |key|
109 | fail(syntaxString) unless ENV.include?(key)
110 | end
111 |
112 | dn = ENV['APIC_DN']
113 | root = ENV['APIC_ROOT']
114 | url = ENV['APIC_ADDRESS']
115 | user = ENV['APIC_USERNAME']
116 | password = ENV['APIC_PASSWORD']
117 |
118 | rest = ACIrb::RestClient.new(url: url, user: user, password: password)
119 |
120 | debug('Looking up Dn ' + dn)
121 | mo = rest.lookupByDn(dn: dn, subtree: 'full')
122 | if mo
123 | debug(mo.to_s)
124 |
125 | Array(new(name: 'APIC',
126 | address: url,
127 | root: root,
128 | user: user,
129 | password: password,
130 | config_type: 'xml',
131 | config: mo.to_xml.to_s,
132 | ensure: :present
133 | ))
134 | else
135 | Array(new(name: 'APIC',
136 | address: url,
137 | root: root,
138 | user: user,
139 | password: password,
140 | config_type: 'xml',
141 | config: '',
142 | ensure: :present
143 | ))
144 | end
145 | end
146 | end
147 |
--------------------------------------------------------------------------------
/lib/puppet/type/apic.rb:
--------------------------------------------------------------------------------
1 | Puppet::Type.newtype(:apic) do
2 | @doc = 'An APIC that will be accessed'
3 |
4 | ensurable
5 | apply_to_device
6 |
7 | newparam(:apicname, namevar: true) do
8 | desc 'Name of the APIC'
9 | end
10 |
11 | newparam(:address) do
12 | desc 'URL for APIC'
13 | end
14 |
15 | newparam(:config_type) do
16 | desc 'Configuration type for config (xml, json or hash)'
17 | end
18 |
19 | newparam(:config) do
20 | desc 'Configuration defined as JSON, XML or Ruby Hash, as' \
21 | ' specified by config_type'
22 | end
23 |
24 | newparam(:user) do
25 | defaultto('admin')
26 | desc 'APIC Username'
27 | end
28 |
29 | newparam(:password) do
30 | desc 'APIC Password'
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/lib/puppet/util/network_device/apic.rb:
--------------------------------------------------------------------------------
1 | require 'puppet/util/network_device'
2 |
3 | module Puppet::Util::NetworkDevice::Apic
4 | end
5 |
--------------------------------------------------------------------------------
/lib/puppet/util/network_device/apic/device.rb:
--------------------------------------------------------------------------------
1 | require 'ACIrb'
2 | require 'puppet'
3 | require 'puppet/util'
4 | require 'puppet/util/network_device/apic'
5 | require 'uri'
6 |
7 | class Puppet::Util::NetworkDevice::Apic::Device
8 | attr_accessor :url, :rest
9 |
10 | def initialize(url, _options = {})
11 | @url = URI.parse(url)
12 | apicuri = '%s://%s' % [@url.scheme, @url.host]
13 | user = @url.user
14 | password = @url.password
15 | @rest = ACIrb::RestClient.new(url: apicuri, user: user,
16 | password: password)
17 | end
18 |
19 | def facts
20 | {}
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/manifests/README.txt:
--------------------------------------------------------------------------------
1 | Place the sample puppet manifest site.pp here into ~/.puppet/manifests
2 |
3 | Change the nodename at the top to match the name of your controller, and then adjust the parameters to reflect your environment
4 |
--------------------------------------------------------------------------------
/manifests/site.pp:
--------------------------------------------------------------------------------
1 | node 'apic.cisco.com' {
2 | apic { 'SomeAPICConfig' :
3 | address => 'https://apic',
4 | user => 'admin',
5 | password => 'password',
6 | config_type => 'hash',
7 | config => {
8 | 'polUni' => {
9 | 'children' => [
10 | {
11 | 'fvTenant' => {
12 | 'attributes' => {
13 | 'name' => 'test2',
14 | },
15 | 'children' => [
16 | {
17 | 'fvBD' => {
18 | 'attributes' => {
19 | 'name' => 'BD1'
20 | }
21 | },
22 | },
23 | {
24 | 'fvAp' => {
25 | 'attributes' => {
26 | 'name' => 'WebApplication',
27 | },
28 | 'children' => [
29 | {
30 | 'fvAEPg' => {
31 | 'attributes' => {
32 | 'name' => 'WebTier',
33 | }
34 | }
35 | }
36 | ]
37 | }
38 | }
39 | ]
40 | }
41 | }
42 | ]
43 | }
44 | },
45 | ensure => 'present',
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datacenter/puppet-aci/f68959f4b3cd39ce13d0d3052d5a229767a48a24/pkg/cisco-apic-0.7.156.tar.gz
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/Modulefile:
--------------------------------------------------------------------------------
1 | name 'cisco-apic'
2 | version '0.7.156'
3 | source 'Cisco Advanced Services'
4 | author 'palesiak@cisco.com'
5 | license 'Apache License, Version 2.0'
6 | summary 'Provider and types for managing Cisco APIC'
7 | description 'Contains the providers and types for managing the Cisco APIC via the Northbound REST API'
8 | project_page 'www.cisco.com'
9 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/Modulefile.tmpl:
--------------------------------------------------------------------------------
1 | name 'cisco-apic'
2 | version '$VERSION'
3 | source 'Cisco Advanced Services'
4 | author 'palesiak@cisco.com'
5 | license 'Apache License, Version 2.0'
6 | summary 'Provider and types for managing Cisco APIC'
7 | description 'Contains the providers and types for managing the Cisco APIC via the Northbound REST API'
8 | project_page 'www.cisco.com'
9 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/README.md:
--------------------------------------------------------------------------------
1 | # Cisco APIC Puppet Module
2 | ## Overview
3 | This module enables configuration of the Cisco ACI fabric via the Puppet configuration management system. By converting puppet manifests into APIC northbound REST API calls, this module can configure any features available via the APIC GUI, to achieve the desired end state.
4 | ## Dependencies
5 | This module depends on the acirb ruby GEM, which is included in the gems directory, but is also available from http://github.com/datacenter/acirb. You will first need to install the ACIrb gem, using:
6 | gem install acirb-version.gem
7 |
8 | Note that this package supports Ruby 1.9. Please ensure that whatever version of ruby puppet is utilizing is the same version of gem used to install the ACIrb gem
9 | ## Deployment
10 | Given that APIC is a network device, this module is implemented using the **puppet device** framework, meaning that a puppet agent is not run directly on the controller, but rather a intermediary device will proxy between a puppet master and the target device.
11 |
12 | You'll need the following components in order to use this module:
13 | - Puppet master
14 | - Proxy device (this can run on the master if needed)
15 | - Configuration manifest
16 | - Device configuration
17 | - ACI controller
18 |
19 | A sample manifest is provided in the manifests folder, and a sample device.conf is provided in the root folder. Once you have updated these to match your environment, you can use **puppetmaster.sh** to start up a puppetmaster, and then invoke **puppetdevice.sh** to run the module and apply the configuration. Note that both of these have heavy debug enabled by default, so you may want to remove the "--debug" and "--trace" flags, unless you're debugging or just interested in the output.
20 |
21 | ## Manifests
22 | Manifests are simple to write, as you can take an existing deployed configuration from an APIC, save it as XML or JSON and just substitute the payload into the config parameter.
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | version=$(ruby -e 'require "acirb"; puts ACIrb::VERSION')
3 | echo "Using ACIrb Gem version $version"
4 |
5 | # increment build number
6 | set +e
7 | test -e .build
8 | if [ $? -eq 1 ] ; then
9 | echo 0 > .build
10 | fi
11 | build=$(cat .build)
12 | build=$((build+1))
13 | echo $build > .build
14 |
15 | # insert new version into Modulefile
16 | sed -e "s/\$VERSION/$version.$build/g" < Modulefile.tmpl > Modulefile
17 |
18 | FAILED=0
19 | puppet module build --verbose || FAILED=1
20 | if [ $FAILED -ne 0 ] ; then
21 | echo "Puppet module build did not complete successfully. Printing trace"
22 | puppet module build --trace
23 | exit 1
24 | fi
25 | puppet module uninstall cisco-apic || true
26 | puppet module install -f pkg/cisco-apic-$version.$build.tar.gz
27 |
28 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/checksums.json:
--------------------------------------------------------------------------------
1 | {
2 | "Modulefile": "bebdbe5e34aef22d330ff6aeaec24650",
3 | "Modulefile.tmpl": "b6d4bfe0f9bac70df82fd27ca444b9b4",
4 | "README.md": "57ddbb9c78ca8b2adf400b502e180d40",
5 | "build.sh": "5c5078a74f939f1fa1692a0be869776c",
6 | "device.conf": "f5565e717fc4205dd6ec0d60a3d3d33b",
7 | "env.sh": "9e94c1f6ca68b3f226f77e01bfa1b4b3",
8 | "gems/acirb-0.7.gem": "fa953970497f53d6eedfa79918351d8d",
9 | "lib/puppet/provider/apic/apic.rb": "13e6a6700c8dc9eb609e8c7b68d7dab9",
10 | "lib/puppet/type/apic.rb": "685979921c414447077b7ad96e44961d",
11 | "lib/puppet/util/network_device/apic/device.rb": "9b9e1379c04c213bbfa2153ae1d3e396",
12 | "lib/puppet/util/network_device/apic.rb": "131e292f2e15a55a9b15ee5e95023fef",
13 | "manifests/README.txt": "f12dd301218d2bacc2bf2d306986e167",
14 | "manifests/site.pp": "46fd751384db3feff0189a5d4a58b948",
15 | "metadata.json": "7f481a604434821302464039fac20d45",
16 | "package.sh": "309d917ddaafa84c728b658403fb407f",
17 | "puppetdevice.sh": "98a7a54fa871df9868b32d99e785ced0",
18 | "puppetmaster.sh": "18be02554ea8426d522f12e52e98b9c1",
19 | "tests/init.pp": "68b329da9893e34099c7d8ad5cb9c940"
20 | }
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/device.conf:
--------------------------------------------------------------------------------
1 | [apic.cisco.com]
2 | type apic
3 | url https://admin:password@apic/
4 |
5 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/env.sh:
--------------------------------------------------------------------------------
1 | export APIC_ADDRESS=https://apic
2 | export APIC_USERNAME=admin
3 | export APIC_PASSWORD=password
4 | export APIC_DN=uni/tn-common
5 | export APIC_ROOT=uni
6 |
7 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/gems/acirb-0.7.gem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datacenter/puppet-aci/f68959f4b3cd39ce13d0d3052d5a229767a48a24/pkg/cisco-apic-0.7.156/gems/acirb-0.7.gem
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/lib/puppet/provider/apic/apic.rb:
--------------------------------------------------------------------------------
1 | require 'acirb'
2 | require 'puppet'
3 | require 'rexml/document'
4 | require 'rubygems'
5 |
6 | Puppet::Type.type(:apic).provide :apic do
7 | desc 'Manage APIC'
8 |
9 | def loadconfig(config_type, config)
10 | if config_type == 'xml'
11 | mo = ACIrb::Loader.load_xml_str(config)
12 | elsif config_type == 'json'
13 | mo = ACIrb::Loader.load_json_str(config)
14 | elsif config_type == 'hash'
15 | mo = ACIrb::Loader.load_hash(config)
16 | end
17 | mo
18 | end
19 |
20 | def restclient(url, user, password)
21 | begin
22 | device = Puppet::Util::NetworkDevice.current
23 | rescue
24 | device = nil
25 | end
26 |
27 | if device
28 | info('Using NetworkDevice rest')
29 | return device.rest
30 | else
31 | info('Establishing new REST session')
32 | return ACIrb::RestClient.new(url: url, user: user, password: password)
33 | end
34 | end
35 |
36 | def create
37 | info('Invoking %s' % __method__.to_s)
38 |
39 | url ||= @resource[:address] || @property_hash[:address]
40 | user ||= @resource[:user] || @property_hash[:user]
41 | password ||= @resource[:password] || @property_hash[:password]
42 |
43 | rest = restclient(url, user, password)
44 |
45 | mo = loadconfig(@resource[:config_type], @resource[:config])
46 |
47 | mocreate = mo.create(rest)
48 | end
49 |
50 | def destroy
51 | info('Invoking %s' % __method__.to_s)
52 |
53 | url ||= @resource[:address] || @property_hash[:address]
54 | user ||= @resource[:user] || @property_hash[:user]
55 | password ||= @resource[:password] || @property_hash[:password]
56 |
57 | rest = restclient(url, user, password)
58 |
59 | mo = loadconfig(@resource[:config_type], @resource[:config])
60 |
61 | mo.destroy(rest)
62 | end
63 |
64 | def exists?
65 | info('Invoking %s' % __method__.to_s)
66 | url ||= @resource[:address] || @property_hash[:address]
67 | user ||= @resource[:user] || @property_hash[:user]
68 | password ||= @resource[:password] || @property_hash[:password]
69 |
70 | rest = restclient(url, user, password)
71 |
72 | config_type ||= @resource[:config_type] || @property_hash[:config_type]
73 | config ||= @resource[:config] || @property_hash[:config]
74 |
75 | mo = loadconfig(config_type, config)
76 |
77 | moexists = mo.exists(rest, true)
78 |
79 | @property_hash[:address] = url
80 |
81 | moexists
82 | end
83 |
84 | def self.instances
85 | raise Puppet::DevError, "Provider #{self.name} has not defined the 'instances' class method"
86 |
87 | # Need more details on the specific use cases for this invocation
88 | info('Invoking %s' % __method__.to_s)
89 |
90 | syntaxString = 'The following environment variables must be defined
91 | APIC_DN: Distinguished name of the tree to query
92 | APIC_ROOT: Parent to tree to query
93 | APIC_ADDRESS: IP address of the controller
94 | APIC_USERNAME: Username for the APIC
95 | APIC_PASSWORD: Password for the APIC
96 |
97 | These should be assigned using export or pre-pended to the puppet command, e.g.,
98 |
99 | export APIC_ADDRESS=10.0.0.1
100 | export APIC_USERNAME=admin
101 | export APIC_PASSWORD=cisco
102 | export APIC_DN=uni/tn-Cisco
103 | export APIC_ROOT=uni
104 | puppet resource apic
105 | '
106 |
107 | required = %w(APIC_DN APIC_ROOT APIC_ADDRESS APIC_USERNAME APIC_PASSWORD)
108 | required.each do |key|
109 | fail(syntaxString) unless ENV.include?(key)
110 | end
111 |
112 | dn = ENV['APIC_DN']
113 | root = ENV['APIC_ROOT']
114 | url = ENV['APIC_ADDRESS']
115 | user = ENV['APIC_USERNAME']
116 | password = ENV['APIC_PASSWORD']
117 |
118 | rest = ACIrb::RestClient.new(url: url, user: user, password: password)
119 |
120 | debug('Looking up Dn ' + dn)
121 | mo = rest.lookupByDn(dn: dn, subtree: 'full')
122 | if mo
123 | debug(mo.to_s)
124 |
125 | Array(new(name: 'APIC',
126 | address: url,
127 | root: root,
128 | user: user,
129 | password: password,
130 | config_type: 'xml',
131 | config: mo.to_xml.to_s,
132 | ensure: :present
133 | ))
134 | else
135 | Array(new(name: 'APIC',
136 | address: url,
137 | root: root,
138 | user: user,
139 | password: password,
140 | config_type: 'xml',
141 | config: '',
142 | ensure: :present
143 | ))
144 | end
145 | end
146 | end
147 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/lib/puppet/type/apic.rb:
--------------------------------------------------------------------------------
1 | Puppet::Type.newtype(:apic) do
2 | @doc = 'An APIC that will be accessed'
3 |
4 | ensurable
5 | apply_to_device
6 |
7 | newparam(:apicname, namevar: true) do
8 | desc 'Name of the APIC'
9 | end
10 |
11 | newparam(:address) do
12 | desc 'URL for APIC'
13 | end
14 |
15 | newparam(:config_type) do
16 | desc 'Configuration type for config (xml, json or hash)'
17 | end
18 |
19 | newparam(:config) do
20 | desc 'Configuration defined as JSON, XML or Ruby Hash, as' \
21 | ' specified by config_type'
22 | end
23 |
24 | newparam(:user) do
25 | defaultto('admin')
26 | desc 'APIC Username'
27 | end
28 |
29 | newparam(:password) do
30 | desc 'APIC Password'
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/lib/puppet/util/network_device/apic.rb:
--------------------------------------------------------------------------------
1 | require 'puppet/util/network_device'
2 |
3 | module Puppet::Util::NetworkDevice::Apic
4 | end
5 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/lib/puppet/util/network_device/apic/device.rb:
--------------------------------------------------------------------------------
1 | require 'ACIrb'
2 | require 'puppet'
3 | require 'puppet/util'
4 | require 'puppet/util/network_device/apic'
5 | require 'uri'
6 |
7 | class Puppet::Util::NetworkDevice::Apic::Device
8 | attr_accessor :url, :rest
9 |
10 | def initialize(url, _options = {})
11 | @url = URI.parse(url)
12 | apicuri = '%s://%s' % [@url.scheme, @url.host]
13 | user = @url.user
14 | password = @url.password
15 | @rest = ACIrb::RestClient.new(url: apicuri, user: user,
16 | password: password)
17 | end
18 |
19 | def facts
20 | {}
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/manifests/README.txt:
--------------------------------------------------------------------------------
1 | Place the sample puppet manifest site.pp here into ~/.puppet/manifests
2 |
3 | Change the nodename at the top to match the name of your controller, and then adjust the parameters to reflect your environment
4 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/manifests/site.pp:
--------------------------------------------------------------------------------
1 | node 'apic.cisco.com' {
2 | apic { 'SomeAPICConfig' :
3 | address => 'https://apic',
4 | user => 'admin',
5 | password => 'password',
6 | config_type => 'hash',
7 | config => {
8 | 'polUni' => {
9 | 'children' => [
10 | {
11 | 'fvTenant' => {
12 | 'attributes' => {
13 | 'name' => 'test2',
14 | },
15 | 'children' => [
16 | {
17 | 'fvBD' => {
18 | 'attributes' => {
19 | 'name' => 'BD1'
20 | }
21 | },
22 | },
23 | {
24 | 'fvAp' => {
25 | 'attributes' => {
26 | 'name' => 'WebApplication',
27 | },
28 | 'children' => [
29 | {
30 | 'fvAEPg' => {
31 | 'attributes' => {
32 | 'name' => 'WebTier',
33 | }
34 | }
35 | }
36 | ]
37 | }
38 | }
39 | ]
40 | }
41 | }
42 | ]
43 | }
44 | },
45 | ensure => 'present',
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cisco-apic",
3 | "version": "0.7.156",
4 | "author": "palesiak@cisco.com",
5 | "summary": "Provider and types for managing Cisco APIC",
6 | "license": "Apache License, Version 2.0",
7 | "source": "Cisco Advanced Services",
8 | "project_page": "www.cisco.com",
9 | "issues_url": null,
10 | "description": "Contains the providers and types for managing the Cisco APIC via the Northbound REST API",
11 | "dependencies": [
12 |
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 | #
3 | # This script cleans up directories that shouldn't be packaged and then zips up everything else
4 | # this is for Paul's use
5 | #
6 | basename=$(pwd | sed -e 's/^.*\///g')
7 | echo 'Cleaning up'
8 | rm -fv ../${basename}.zip
9 | echo 'Deleting all but the latest two files in pkg directory'
10 | cd pkg
11 | b=0; for a in $(ls -1t) ; do if [ $b -gt 1 ]; then rm -rv $a; fi; b=$((b+1)); done
12 | cd ..
13 | cd ..
14 | echo 'Zipping'
15 | zip -r ${basename} ${basename}/*
16 | cd ${basename}
17 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/puppetdevice.sh:
--------------------------------------------------------------------------------
1 | puppet device --debug --trace --server localhost --deviceconfig ~/.puppet/device.conf
2 |
3 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/puppetmaster.sh:
--------------------------------------------------------------------------------
1 | puppet master --no-daemonize
2 |
--------------------------------------------------------------------------------
/pkg/cisco-apic-0.7.156/tests/init.pp:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/puppetdevice.sh:
--------------------------------------------------------------------------------
1 | puppet device --debug --trace --server localhost --deviceconfig ~/.puppet/device.conf
2 |
3 |
--------------------------------------------------------------------------------
/puppetmaster.sh:
--------------------------------------------------------------------------------
1 | puppet master --no-daemonize
2 |
--------------------------------------------------------------------------------
/tests/init.pp:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------