Back-port #36062 to 2015.8 (#36118)

* Comment all lines in the minion config file

* Add unit tests to check for all files in conf/ to be commented out

* Make sure cont/cloud.profiles file is commented out

Matches the cloud.providers file format and other sample config files.

* Add unit tests for sample files in cloud.profiles.d, cloud.providers.d,
and cloud.maps.d

* Make sure all sample config files in cloud.maps.d are commented out

* Make sure all sample config files in cloud.profiles.d are commented out
This commit is contained in:
Nicole Thomas 2016-09-07 16:01:34 -06:00 committed by GitHub
parent fa09050150
commit 7cdbc546f1
7 changed files with 503 additions and 299 deletions

View file

@ -4,17 +4,16 @@
# Because the location to this file must be explicitly declared when using it,
# its actual location on disk is up to the user.
#fedora_rs:
# - fedora1
# - fedora2
# - fedora3
# - fedora4
# - fedora5
fedora_rs:
- fedora1
- fedora2
- fedora3
- fedora4
- fedora5
ubuntu_rs:
- ubuntu1
- ubuntu2
- ubuntu3
- ubuntu4
- ubuntu5
#ubuntu_rs:
# - ubuntu1
# - ubuntu2
# - ubuntu3
# - ubuntu4
# - ubuntu5

View file

@ -1,23 +1,27 @@
base_ec2:
provider: my-ec2-config
image: ami-e565ba8c
size: t1.micro
script: python-bootstrap
minion:
cheese: edam
# This file may be used in addition to, or instead of, the files in the
# cloud.profiles.d/ directory. The format for this file, and all files in that
# directory, is identical.
ubuntu_rs:
provider: my-openstack-rackspace-config
image: Ubuntu 12.04 LTS
size: 256 server
script: Ubuntu
minion:
cheese: edam
#base_ec2:
# provider: my-ec2-config
# image: ami-e565ba8c
# size: t1.micro
# script: python-bootstrap
# minion:
# cheese: edam
fedora_rs:
provider: my-openstack-rackspace-config
image: Fedora 17
size: 256 server
script: Fedora
minion:
cheese: edam
#ubuntu_rs:
# provider: my-openstack-rackspace-config
# image: Ubuntu 12.04 LTS
# size: 256 server
# script: Ubuntu
# minion:
# cheese: edam
#fedora_rs:
# provider: my-openstack-rackspace-config
# image: Fedora 17
# size: 256 server
# script: Fedora
# minion:
# cheese: edam

View file

@ -2,115 +2,114 @@
# Arch Linux
# https://wiki.archlinux.org/index.php/Arch_Linux_AMIs_for_Amazon_Web_Services
arch_ec2:
provider: my-ec2-config
image: ami-6ee95107
size: t1.micro
ssh_username: root
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#arch_ec2:
# provider: my-ec2-config
# image: ami-6ee95107
# size: t1.micro
# ssh_username: root
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
arch_cloud-init_ec2:
provider: my-ec2-config
image: ami-596de730
size: t1.micro
ssh_username: root
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#arch_cloud-init_ec2:
# provider: my-ec2-config
# image: ami-596de730
# size: t1.micro
# ssh_username: root
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
# Centos 6, available from ec2 marketplace for no-charge
# http://wiki.centos.org/Cloud/AWS
centos_6:
provider: my-ec2-config
image: ami-86e15bef
size: t1.micro
ssh_username: root
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#centos_6:
# provider: my-ec2-config
# image: ami-86e15bef
# size: t1.micro
# ssh_username: root
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
# official Debian, available at no-charge from ec2 marketplace:
# http://wiki.debian.org/Cloud/AmazonEC2Image
debian_squeeze_ec2:
provider: my-ec2-config
image: ami-a121a6c8
size: t1.micro
ssh_username: admin
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#debian_squeeze_ec2:
# provider: my-ec2-config
# image: ami-a121a6c8
# size: t1.micro
# ssh_username: admin
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
# Fedora project cloud images
# https://fedoraproject.org/wiki/Cloud_images
fedora_17_ec2:
provider: my-ec2-config
image: ami-2ea50247
size: t1.micro
ssh_username: ec2-user
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#fedora_17_ec2:
# provider: my-ec2-config
# image: ami-2ea50247
# size: t1.micro
# ssh_username: ec2-user
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
fedora_18_ec2:
provider: my-ec2-config
image: ami-6145cc08
size: t1.micro
ssh_username: ec2-user
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#fedora_18_ec2:
# provider: my-ec2-config
# image: ami-6145cc08
# size: t1.micro
# ssh_username: ec2-user
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
# FreeBSD 9.1
# http://www.daemonology.net/freebsd-on-ec2/
# this t1.micro instance does not auto-populate SSH keys see above link
freebsd_91_ec2:
provider: my-ec2-config
image: ami-5339bb3a
size: t1.micro
ssh_username: ec2-user
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#freebsd_91_ec2:
# provider: my-ec2-config
# image: ami-5339bb3a
# size: t1.micro
# ssh_username: ec2-user
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
freebsd_91_4XL_ec2:
provider: my-ec2-config
image: ami-79088510
size: Cluster Compute 4XL
ssh_username: ec2-user
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#freebsd_91_4XL_ec2:
# provider: my-ec2-config
# image: ami-79088510
# size: Cluster Compute 4XL
# ssh_username: ec2-user
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
# Canonical Ubuntu LTS images
# http://cloud-images.ubuntu.com/releases/
ubuntu_lucid_ec2:
provider: my-ec2-config
image: ami-21e47148
size: t1.micro
ssh_username: ubuntu
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
ubuntu_precise_ec2:
provider: my-ec2-config
image: ami-0145d268
size: t1.micro
ssh_username: ubuntu
location: us-east-1
minion:
grains:
cloud: ec2-us-east-1
#ubuntu_lucid_ec2:
# provider: my-ec2-config
# image: ami-21e47148
# size: t1.micro
# ssh_username: ubuntu
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1
#ubuntu_precise_ec2:
# provider: my-ec2-config
# image: ami-0145d268
# size: t1.micro
# ssh_username: ubuntu
# location: us-east-1
# minion:
# grains:
# cloud: ec2-us-east-1

View file

@ -2,105 +2,104 @@
# Arch Linux
# https://wiki.archlinux.org/index.php/Arch_Linux_AMIs_for_Amazon_Web_Services
arch_ec2:
provider: my-ec2-config
image: ami-337d5b76
size: t1.micro
ssh_username: root
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#arch_ec2:
# provider: my-ec2-config
# image: ami-337d5b76
# size: t1.micro
# ssh_username: root
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
arch_cloud-init_ec2:
provider: my-ec2-config
image: ami-6a5f7c2f
size: t1.micro
ssh_username: root
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#arch_cloud-init_ec2:
# provider: my-ec2-config
# image: ami-6a5f7c2f
# size: t1.micro
# ssh_username: root
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
# Centos 6, available from ec2 marketplace for no-charge
# http://wiki.centos.org/Cloud/AWS
centos_6:
provider: my-ec2-config
image: ami-f61630b3
size: t1.micro
ssh_username: root
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#centos_6:
# provider: my-ec2-config
# image: ami-f61630b3
# size: t1.micro
# ssh_username: root
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
# official Debian, available at no-charge from ec2 marketplace:
# http://wiki.debian.org/Cloud/AmazonEC2Image
debian_squeeze_ec2:
provider: my-ec2-config
image: ami-2c735269
size: t1.micro
ssh_username: admin
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#debian_squeeze_ec2:
# provider: my-ec2-config
# image: ami-2c735269
# size: t1.micro
# ssh_username: admin
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
# Fedora project cloud images
# https://fedoraproject.org/wiki/Cloud_images
fedora_17_ec2:
provider: my-ec2-config
image: ami-877e24c2
size: t1.micro
ssh_username: ec2-user
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#fedora_17_ec2:
# provider: my-ec2-config
# image: ami-877e24c2
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
fedora_18_ec2:
provider: my-ec2-config
image: ami-0899b94d
size: t1.micro
ssh_username: ec2-user
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#fedora_18_ec2:
# provider: my-ec2-config
# image: ami-0899b94d
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
# FreeBSD 9.1
# http://www.daemonology.net/freebsd-on-ec2/
# this t1.micro instance does not auto-populate SSH keys see above link
freebsd_91_ec2:
provider: my-ec2-config
image: ami-4c8baa09
size: t1.micro
ssh_username: ec2-user
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#freebsd_91_ec2:
# provider: my-ec2-config
# image: ami-4c8baa09
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
# Canonical Ubuntu LTS images
# http://cloud-images.ubuntu.com/releases/
ubuntu_lucid_ec2:
provider: my-ec2-config
image: ami-e63013a3
size: t1.micro
ssh_username: ubuntu
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
ubuntu_precise_ec2:
provider: my-ec2-config
image: ami-3ed8fb7b
size: t1.micro
ssh_username: ubuntu
location: us-west-1
minion:
grains:
cloud: ec2-us-west-1
#ubuntu_lucid_ec2:
# provider: my-ec2-config
# image: ami-e63013a3
# size: t1.micro
# ssh_username: ubuntu
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1
#ubuntu_precise_ec2:
# provider: my-ec2-config
# image: ami-3ed8fb7b
# size: t1.micro
# ssh_username: ubuntu
# location: us-west-1
# minion:
# grains:
# cloud: ec2-us-west-1

View file

@ -2,115 +2,114 @@
# Arch Linux
# https://wiki.archlinux.org/index.php/Arch_Linux_AMIs_for_Amazon_Web_Services
arch_ec2:
provider: my-ec2-config
image: ami-bcf77e8c
size: t1.micro
ssh_username: root
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#arch_ec2:
# provider: my-ec2-config
# image: ami-bcf77e8c
# size: t1.micro
# ssh_username: root
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
arch_cloud-init_ec2:
provider: my-ec2-config
image: ami-6a5f7c2f
size: t1.micro
ssh_username: root
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#arch_cloud-init_ec2:
# provider: my-ec2-config
# image: ami-6a5f7c2f
# size: t1.micro
# ssh_username: root
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
# Centos 6, available from ec2 marketplace for no-charge
# http://wiki.centos.org/Cloud/AWS
centos_6:
provider: my-ec2-config
image: ami-de5bd2ee
size: t1.micro
ssh_username: root
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#centos_6:
# provider: my-ec2-config
# image: ami-de5bd2ee
# size: t1.micro
# ssh_username: root
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
# official Debian, available at no-charge from ec2 marketplace:
# http://wiki.debian.org/Cloud/AmazonEC2Image
debian_squeeze_ec2:
provider: my-ec2-config
image: ami-e4da52d4
size: t1.micro
ssh_username: admin
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#debian_squeeze_ec2:
# provider: my-ec2-config
# image: ami-e4da52d4
# size: t1.micro
# ssh_username: admin
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
# Fedora project cloud images
# https://fedoraproject.org/wiki/Cloud_images
fedora_17_ec2:
provider: my-ec2-config
image: ami-8e69e5be
size: t1.micro
ssh_username: ec2-user
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#fedora_17_ec2:
# provider: my-ec2-config
# image: ami-8e69e5be
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
fedora_18_ec2:
provider: my-ec2-config
image: ami-0266ed32
size: t1.micro
ssh_username: ec2-user
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#fedora_18_ec2:
# provider: my-ec2-config
# image: ami-0266ed32
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
# FreeBSD 9.1
# http://www.daemonology.net/freebsd-on-ec2/
# this t1.micro instance does not auto-populate SSH keys see above link
freebsd_91_ec2:
provider: my-ec2-config
image: ami-aa09819a
size: t1.micro
ssh_username: ec2-user
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#freebsd_91_ec2:
# provider: my-ec2-config
# image: ami-aa09819a
# size: t1.micro
# ssh_username: ec2-user
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
freebsd_91_4XL_ec2:
provider: my-ec2-config
image: ami-66169e56
size: Cluster Compute 4XL
ssh_username: ec2-user
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#freebsd_91_4XL_ec2:
# provider: my-ec2-config
# image: ami-66169e56
# size: Cluster Compute 4XL
# ssh_username: ec2-user
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
# Canonical Ubuntu LTS images
# http://cloud-images.ubuntu.com/releases/
ubuntu_lucid_ec2:
provider: my-ec2-config
image: ami-6ec8425e
size: t1.micro
ssh_username: ubuntu
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
ubuntu_precise_ec2:
provider: my-ec2-config
image: ami-e0941ed0
size: t1.micro
ssh_username: ubuntu
location: us-west-2
minion:
grains:
cloud: ec2-us-west-2
#ubuntu_lucid_ec2:
# provider: my-ec2-config
# image: ami-6ec8425e
# size: t1.micro
# ssh_username: ubuntu
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2
#ubuntu_precise_ec2:
# provider: my-ec2-config
# image: ami-e0941ed0
# size: t1.micro
# ssh_username: ubuntu
# location: us-west-2
# minion:
# grains:
# cloud: ec2-us-west-2

View file

@ -353,7 +353,17 @@
# access the master has to the minion.
#disable_modules: [cmd,test]
#disable_returners: []
#
# This is the reverse of disable_modules. The default, like disable_modules, is the empty list,
# but if this option is set to *anything* then *only* those modules will load.
# Note that this is a very large hammer and it can be quite difficult to keep the minion working
# the way you think it should since Salt uses many modules internally itself. At a bare minimum
# you need the following enabled or else the minion won't start.
#whitelist_modules:
# - cmdmod
# - test
# - config
# Modules can be loaded from arbitrary paths. This enables the easy deployment
# of third party modules. Modules for returners and minions can be loaded.
# Specify a list of extra directories to search for minion modules and

194
tests/unit/conf_test.py Normal file
View file

@ -0,0 +1,194 @@
# -*- coding: utf-8 -*-
'''
Unit tests for the files in the salt/conf directory.
'''
# Import Python libs
from __future__ import absolute_import
import os
# Import Salt Testing libs
from salttesting import skipIf, TestCase
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import (
NO_MOCK,
NO_MOCK_REASON,
)
ensure_in_syspath('../')
# Import Salt libs
import salt.config
SAMPLE_CONF_DIR = os.path.dirname(os.path.realpath(__file__)).split('tests')[0] + 'conf/'
@skipIf(NO_MOCK, NO_MOCK_REASON)
class ConfTest(TestCase):
'''
Validate files in the salt/conf directory.
'''
def test_conf_master_sample_is_commented(self):
'''
The sample config file located in salt/conf/master must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
master_config = SAMPLE_CONF_DIR + 'master'
ret = salt.config._read_conf_file(master_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
master_config
)
)
def test_conf_minion_sample_is_commented(self):
'''
The sample config file located in salt/conf/minion must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
minion_config = SAMPLE_CONF_DIR + 'minion'
ret = salt.config._read_conf_file(minion_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
minion_config
)
)
def test_conf_cloud_sample_is_commented(self):
'''
The sample config file located in salt/conf/cloud must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
cloud_config = SAMPLE_CONF_DIR + 'cloud'
ret = salt.config._read_conf_file(cloud_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
cloud_config
)
)
def test_conf_cloud_profiles_sample_is_commented(self):
'''
The sample config file located in salt/conf/cloud.profiles must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
cloud_profiles_config = SAMPLE_CONF_DIR + 'cloud.profiles'
ret = salt.config._read_conf_file(cloud_profiles_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
cloud_profiles_config
)
)
def test_conf_cloud_providers_sample_is_commented(self):
'''
The sample config file located in salt/conf/cloud.providers must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
cloud_providers_config = SAMPLE_CONF_DIR + 'cloud.providers'
ret = salt.config._read_conf_file(cloud_providers_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
cloud_providers_config
)
)
def test_conf_proxy_sample_is_commented(self):
'''
The sample config file located in salt/conf/proxy must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
proxy_config = SAMPLE_CONF_DIR + 'proxy'
ret = salt.config._read_conf_file(proxy_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
proxy_config
)
)
def test_conf_roster_sample_is_commented(self):
'''
The sample config file located in salt/conf/roster must be completely
commented out. This test checks for any lines that are not commented or blank.
'''
roster_config = SAMPLE_CONF_DIR + 'roster'
ret = salt.config._read_conf_file(roster_config)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
roster_config
)
)
def test_conf_cloud_profiles_d_files_are_commented(self):
'''
All cloud profile sample configs in salt/conf/cloud.profiles.d/* must be completely
commented out. This test loops through all of the files in that directory to check
for any lines that are not commented or blank.
'''
cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.profiles.d/')
for conf_file in cloud_sample_files:
profile_conf = SAMPLE_CONF_DIR + 'cloud.profiles.d/' + conf_file
ret = salt.config._read_conf_file(profile_conf)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
conf_file
)
)
def test_conf_cloud_providers_d_files_are_commented(self):
'''
All cloud profile sample configs in salt/conf/cloud.providers.d/* must be completely
commented out. This test loops through all of the files in that directory to check
for any lines that are not commented or blank.
'''
cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.providers.d/')
for conf_file in cloud_sample_files:
provider_conf = SAMPLE_CONF_DIR + 'cloud.providers.d/' + conf_file
ret = salt.config._read_conf_file(provider_conf)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
conf_file
)
)
def test_conf_cloud_maps_d_files_are_commented(self):
'''
All cloud profile sample configs in salt/conf/cloud.maps.d/* must be completely
commented out. This test loops through all of the files in that directory to check
for any lines that are not commented or blank.
'''
cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.maps.d/')
for conf_file in cloud_sample_files:
map_conf = SAMPLE_CONF_DIR + 'cloud.maps.d/' + conf_file
ret = salt.config._read_conf_file(map_conf)
self.assertEqual(
ret,
{},
'Sample config file \'{0}\' must be commented out.'.format(
conf_file
)
)
if __name__ == '__main__':
from integration import run_tests
run_tests(ConfTest, needs_daemon=False)