Skip to content

Commit 5dea568

Browse files
authored
DB projects - optionally use YAML for configuration (#552)
For the 9 single-instance database projects, switch from optionally using the vagrant-env plugin for configuration to optionally using YAML. The vagrant-env plugin is no longer maintained, and doesn't work correctly with Vagrant 2.4.3+ without modifying the dotenv gem. See #551. The changes are the same for each project. .env/config.yaml: - rename .env to config.yaml and convert to YAML - remove comment referring to the vagrant-env plugin - update comment referring to .env/.env.local to refer to config.yaml/config.local.yaml .gitignore: - remove .env.local* and add config.local*.yaml README.md: - remove references to the vagrant-env plugin - replace references to .env/.env.local with references to config.yaml/config.local.yaml Vagrantfile: - remove references to the vagrant-env plugin - add "require 'yaml'" - replace the code that loads environment variables from .env files with code that loads environment variables from .yaml files Tested with both VirtualBox and libvirt providers. Signed-off-by: Paul Neumann <[email protected]>
1 parent c9a3453 commit 5dea568

36 files changed

+261
-279
lines changed

OracleDatabase/11.2.0.2/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.env.local*
1+
config.local*.yaml

OracleDatabase/11.2.0.2/README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ This Vagrant project provisions Oracle Database automatically, using Vagrant, an
44

55
## Prerequisites
66

7-
1. Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
8-
2. The [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is optional but
9-
makes configuration much easier
7+
Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
108

119
## Getting started
1210

@@ -53,14 +51,13 @@ There are three ways to set parameters:
5351

5452
1. Update the `Vagrantfile`. This is straightforward; the downside is that you will lose changes when you update this repository.
5553
2. Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
56-
3. Use the `.env`/`.env.local` files (requires
57-
[vagrant-env](https://github.com/gosuri/vagrant-env) plugin). You can configure your installation by editing the `.env` file, but `.env` will be overwritten on updates, so it's better to make a copy of `.env` called `.env.local`, then make changes in `.env.local`. The `.env.local` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
54+
3. Use the `config.yaml`/`config.local.yaml` files. You can configure your installation by editing the `config.yaml` file, but `config.yaml` will be overwritten on updates, so it's better to make a copy of `config.yaml` called `config.local.yaml`, then make changes in `config.local.yaml`. The `config.local.yaml` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
5855

5956
Parameters are considered in the following order (first one wins):
6057

6158
1. Environment variables
62-
2. `.env.local` (if it exists and the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
63-
3. `.env` (if the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
59+
2. `config.local.yaml` (if it exists)
60+
3. `config.yaml`
6461
4. `Vagrantfile` definitions
6562

6663
### VM parameters
@@ -78,12 +75,10 @@ Parameters are considered in the following order (first one wins):
7875
* `VM_LISTENER_PORT` (default: `1521`): Listener port.
7976
* `VM_ORACLE_PWD` (default: automatically generated): Oracle Database password for the SYS and SYSTEM accounts.
8077

81-
## Optional plugins
78+
## Optional plugin
8279

83-
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
80+
When installed, this Vagrant project will make use of the following third party Vagrant plugin:
8481

85-
* [vagrant-env](https://github.com/gosuri/vagrant-env): loads environment
86-
variables from .env files;
8782
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf): set
8883
proxies in the guest VM if you need to access the Internet through a proxy. See
8984
the plugin documentation for configuration.

OracleDatabase/11.2.0.2/Vagrantfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# Since: January, 2018
77
88
# Description: Creates an Oracle database Vagrant virtual machine.
9-
# Optional plugins:
10-
# vagrant-env (use .env files for configuration)
9+
# Optional plugin:
1110
# vagrant-proxyconf (if you don't have direct access to the Internet)
1211
# see https://github.com/tmatilai/vagrant-proxyconf for configuration
1312
#
@@ -16,6 +15,7 @@
1615

1716
# -*- mode: ruby -*-
1817
# vi: set ft=ruby :
18+
require 'yaml'
1919

2020
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
2121
VAGRANTFILE_API_VERSION = "2"
@@ -29,9 +29,13 @@ ui = Vagrant::UI::Prefixed.new(Vagrant::UI::Colored.new, "vagrant")
2929

3030
# Define constants
3131
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
32-
# Use vagrant-env plugin if available
33-
if Vagrant.has_plugin?("vagrant-env")
34-
config.env.load(".env.local", ".env") # enable the plugin
32+
# Load configuration parameters into environment
33+
['config.local.yaml', 'config.yaml'].each do |f|
34+
cfg = File.file?(f) ? YAML.safe_load_file(f, freeze: true) : {}
35+
cfg && cfg.each do |key, value|
36+
key = key.upcase
37+
(!ENV[key] || ENV[key].empty?) && ENV[key] = value.to_s
38+
end
3539
end
3640

3741
# VM name
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1+
---
12
# Oracle Database 11.2.0.2 Express Edition configuration file
23
#
3-
# Requires vagrant-env plugin
4-
#
5-
# This file will be overwritten on updates, so it is recommended to make
6-
# a copy of this file called .env.local, then make changes in .env.local.
4+
# This file will be overwritten on updates, so it is recommended to make a copy
5+
# of this file called config.local.yaml, then make changes in config.local.yaml.
76
#
87
# To change a parameter, uncomment it and set it to the desired value.
98
# All commented parameters will retain their default values.
109

1110
# VM name
12-
# VM_NAME='oracle11g-xe-vagrant'
11+
#VM_NAME: 'oracle11g-xe-vagrant'
1312

1413
# Memory for the VM (in MB, 2048 MB = 2 GB)
15-
# VM_MEMORY=2048
14+
#VM_MEMORY: 2048
1615

1716
# VM time zone
1817
# If not specified, will be set to match host time zone (if possible)
1918
# Can use time zone name (e.g., 'America/Los_Angeles')
2019
# or an offset from GMT (e.g., 'Etc/GMT-2')
21-
# VM_SYSTEM_TIMEZONE=
20+
#VM_SYSTEM_TIMEZONE: ''
2221

2322
# Listener port
24-
# VM_LISTENER_PORT=1521
23+
#VM_LISTENER_PORT: 1521
2524

2625
# Oracle Database password for SYS and SYSTEM accounts
2726
# If left blank, the password will be generated automatically
28-
# VM_ORACLE_PWD=
27+
#VM_ORACLE_PWD: ''

OracleDatabase/12.1.0.2/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.env.local*
1+
config.local*.yaml

OracleDatabase/12.1.0.2/README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ This Vagrant project provisions Oracle Database automatically, using Vagrant, an
44

55
## Prerequisites
66

7-
1. Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
8-
2. The [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is optional but
9-
makes configuration much easier
7+
Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
108

119
## Getting started
1210

@@ -57,14 +55,13 @@ There are three ways to set parameters:
5755

5856
1. Update the `Vagrantfile`. This is straightforward; the downside is that you will lose changes when you update this repository.
5957
2. Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
60-
3. Use the `.env`/`.env.local` files (requires
61-
[vagrant-env](https://github.com/gosuri/vagrant-env) plugin). You can configure your installation by editing the `.env` file, but `.env` will be overwritten on updates, so it's better to make a copy of `.env` called `.env.local`, then make changes in `.env.local`. The `.env.local` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
58+
3. Use the `config.yaml`/`config.local.yaml` files. You can configure your installation by editing the `config.yaml` file, but `config.yaml` will be overwritten on updates, so it's better to make a copy of `config.yaml` called `config.local.yaml`, then make changes in `config.local.yaml`. The `config.local.yaml` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
6259

6360
Parameters are considered in the following order (first one wins):
6461

6562
1. Environment variables
66-
2. `.env.local` (if it exists and the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
67-
3. `.env` (if the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
63+
2. `config.local.yaml` (if it exists)
64+
3. `config.yaml`
6865
4. `Vagrantfile` definitions
6966

7067
### VM parameters
@@ -89,12 +86,10 @@ Parameters are considered in the following order (first one wins):
8986
* `VM_EM_EXPRESS_PORT` (default: `5500`): EM Express port.
9087
* `VM_ORACLE_PWD` (default: automatically generated): Oracle Database password for the SYS, SYSTEM and PDBADMIN accounts.
9188

92-
## Optional plugins
89+
## Optional plugin
9390

94-
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
91+
When installed, this Vagrant project will make use of the following third party Vagrant plugin:
9592

96-
* [vagrant-env](https://github.com/gosuri/vagrant-env): loads environment
97-
variables from .env files;
9893
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf): set
9994
proxies in the guest VM if you need to access the Internet through a proxy. See
10095
the plugin documentation for configuration.

OracleDatabase/12.1.0.2/Vagrantfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# Since: January, 2018
77
88
# Description: Creates an Oracle database Vagrant virtual machine.
9-
# Optional plugins:
10-
# vagrant-env (use .env files for configuration)
9+
# Optional plugin:
1110
# vagrant-proxyconf (if you don't have direct access to the Internet)
1211
# see https://github.com/tmatilai/vagrant-proxyconf for configuration
1312
#
@@ -16,6 +15,7 @@
1615

1716
# -*- mode: ruby -*-
1817
# vi: set ft=ruby :
18+
require 'yaml'
1919

2020
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
2121
VAGRANTFILE_API_VERSION = "2"
@@ -29,9 +29,13 @@ ui = Vagrant::UI::Prefixed.new(Vagrant::UI::Colored.new, "vagrant")
2929

3030
# Define constants
3131
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
32-
# Use vagrant-env plugin if available
33-
if Vagrant.has_plugin?("vagrant-env")
34-
config.env.load(".env.local", ".env") # enable the plugin
32+
# Load configuration parameters into environment
33+
['config.local.yaml', 'config.yaml'].each do |f|
34+
cfg = File.file?(f) ? YAML.safe_load_file(f, freeze: true) : {}
35+
cfg && cfg.each do |key, value|
36+
key = key.upcase
37+
(!ENV[key] || ENV[key].empty?) && ENV[key] = value.to_s
38+
end
3539
end
3640

3741
# VM name
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
1+
---
12
# Oracle Database 12.1.0.2 configuration file
23
#
3-
# Requires vagrant-env plugin
4-
#
5-
# This file will be overwritten on updates, so it is recommended to make
6-
# a copy of this file called .env.local, then make changes in .env.local.
4+
# This file will be overwritten on updates, so it is recommended to make a copy
5+
# of this file called config.local.yaml, then make changes in config.local.yaml.
76
#
87
# To change a parameter, uncomment it and set it to the desired value.
98
# All commented parameters will retain their default values.
109

1110
# VM name
12-
# VM_NAME='oracle-12102-vagrant'
11+
#VM_NAME: 'oracle-12102-vagrant'
1312

1413
# Memory for the VM (in MB, 2048 MB = 2 GB)
15-
# VM_MEMORY=2048
14+
#VM_MEMORY: 2048
1615

1716
# VM time zone
1817
# If not specified, will be set to match host time zone (if possible)
1918
# Can use time zone name (e.g., 'America/Los_Angeles')
2019
# or an offset from GMT (e.g., 'Etc/GMT-2')
21-
# VM_SYSTEM_TIMEZONE=
20+
#VM_SYSTEM_TIMEZONE: ''
2221

2322
# Oracle base directory
24-
# VM_ORACLE_BASE='/opt/oracle'
23+
#VM_ORACLE_BASE: '/opt/oracle'
2524

2625
# Oracle home directory
27-
# VM_ORACLE_HOME='/opt/oracle/product/12.1.0.2/dbhome_1'
26+
#VM_ORACLE_HOME: '/opt/oracle/product/12.1.0.2/dbhome_1'
2827

2928
# Oracle SID
30-
# VM_ORACLE_SID='ORCLCDB'
29+
#VM_ORACLE_SID: 'ORCLCDB'
3130

3231
# PDB name
33-
# VM_ORACLE_PDB='ORCLPDB1'
32+
#VM_ORACLE_PDB: 'ORCLPDB1'
3433

3534
# Database character set
36-
# VM_ORACLE_CHARACTERSET='AL32UTF8'
35+
#VM_ORACLE_CHARACTERSET: 'AL32UTF8'
3736

3837
# Oracle Database edition
3938
# Valid values are 'EE' for Enterprise Edition or 'SE2' for Standard Edition 2
40-
# VM_ORACLE_EDITION='EE'
39+
#VM_ORACLE_EDITION: 'EE'
4140

4241
# Listener port
43-
# VM_LISTENER_PORT=1521
42+
#VM_LISTENER_PORT: 1521
4443

4544
# EM Express port
46-
# VM_EM_EXPRESS_PORT=5500
45+
#VM_EM_EXPRESS_PORT: 5500
4746

4847
# Oracle Database password for SYS, SYSTEM and PDBADMIN accounts
4948
# If left blank, the password will be generated automatically
50-
# VM_ORACLE_PWD=
49+
#VM_ORACLE_PWD: ''

OracleDatabase/12.2.0.1/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.env.local*
1+
config.local*.yaml

OracleDatabase/12.2.0.1/README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ This Vagrant project provisions Oracle Database automatically, using Vagrant, an
44

55
## Prerequisites
66

7-
1. Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
8-
2. The [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is optional but
9-
makes configuration much easier
7+
Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
108

119
## Getting started
1210

@@ -55,14 +53,13 @@ There are three ways to set parameters:
5553

5654
1. Update the `Vagrantfile`. This is straightforward; the downside is that you will lose changes when you update this repository.
5755
2. Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
58-
3. Use the `.env`/`.env.local` files (requires
59-
[vagrant-env](https://github.com/gosuri/vagrant-env) plugin). You can configure your installation by editing the `.env` file, but `.env` will be overwritten on updates, so it's better to make a copy of `.env` called `.env.local`, then make changes in `.env.local`. The `.env.local` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
56+
3. Use the `config.yaml`/`config.local.yaml` files. You can configure your installation by editing the `config.yaml` file, but `config.yaml` will be overwritten on updates, so it's better to make a copy of `config.yaml` called `config.local.yaml`, then make changes in `config.local.yaml`. The `config.local.yaml` file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
6057

6158
Parameters are considered in the following order (first one wins):
6259

6360
1. Environment variables
64-
2. `.env.local` (if it exists and the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
65-
3. `.env` (if the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
61+
2. `config.local.yaml` (if it exists)
62+
3. `config.yaml`
6663
4. `Vagrantfile` definitions
6764

6865
### VM parameters
@@ -87,12 +84,10 @@ Parameters are considered in the following order (first one wins):
8784
* `VM_EM_EXPRESS_PORT` (default: `5500`): EM Express port.
8885
* `VM_ORACLE_PWD` (default: automatically generated): Oracle Database password for the SYS, SYSTEM and PDBADMIN accounts.
8986

90-
## Optional plugins
87+
## Optional plugin
9188

92-
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
89+
When installed, this Vagrant project will make use of the following third party Vagrant plugin:
9390

94-
* [vagrant-env](https://github.com/gosuri/vagrant-env): loads environment
95-
variables from .env files;
9691
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf): set
9792
proxies in the guest VM if you need to access the Internet through a proxy. See
9893
the plugin documentation for configuration.

0 commit comments

Comments
 (0)