vagrant-junos_cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +9 -0
- data/README.md +65 -0
- data/Rakefile +2 -0
- data/example/Vagrantfile +23 -0
- data/example/provision.cmd +8 -0
- data/lib/vagrant/junos_cli/config.rb +9 -0
- data/lib/vagrant/junos_cli/plugin.rb +22 -0
- data/lib/vagrant/junos_cli/provisioner.rb +63 -0
- data/lib/vagrant/junos_cli/version.rb +5 -0
- data/lib/vagrant/junos_cli.rb +2 -0
- data/vagrant-junos_cli.gemspec +21 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de8e0cec5ffa6a07787c3ea64d1104fb82319537
|
4
|
+
data.tar.gz: eb47ce35ad3852cd1cb3a216f1c0bb6e5dc66110
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7dedc9f20b2d49a667e57835deb7bbbf8d262950fab053f8e777634c4bdbf1e9909c7b76519f72474f20443a796afff2185539a7866cf3ec2fc519fc2477798a
|
7
|
+
data.tar.gz: 9a92b505bec6ce20b7d8f4c61ea08ef6705e910bc01cdc3bed78a10569fb74a9885cf48d8c4fdadd3118bc2aac99c983dd964dc161b740829f2aa1bbb74c672f
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Vagrant::JunosCli
|
2
|
+
|
3
|
+
## Features
|
4
|
+
|
5
|
+
- Provision Junos OS boxes using CLI commands
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Install using standard Vagrant plugin installation methods.
|
10
|
+
|
11
|
+
```
|
12
|
+
$ vagrant plugin install vagrant-junos_cli
|
13
|
+
```
|
14
|
+
|
15
|
+
## Quick Start
|
16
|
+
|
17
|
+
After installing the plugin you need to obtain a Junos box image.
|
18
|
+
Official boxes are available [here](https://github.com/Juniper/vqfx10k-vagrant).
|
19
|
+
|
20
|
+
```
|
21
|
+
$ vagrant box add juniper/vqfx10k-re
|
22
|
+
```
|
23
|
+
|
24
|
+
Create a Vagrantfile based on [one of the examples](https://github.com/Juniper/vqfx10k-vagrant/blob/master/light-1qfx/Vagrantfile).
|
25
|
+
|
26
|
+
```
|
27
|
+
Vagrant.configure('2') do |config|
|
28
|
+
config.ssh.insert_key = false
|
29
|
+
|
30
|
+
config.vm.define 'vqfx' do |vqfx|
|
31
|
+
vqfx.vm.hostname = 'vqfx'
|
32
|
+
vqfx.vm.box = 'juniper/vqfx10k-re'
|
33
|
+
vqfx.vm.synced_folder '.', '/vagrant', disabled: true
|
34
|
+
|
35
|
+
# Management port (em1 / em2)
|
36
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: 'reserved-bridge'
|
37
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', intnet: 'reserved-bridge'
|
38
|
+
|
39
|
+
# (em3 em4)
|
40
|
+
(1..2).each do |seg_id|
|
41
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', intnet: 'segment'
|
42
|
+
end
|
43
|
+
|
44
|
+
config.vm.provision 'junos_cli', path: 'provision.cmd'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
Note the `provision.cmd` file, referenced in the provisioner.
|
50
|
+
This is where your CLI commands should go.
|
51
|
+
|
52
|
+
```
|
53
|
+
configure
|
54
|
+
set interfaces em3 unit 0 family inet address 10.0.0.1/24
|
55
|
+
commit
|
56
|
+
exit
|
57
|
+
```
|
58
|
+
|
59
|
+
Run `vagrant up` and the new box is getting created with the address configured.
|
60
|
+
|
61
|
+
## Configuration
|
62
|
+
|
63
|
+
Junos CLI provisioner accepts most parameters available for the [Shell provisioner](https://www.vagrantup.com/docs/provisioning/shell.html).
|
64
|
+
Do not pass `args`.
|
65
|
+
|
data/Rakefile
ADDED
data/example/Vagrantfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure('2') do |config|
|
5
|
+
config.ssh.insert_key = false
|
6
|
+
|
7
|
+
config.vm.define 'vqfx' do |vqfx|
|
8
|
+
vqfx.vm.hostname = 'vqfx'
|
9
|
+
vqfx.vm.box = 'juniper/vqfx10k-re'
|
10
|
+
vqfx.vm.synced_folder '.', '/vagrant', disabled: true
|
11
|
+
|
12
|
+
# Management port (em1 / em2)
|
13
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: 'reserved-bridge'
|
14
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', intnet: 'reserved-bridge'
|
15
|
+
|
16
|
+
# (em3 em4)
|
17
|
+
(1..2).each do |_seg_id|
|
18
|
+
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', intnet: 'segment'
|
19
|
+
end
|
20
|
+
|
21
|
+
config.vm.provision 'junos_cli', path: 'provision.cmd'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module JunosCli
|
5
|
+
class Plugin < VagrantPlugins::Shell::Plugin
|
6
|
+
name 'junos_cli'
|
7
|
+
description <<-DESC
|
8
|
+
Junos CLI provisioner.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config(:junos_cli, :provisioner) do
|
12
|
+
require File.expand_path('../config', __FILE__)
|
13
|
+
Config
|
14
|
+
end
|
15
|
+
|
16
|
+
provisioner(:junos_cli) do
|
17
|
+
require File.expand_path('../provisioner', __FILE__)
|
18
|
+
Provisioner
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module JunosCli
|
3
|
+
class Provisioner < VagrantPlugins::Shell::Plugin.provisioner[:shell]
|
4
|
+
include Vagrant::Util::Retryable
|
5
|
+
|
6
|
+
def provision
|
7
|
+
raise Vagrant::Errors::ConfigInvalid, errors: "'args' attribute is not supported by junos_cli provisioner" unless config.args.nil?
|
8
|
+
raise Vagrant::Errors::ConfigInvalid, errors: "'env' attribute is not supported by junos_cli provisioner" unless config.env.empty?
|
9
|
+
|
10
|
+
provision_junos_cli
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def provision_junos_cli
|
16
|
+
@machine.config.ssh.shell = 'start shell'
|
17
|
+
|
18
|
+
with_script_file do |path|
|
19
|
+
@machine.communicate.tap do |comm|
|
20
|
+
# Reset upload path permissions for the current ssh user
|
21
|
+
info = nil
|
22
|
+
retryable(on: Vagrant::Errors::SSHNotReady, tries: 3, sleep: 2) do
|
23
|
+
info = @machine.ssh_info
|
24
|
+
raise Vagrant::Errors::SSHNotReady if info.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
if config.name
|
28
|
+
@machine.ui.detail(I18n.t('vagrant.provisioners.shell.running',
|
29
|
+
script: "script: #{config.name}"))
|
30
|
+
elsif config.path
|
31
|
+
@machine.ui.detail(I18n.t('vagrant.provisioners.shell.running',
|
32
|
+
script: path.to_s))
|
33
|
+
else
|
34
|
+
@machine.ui.detail(I18n.t('vagrant.provisioners.shell.running',
|
35
|
+
script: 'inline script'))
|
36
|
+
end
|
37
|
+
|
38
|
+
prepare = "/sbin/sh -c '\
|
39
|
+
if [ ! -d ~/.vagrant-junos_cli/bin ]; then\
|
40
|
+
/bin/mkdir -p ~/.vagrant-junos_cli/bin;\
|
41
|
+
/bin/ln -s /bin/echo ~/.vagrant-junos_cli/bin/printf;\
|
42
|
+
/bin/ln -s /bin/echo ~/.vagrant-junos_cli/bin/export;\
|
43
|
+
/bin/echo setenv PATH \\~/.vagrant-junos_cli/bin:\\$PATH >> ~/.cshrc;\
|
44
|
+
source ~/.cshrc;\
|
45
|
+
fi'"
|
46
|
+
|
47
|
+
cli_oneliner = format('/usr/sbin/cli -c "%s"', File.read(path).tr("\n", ';').gsub(/;+/, ';'))
|
48
|
+
|
49
|
+
[prepare, cli_oneliner].each do |command|
|
50
|
+
comm.execute(
|
51
|
+
command,
|
52
|
+
sudo: false,
|
53
|
+
error_key: :ssh_bad_exit_status_muted
|
54
|
+
) do |type, data|
|
55
|
+
handle_comm(type, data)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'vagrant/junos_cli/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'vagrant-junos_cli'
|
7
|
+
spec.version = Vagrant::JunosCli::VERSION
|
8
|
+
spec.authors = ['Mate Farkas']
|
9
|
+
spec.email = ['mate.farkas@sch.hu']
|
10
|
+
|
11
|
+
spec.summary = 'Provision Junos OS boxes using CLI commands.'
|
12
|
+
spec.homepage = 'https://github.com/farkasmate/vagrant-junos_cli'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
16
|
+
end
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.16.a'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-junos_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mate Farkas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.16.a
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.16.a
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- mate.farkas@sch.hu
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
50
|
+
- Gemfile
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- example/Vagrantfile
|
54
|
+
- example/provision.cmd
|
55
|
+
- lib/vagrant/junos_cli.rb
|
56
|
+
- lib/vagrant/junos_cli/config.rb
|
57
|
+
- lib/vagrant/junos_cli/plugin.rb
|
58
|
+
- lib/vagrant/junos_cli/provisioner.rb
|
59
|
+
- lib/vagrant/junos_cli/version.rb
|
60
|
+
- vagrant-junos_cli.gemspec
|
61
|
+
homepage: https://github.com/farkasmate/vagrant-junos_cli
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.2.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Provision Junos OS boxes using CLI commands.
|
84
|
+
test_files: []
|