diff --git a/CONTRIB.md b/CONTRIB.md index 81735ba67..a85c8eb0d 100644 --- a/CONTRIB.md +++ b/CONTRIB.md @@ -14,9 +14,7 @@ Use [PULL_REQUEST_TEMPLATE.md](/PULL_REQUEST_TEMPLATE.md) to create the descript ## Development Environment -You can use our Docker or Vagrant/VirtualBox development environments. - -### Docker +You can use our Docker-compose environment to stand up a development OpenOversight. You will need to have Docker installed in order to use the Docker development environment. @@ -39,61 +37,6 @@ $ docker exec -it openoversight_web_1 /bin/bash Once you're done, `make stop` and `make clean` to stop and remove the containers respectively. -### VirtualBox + Vagrant - -Our standard development environment is an Ubuntu 14 VM. We manage it with Vagrant, which means you'll need Vagrant and VirtualBox installed to start out. - -* Install Vagrant: https://www.vagrantup.com/downloads.html -* Install VirtualBox: https://www.virtualbox.org/wiki/Downloads - -Make sure you've started VirtualBox, and then in your project directory, run: - -`vagrant up` - -This creates a new, pristine virtual machine and provisions it to be an almost-copy of production with a local test database. (Behind the scenes, this is all happening via the files in vagrant/puppet.) If everything works, you should get a webserver listening at `http://localhost:3000` that you can browse to on your host machine. - -In addition, you can now SSH into it: - -`vagrant ssh` - -The provisioning step creates a virtual environment (venv) in `~/oovirtenv`. If you will be running lots of python-related commands, you can 'activate' the virtual environment (override the built-in python and pip commands and add pytest and fab to your path) by activating it: -```sh -vagrant@vagrant-ubuntu-trusty-64:~$ source /home/vagrant/oovirtenv/bin/activate -``` - -You can tell that your virtual environment is activated by seeing the addition of `(oovirtenv)` to your prompt: -```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:~$ -``` -When this is done, you no longer need to preface python commands (as below) with `~/oovirtenv/bin`. - -In the VM instance, your code is copied to a folder inside of `/vagrant`, so you'll want to run this: -```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:~$ cd /vagrant/OpenOversight -``` - -*Note:* the photo upload functionality - which uses an S3 bucket - and the email functionality - which -requires an email account - do not work in the development environment as they require some environment -variables to be configured. - -## Server commands - -The app, as provisioned, is running under gunicorn, which means that it does not dynamically reload your changes. - -If you run the app in debug mode, you can see these changes take effect on every update, but certain changes will kill the server in a way some of us find really irritating. To do this: - -`vagrant ssh` (if you're not already there) -```sh -$ sudo service gunicorn stop - * Stopping Gunicorn workers - [oo] * -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:~$ cd /vagrant/OpenOversight/ # (again, if you're not already there) -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py runserver - * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit) - * Restarting with stat - * Debugger is active! -``` - ## Database commands You can access your PostgreSQL development database via psql using: @@ -105,16 +48,16 @@ psql -h localhost -d openoversight-dev -U openoversight --password with the password `terriblepassword`. -The provisioning step already does this, but in case you need it, in the `/vagrant/OpenOversight` directory, there is a script to create the database: +In the Docker environment, you'll need to run the script to create the database: ```sh -~/oovirtenv/bin/python create_db.py +$ python create_db.py ``` In the event that you need to create or delete the test data, you can do that with -`~/oovirtenv/bin/python test_data.py --populate` to create the data +`$ python test_data.py --populate` to create the data or -`~/oovirtenv/bin/python test_data.py --cleanup` to delete the data +`$ python test_data.py --cleanup` to delete the data ### Migrating the Database @@ -123,13 +66,13 @@ If you e.g. add a new column or table, you'll need to migrate the database. You can use the management interface to first generate migrations: ```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py db migrate +$ python manage.py db migrate ``` And then you should inspect/edit the migrations. You can then apply the migrations: ```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py db upgrade +$ python manage.py db upgrade ``` You can also downgrade the database using `python manage.py db downgrade`. @@ -139,7 +82,7 @@ You can also downgrade the database using `python manage.py db downgrade`. In addition to running the development server, `manage.py` (OpenOversight's management interface) can be used to do the following: ```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py +$ python manage.py -------------------------------------------------------------------------------- INFO in __init__ [/vagrant/OpenOversight/app/__init__.py:57]: OpenOversight startup @@ -164,39 +107,10 @@ optional arguments: In development, you can make an administrator account without having to confirm your email: ```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight$ python manage.py make_admin_user +$ python manage.py make_admin_user Username: redshiftzero Email: jen@redshiftzero.com Password: Type your password again: Administrator redshiftzero successfully added ``` - -## Running Unit Tests - - Run tests with `pytest`: - -```sh -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight/$ cd tests -(oovirtenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/OpenOversight/tests$ pytest -``` - -## Changing the Development Environment - -If you're making massive changes to the development environment provisioning, you should know that Vagrant and the Puppet modules that provision the box use Ruby, so you'll want some reasonably-modern Ruby. Anything in the 2.0-2.2 area should work. Puppet has some annoying interactions where puppet 3 doesn't work with ruby 2.2, though, so you might have to get creative on modern OSes. - -If you don't have bundler installed: - -`gem install bundler` - -If you don't have rake installed: - -`bundle install` - -Then provision the VM: - -`rake vagrant:provision` - -Puppet modules are dropped into place by librarian-puppet, and there's a rake task that'll do it without the headache of remembering all the paths and such: - -`rake vagrant:build_puppet` diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 073cec6c8..000000000 --- a/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' -gem 'librarian-puppet' -gem 'puppet', '~>3.8' diff --git a/Makefile b/Makefile index 0ad1b6bd2..d50110e12 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -.PHONY: default build run - default: dev build start test stop clean -dev: +.PHONY: dev +dev: ## Build and run containers make build make start -build: +.PHONY: build +build: ## Build containers docker-compose build postgres docker-compose up -d postgres docker-compose build web @@ -14,15 +14,31 @@ build: docker-compose run --rm web /usr/local/bin/python ../create_db.py docker-compose run --rm web /usr/local/bin/python ../test_data.py -p -start: +.PHONY: start +start: ## Run containers docker-compose up -d -clean: +.PHONY: clean +clean: ## Remove containers docker rm openoversight_web_1 docker rm openoversight_postgres_1 -test: +.PHONY: test +test: ## Run tests docker-compose run --rm web /usr/local/bin/pytest -v tests/ -stop: +.PHONY: stop +stop: ## Stop containers docker-compose stop + +.PHONY: docs +docs: ## Build project documentation in live reload for editing + make -C docs/ clean && sphinx-autobuild docs/ docs/_build/html + +.PHONY: help +help: ## Print this message and exit + @printf "OpenOversight: Makefile for development, documentation and testing.\n" + @printf "Subcommands:\n\n" + @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) \ + | sort \ + | column -s ':' -t diff --git a/OpenOversight/app/__init__.py b/OpenOversight/app/__init__.py index 03b274ec1..8d336cbf8 100644 --- a/OpenOversight/app/__init__.py +++ b/OpenOversight/app/__init__.py @@ -75,6 +75,11 @@ def internal_error(e): def rate_exceeded(e): return render_template('429.html'), 429 + # create jinja2 filter for titles with multiple capitals + @app.template_filter('capfirst') + def capfirst_filter(s): + return s[0].capitalize() + s[1:] # only change 1st letter + return app diff --git a/OpenOversight/app/main/choices.py b/OpenOversight/app/main/choices.py index a9ac84252..343543bd5 100644 --- a/OpenOversight/app/main/choices.py +++ b/OpenOversight/app/main/choices.py @@ -1,6 +1,8 @@ from us import states # Choices are a list of (value, label) tuples +SUFFIX_CHOICES = [('', '-'), ('Jr', 'Jr'), ('Sr', 'Sr'), ('II', 'II'), + ('III', 'III'), ('IV', 'IV'), ('V', 'V')] RACE_CHOICES = [('BLACK', 'Black'), ('WHITE', 'White'), ('ASIAN', 'Asian'), ('HISPANIC', 'Hispanic'), ('NATIVE AMERICAN', 'Native American'), diff --git a/OpenOversight/app/main/forms.py b/OpenOversight/app/main/forms.py index 4b489cfa7..40cfe6382 100644 --- a/OpenOversight/app/main/forms.py +++ b/OpenOversight/app/main/forms.py @@ -10,15 +10,15 @@ from flask_wtf.file import FileField, FileAllowed, FileRequired from ..utils import unit_choices, dept_choices -from .choices import GENDER_CHOICES, RACE_CHOICES, RANK_CHOICES, STATE_CHOICES, LINK_CHOICES +from .choices import SUFFIX_CHOICES, GENDER_CHOICES, RACE_CHOICES, RANK_CHOICES, STATE_CHOICES, LINK_CHOICES from ..formfields import TimeField from ..widgets import BootstrapListWidget, FormFieldWidget from ..models import Officer import datetime -def allowed_values(choices): - return [x[0] for x in choices] +def allowed_values(choices, empty_allowed=True): + return [x[0] for x in choices if empty_allowed or x[0]] class HumintContribution(Form): @@ -39,11 +39,11 @@ class FindOfficerForm(Form): Length(max=10)]) dept = QuerySelectField('dept', validators=[DataRequired()], query_factory=dept_choices, get_label='name') - rank = SelectField('rank', default='COMMANDER', choices=RANK_CHOICES, + rank = SelectField('rank', default='Not Sure', choices=RANK_CHOICES, validators=[AnyOf(allowed_values(RANK_CHOICES))]) - race = SelectField('race', default='WHITE', choices=RACE_CHOICES, + race = SelectField('race', default='Not Sure', choices=RACE_CHOICES, validators=[AnyOf(allowed_values(RACE_CHOICES))]) - gender = SelectField('gender', default='M', choices=GENDER_CHOICES, + gender = SelectField('gender', default='Not Sure', choices=GENDER_CHOICES, validators=[AnyOf(allowed_values(GENDER_CHOICES))]) min_age = IntegerField('min_age', default=16, validators=[ NumberRange(min=16, max=100) @@ -103,6 +103,10 @@ class DepartmentForm(Form): submit = SubmitField(label='Add') +class EditDepartmentForm(DepartmentForm): + submit = SubmitField(label='Update') + + class LinkForm(Form): title = StringField( validators=[Length(max=100, message='Titles are limited to 100 characters.')], @@ -130,15 +134,16 @@ def validate(self): return success -class BaseNoteForm(Form): - note = TextAreaField() +class BaseTextForm(Form): + text_contents = TextAreaField() + description = "This information about the officer will be attributed to your username." -class EditNoteForm(BaseNoteForm): +class EditTextForm(BaseTextForm): submit = SubmitField(label='Submit') -class NoteForm(EditNoteForm): +class TextForm(EditTextForm): officer_id = HiddenField(validators=[Required(message='Not a valid officer ID')]) creator_id = HiddenField(validators=[Required(message='Not a valid user ID')]) @@ -150,12 +155,15 @@ class AddOfficerForm(Form): Regexp('\w*'), Length(max=50), DataRequired()]) middle_initial = StringField('Middle initial', default='', validators=[ Regexp('\w*'), Length(max=50), Optional()]) + suffix = SelectField('Suffix', default='', choices=SUFFIX_CHOICES, + validators=[AnyOf(allowed_values(SUFFIX_CHOICES))]) race = SelectField('Race', default='WHITE', choices=RACE_CHOICES, validators=[AnyOf(allowed_values(RACE_CHOICES))]) gender = SelectField('Gender', default='M', choices=GENDER_CHOICES, validators=[AnyOf(allowed_values(GENDER_CHOICES))]) star_no = StringField('Badge Number', default='', validators=[ Regexp('\w*'), Length(max=50)]) + unique_internal_identifier = StringField('Unique Internal Identifier', default='', validators=[Regexp('\w*'), Length(max=50)]) rank = SelectField('Rank', default='PO', choices=RANK_CHOICES, validators=[AnyOf(allowed_values(RANK_CHOICES))]) unit = QuerySelectField('Unit', validators=[Optional()], @@ -172,11 +180,17 @@ class AddOfficerForm(Form): min_entries=1, widget=BootstrapListWidget()) notes = FieldList(FormField( - BaseNoteForm, + BaseTextForm, widget=FormFieldWidget()), description='This note about the officer will be attributed to your username.', min_entries=1, widget=BootstrapListWidget()) + descriptions = FieldList(FormField( + BaseTextForm, + widget=FormFieldWidget()), + description='This description of the officer will be attributed to your username.', + min_entries=1, + widget=BootstrapListWidget()) submit = SubmitField(label='Add') @@ -191,12 +205,15 @@ class EditOfficerForm(Form): middle_initial = StringField('Middle initial', validators=[Regexp('\w*'), Length(max=50), Optional()]) + suffix = SelectField('Suffix', choices=SUFFIX_CHOICES, + validators=[AnyOf(allowed_values(SUFFIX_CHOICES))]) race = SelectField('Race', choices=RACE_CHOICES, validators=[AnyOf(allowed_values(RACE_CHOICES))]) gender = SelectField('Gender', choices=GENDER_CHOICES, validators=[AnyOf(allowed_values(GENDER_CHOICES))]) employment_date = DateField('Employment Date', validators=[Optional()]) birth_year = IntegerField('Birth Year', validators=[Optional()]) + unique_internal_identifier = StringField('Unique Internal Identifier', default='', validators=[Regexp('\w*'), Length(max=50)]) department = QuerySelectField( 'Department', validators=[Optional()], @@ -222,6 +239,14 @@ class AddUnitForm(Form): submit = SubmitField(label='Add') +class AddImageForm(Form): + department = QuerySelectField( + 'Department', + validators=[Required()], + query_factory=dept_choices, + get_label='name') + + class DateFieldForm(Form): date_field = DateField('Date *', validators=[Required()]) time_field = TimeField('Time', validators=[Optional()]) @@ -252,14 +277,14 @@ def validate_date_field(self, field): class LocationForm(Form): street_name = StringField(validators=[Optional()], description='Street on which incident occurred. For privacy reasons, please DO NOT INCLUDE street number.') - cross_street1 = StringField(validators=[Optional()], description="Closest cross street to where incident occurred.") + cross_street1 = StringField(validators=[Optional()], description='Closest cross street to where incident occurred.') cross_street2 = StringField(validators=[Optional()]) city = StringField('City *', validators=[Required()]) state = SelectField('State *', choices=STATE_CHOICES, - validators=[AnyOf(allowed_values(STATE_CHOICES))]) + validators=[AnyOf(allowed_values(STATE_CHOICES, False), message='Must select a state.')]) zip_code = StringField('Zip Code', validators=[Optional(), - Regexp('^\d{5}$', message='Zip codes must have 5 digits')]) + Regexp('^\d{5}$', message='Zip codes must have 5 digits.')]) class LicensePlateForm(Form): @@ -267,6 +292,10 @@ class LicensePlateForm(Form): state = SelectField('State', choices=STATE_CHOICES, validators=[AnyOf(allowed_values(STATE_CHOICES))]) + def validate_state(self, field): + if self.number.data != '' and field.data == '': + raise ValidationError('Must also select a state.') + class OfficerIdField(StringField): def process_data(self, value): @@ -275,11 +304,24 @@ def process_data(self, value): else: self.data = value - def pre_validate(self, form): - if self.data: - officer = Officer.query.get(int(self.data)) - if not officer: - raise ValueError('Not a valid officer id') + +def validate_oo_id(self, field): + if field.data: + try: + officer_id = int(field.data) + officer = Officer.query.get(officer_id) + + # Sometimes we get a string in field.data with py.test, this parses it + except ValueError: + officer_id = field.data.split("value=\"")[1][:-2] + officer = Officer.query.get(officer_id) + + if not officer: + raise ValidationError('Not a valid officer id') + + +class OOIdForm(Form): + oo_id = StringField('OO Officer ID', validators=[validate_oo_id]) class IncidentForm(DateFieldForm): @@ -293,8 +335,8 @@ class IncidentForm(DateFieldForm): query_factory=dept_choices, get_label='name') address = FormField(LocationForm) - officers = FieldList( - OfficerIdField('OO Officer ID'), + officers = FieldList(FormField( + OOIdForm, widget=FormFieldWidget()), description='Officers present at the incident.', min_entries=1, widget=BootstrapListWidget()) diff --git a/OpenOversight/app/main/views.py b/OpenOversight/app/main/views.py index d8cfda507..b48d00f55 100644 --- a/OpenOversight/app/main/views.py +++ b/OpenOversight/app/main/views.py @@ -9,7 +9,7 @@ from werkzeug import secure_filename from flask import (abort, render_template, request, redirect, url_for, - flash, current_app, jsonify, Markup) + flash, current_app, jsonify) from flask_login import current_user, login_required, login_user from . import main @@ -21,14 +21,16 @@ ac_can_edit_officer, add_department_query, add_unit_query, create_incident, get_or_create, replace_list, set_dynamic_default, create_note, - get_uploaded_cropped_image) + get_uploaded_cropped_image, create_description) from .forms import (FindOfficerForm, FindOfficerIDForm, AddUnitForm, FaceTag, AssignmentForm, DepartmentForm, AddOfficerForm, - EditOfficerForm, IncidentForm, NoteForm, EditNoteForm) + EditOfficerForm, IncidentForm, TextForm, EditTextForm, + AddImageForm, EditDepartmentForm) from .model_view import ModelView from ..models import (db, Image, User, Face, Officer, Assignment, Department, - Unit, Incident, Location, LicensePlate, Link, Note) + Unit, Incident, Location, LicensePlate, Link, Note, + Description) from ..auth.forms import LoginForm from ..auth.utils import admin_required, ac_or_admin_required @@ -49,7 +51,7 @@ def index(): @main.route('/browse', methods=['GET']) def browse(): - departments = Department.query.all() + departments = Department.query.filter(Department.officers.any()) return render_template('browse.html', departments=departments) @@ -148,7 +150,7 @@ def officer_profile(officer_id): )) return render_template('officer.html', officer=officer, paths=face_paths, - assignments=assignments, form=form) + faces=faces, assignments=assignments, form=form) @main.route('/officer//assignment/new', methods=['POST']) @@ -276,7 +278,30 @@ def add_department(): flash('Department {} already exists'.format(form.name.data)) return redirect(url_for('main.get_started_labeling')) else: - return render_template('add_department.html', form=form) + return render_template('add_edit_department.html', form=form) + + +@main.route('/department//edit', methods=['GET', 'POST']) +@login_required +@admin_required +def edit_department(department_id): + department = Department.query.get_or_404(department_id) + previous_name = department.name + form = EditDepartmentForm(obj=department) + if form.validate_on_submit(): + new_name = form.name.data + if new_name != previous_name: + if Department.query.filter_by(name=new_name).count() > 0: + flash('Department {} already exists'.format(new_name)) + return redirect(url_for('main.edit_department', + department_id=department_id)) + department.name = new_name + department.short_name = form.short_name.data + db.session.commit() + flash('Department {} edited'.format(department.name)) + return redirect(url_for('main.list_officer', department_id=department.id)) + else: + return render_template('add_edit_department.html', form=form, update=True) @main.route('/department/') @@ -543,26 +568,20 @@ def submit_complaint(): @main.route('/submit', methods=['GET', 'POST']) @limiter.limit('5/minute') def submit_data(): + preferred_dept_id = Department.query.first().id # try to use preferred department if available try: if User.query.filter_by(id=current_user.id).one().dept_pref: - flash(Markup('Want to submit for another department? Change your default department.')) - department = User.query.filter_by(id=current_user.id).one().dept_pref - return redirect(url_for('main.submit_department_images', department_id=department)) + preferred_dept_id = User.query.filter_by(id=current_user.id).one().dept_pref + form = AddImageForm() else: - departments = Department.query.all() - return render_template('submit_deptselect.html', departments=departments) + form = AddImageForm() + return render_template('submit_image.html', form=form, preferred_dept_id=preferred_dept_id) # that is, an anonymous user has no id attribute except AttributeError: - departments = Department.query.all() - return render_template('submit_deptselect.html', departments=departments) - - -@main.route('/submit/department/', methods=['GET', 'POST']) -@limiter.limit('5/minute') -def submit_department_images(department_id=1): - department = Department.query.filter_by(id=department_id).one() - return render_template('submit_department.html', department=department) + preferred_dept_id = Department.query.first().id + form = AddImageForm() + return render_template('submit_image.html', form=form, preferred_dept_id=preferred_dept_id) @main.route('/upload/department/', methods=['POST']) @@ -661,7 +680,7 @@ def get(self, obj_id): def get_new_form(self): form = self.form() if request.args.get('officer_id'): - form.officers[0].data = request.args.get('officer_id') + form.officers[0].oo_id.data = request.args.get('officer_id') for link in form.links: link.user_id.data = current_user.id @@ -679,6 +698,9 @@ def get_edit_form(self, obj): else: link.user_id.data = current_user.id + for officer_idx, officer in enumerate(obj.officers): + form.officers[officer_idx].oo_id.data = officer.id + # set the form to have fields for all the current model's items form.license_plates.min_entries = no_license_plates form.links.min_entries = no_links @@ -706,9 +728,14 @@ def populate_obj(self, form, obj): officers = form.data.pop('officers') del form.officers if officers: - for officer_id in officers: - if officer_id: - of = Officer.query.filter_by(id=int(officer_id)).first() + for officer in officers: + if officer["oo_id"]: + try: + of = Officer.query.filter_by(id=int(officer["oo_id"])).first() + # Sometimes we get a string in officer["oo_id"], this parses it + except ValueError: + our_id = officer["oo_id"].split("value=\"")[1][:-2] + of = Officer.query.filter_by(id=int(our_id)).first() if of: obj.officers.append(of) @@ -745,14 +772,11 @@ def populate_obj(self, form, obj): methods=['GET', 'POST']) -class NoteApi(ModelView): - model = Note - model_name = 'note' +class TextApi(ModelView): order_by = 'date_created' descending = True - form = NoteForm - create_function = create_note department_check = True + form = TextForm def get_new_form(self): form = self.form() @@ -765,22 +789,41 @@ def get_redirect_url(self, *args, **kwargs): def get_post_delete_url(self, *args, **kwargs): return self.get_redirect_url() - def get_edit_form(self, obj): - form = EditNoteForm(obj=obj) - return form - def get_department_id(self, obj): return self.department_id + def get_edit_form(self, obj): + form = EditTextForm(obj=obj) + return form + def dispatch_request(self, *args, **kwargs): if 'officer_id' in kwargs: officer = Officer.query.get_or_404(kwargs['officer_id']) self.officer_id = kwargs.pop('officer_id') self.department_id = officer.department_id + return super(TextApi, self).dispatch_request(*args, **kwargs) + + +class NoteApi(TextApi): + model = Note + model_name = 'note' + form = TextForm + create_function = create_note + def dispatch_request(self, *args, **kwargs): return super(NoteApi, self).dispatch_request(*args, **kwargs) +class DescriptionApi(TextApi): + model = Description + model_name = 'description' + form = TextForm + create_function = create_description + + def dispatch_request(self, *args, **kwargs): + return super(DescriptionApi, self).dispatch_request(*args, **kwargs) + + note_view = NoteApi.as_view('note_api') main.add_url_rule( '/officer//note/new', @@ -798,3 +841,21 @@ def dispatch_request(self, *args, **kwargs): '/officer//note//delete', view_func=note_view, methods=['GET', 'POST']) + +description_view = DescriptionApi.as_view('description_api') +main.add_url_rule( + '/officer//description/new', + view_func=description_view, + methods=['GET', 'POST']) +main.add_url_rule( + '/officer//description/', + view_func=description_view, + methods=['GET']) +main.add_url_rule( + '/officer//description//edit', + view_func=description_view, + methods=['GET', 'POST']) +main.add_url_rule( + '/officer//description//delete', + view_func=description_view, + methods=['GET', 'POST']) diff --git a/OpenOversight/app/models.py b/OpenOversight/app/models.py index ea684c854..c14726f2f 100644 --- a/OpenOversight/app/models.py +++ b/OpenOversight/app/models.py @@ -37,7 +37,7 @@ class Note(db.Model): __tablename__ = 'notes' id = db.Column(db.Integer, primary_key=True) - note = db.Column(db.Text()) + text_contents = db.Column(db.Text()) creator_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL')) creator = db.relationship('User', backref='notes') officer_id = db.Column(db.Integer, db.ForeignKey('officers.id', ondelete='CASCADE')) @@ -46,6 +46,19 @@ class Note(db.Model): date_updated = db.Column(db.DateTime) +class Description(db.Model): + __tablename__ = 'descriptions' + + creator = db.relationship('User', backref='descriptions') + officer = db.relationship('Officer', back_populates='descriptions') + id = db.Column(db.Integer, primary_key=True) + text_contents = db.Column(db.Text()) + creator_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL')) + officer_id = db.Column(db.Integer, db.ForeignKey('officers.id', ondelete='CASCADE')) + date_created = db.Column(db.DateTime) + date_updated = db.Column(db.DateTime) + + class Officer(db.Model): __tablename__ = 'officers' @@ -53,14 +66,16 @@ class Officer(db.Model): last_name = db.Column(db.String(120), index=True, unique=False) first_name = db.Column(db.String(120), index=True, unique=False) middle_initial = db.Column(db.String(120), unique=False, nullable=True) + suffix = db.Column(db.String(120), index=True, unique=False) race = db.Column(db.String(120), index=True, unique=False) gender = db.Column(db.String(120), index=True, unique=False) - employment_date = db.Column(db.DateTime, index=True, unique=False, nullable=True) + employment_date = db.Column(db.Date, index=True, unique=False, nullable=True) birth_year = db.Column(db.Integer, index=True, unique=False, nullable=True) assignments = db.relationship('Assignment', backref='officer', lazy='dynamic') face = db.relationship('Face', backref='officer', lazy='dynamic') department_id = db.Column(db.Integer, db.ForeignKey('departments.id')) department = db.relationship('Department', backref='officers') + unique_internal_identifier = db.Column(db.String(50), index=True, unique=True, nullable=True) # we don't expect to pull up officers via link often so we make it lazy. links = db.relationship( 'Link', @@ -68,17 +83,24 @@ class Officer(db.Model): lazy='subquery', backref=db.backref('officers', lazy=True)) notes = db.relationship('Note', back_populates='officer', order_by='Note.date_created') + descriptions = db.relationship('Description', back_populates='officer', order_by='Description.date_created') def full_name(self): if self.middle_initial: - return '{} {}. {}'.format(self.first_name, self.middle_initial, self.last_name) + if self.suffix: + return '{} {}. {} {}'.format(self.first_name, self.middle_initial, self.last_name, self.suffix) + else: + return '{} {}. {}'.format(self.first_name, self.middle_initial, self.last_name) + if self.suffix: + return '{} {} {}'.format(self.first_name, self.last_name, self.suffix) return '{} {}'.format(self.first_name, self.last_name) def __repr__(self): - return ''.format(self.id, - self.first_name, - self.middle_initial, - self.last_name) + return ''.format(self.id, + self.first_name, + self.middle_initial, + self.last_name, + self.suffix) class Assignment(db.Model): @@ -90,8 +112,8 @@ class Assignment(db.Model): star_no = db.Column(db.String(120), index=True, unique=False) rank = db.Column(db.String(120), index=True, unique=False) unit = db.Column(db.Integer, db.ForeignKey('unit_types.id'), nullable=True) - star_date = db.Column(db.DateTime, index=True, unique=False, nullable=True) - resign_date = db.Column(db.DateTime, index=True, unique=False, nullable=True) + star_date = db.Column(db.Date, index=True, unique=False, nullable=True) + resign_date = db.Column(db.Date, index=True, unique=False, nullable=True) def __repr__(self): return ''.format(self.officer_id, diff --git a/OpenOversight/app/static/js/dropzone.js b/OpenOversight/app/static/js/dropzone.js index 895b055a8..f9ba2ddd0 100644 --- a/OpenOversight/app/static/js/dropzone.js +++ b/OpenOversight/app/static/js/dropzone.js @@ -424,7 +424,7 @@ throw new Error("Invalid dropzone element."); } if (this.element.dropzone) { - throw new Error("Dropzone already attached."); + return this.element.dropzone; } Dropzone.instances.push(this); this.element.dropzone = this; diff --git a/OpenOversight/app/static/js/incidentAddButtons.js b/OpenOversight/app/static/js/incidentAddButtons.js index 47b8ea0c1..840c1ce3f 100644 --- a/OpenOversight/app/static/js/incidentAddButtons.js +++ b/OpenOversight/app/static/js/incidentAddButtons.js @@ -44,13 +44,12 @@ function cloneFieldList(selector) { function removeParent(event) { event.preventDefault() + var things_to_add; + things_to_add = {"Plate Number" : "license plate", "Link" : "link", "OO Officer ID" : "officer"}; var previousElement = event.target.parentElement.previousElementSibling var nextElement = event.target.parentElement.nextElementSibling - // If it's between the legend and the add button, it's the last remaining fieldset, and needs different handling - if(previousElement && - previousElement.tagName === 'LEGEND' && - nextElement && - nextElement.tagName === 'BUTTON'){ + + if(previousElement && nextElement){ var $lastElement = $(event.target.parentElement) // Remove any filled in values (but not the csrf token) $lastElement.find(':input:not(:hidden)').each(function(child) { @@ -59,21 +58,37 @@ function removeParent(event) { $lastElement.hide() var add_button = $(nextElement) var fieldsetName = $(previousElement).text().slice(0, -1) + for (var key in things_to_add) { + if(fieldsetName.search(key) != -1) { + fieldsetName = things_to_add[key] + break; + } + } - // Remove previous click handler - add_button.off('click') - add_button.text('New ' + fieldsetName) - add_button.on('click', function(event) { - event.preventDefault() - $lastElement.show() - // remove this click handler - add_button.off('click') - add_button.text('Add another ' + fieldsetName) - // restore the previous add function - add_button.click(function (event) { - event.preventDefault() - cloneFieldList($(event.target.previousElementSibling)); - }); - }) - } + // nextElement's textContent is short, like + // "Add another link" when we're removing the last element added + // When we are removing something that is not the + // last element added, it is huge (the whole input form) + // with lots of whitespace. + // If we're not removing the last element added, + // we already have a valid Add button so we don't + // want to create another + if (nextElement.textContent.length <= 40) { + // Remove previous click handler + add_button.off('click') + add_button.text('Add another ' + fieldsetName) + add_button.on('click', function(event) { + event.preventDefault() + $lastElement.show() + // remove this click handler + add_button.off('click') + add_button.text('Add another ' + fieldsetName) + // restore the previous add function + add_button.click(function (event) { + event.preventDefault() + cloneFieldList($(event.target.previousElementSibling)); + }); + }) + } + } } diff --git a/OpenOversight/app/templates/add_department.html b/OpenOversight/app/templates/add_edit_department.html similarity index 75% rename from OpenOversight/app/templates/add_department.html rename to OpenOversight/app/templates/add_edit_department.html index 06e314781..b345bb531 100644 --- a/OpenOversight/app/templates/add_department.html +++ b/OpenOversight/app/templates/add_edit_department.html @@ -1,12 +1,12 @@ {% extends "base.html" %} {% import "bootstrap/wtf.html" as wtf %} -{% block title %}OpenOversight Admin - Add Department{% endblock %} +{% block title %}OpenOversight Admin - {% if update %} Update {% else %} Add {% endif %} Department{% endblock %} {% block content %}
diff --git a/OpenOversight/app/templates/add_officer.html b/OpenOversight/app/templates/add_officer.html index 0db1f7dc9..3adb0f940 100644 --- a/OpenOversight/app/templates/add_officer.html +++ b/OpenOversight/app/templates/add_officer.html @@ -15,9 +15,11 @@

Add Officer

{{ wtf.form_field(form.first_name, autofocus="autofocus") }} {{ wtf.form_field(form.middle_initial) }} {{ wtf.form_field(form.last_name) }} + {{ wtf.form_field(form.suffix) }} {{ wtf.form_field(form.race) }} {{ wtf.form_field(form.gender) }} {{ wtf.form_field(form.star_no) }} + {{ wtf.form_field(form.unique_internal_identifier) }} {{ wtf.form_field(form.rank) }} {{ wtf.form_field(form.unit) }}

Don't see your unit? Add one!

@@ -32,6 +34,13 @@

Don't see your unit? Add on {% endfor %}

+
+ {{ form.descriptions.label }} + {% for subform in form.descriptions %} + {% include "partials/subform.html" %} + {% endfor %} + +
{{ wtf.form_field(form.submit, id="submit", button_map={'submit':'primary'}) }}
diff --git a/OpenOversight/app/templates/base.html b/OpenOversight/app/templates/base.html index 3f9d6e393..ec622a02b 100644 --- a/OpenOversight/app/templates/base.html +++ b/OpenOversight/app/templates/base.html @@ -96,7 +96,7 @@
-
+
OpenOversight

A product of Lucy Parsons Labs in Chicago, IL.
@@ -105,7 +105,7 @@

OpenOversight

-
+
Contact

@@ -115,7 +115,7 @@

Contact
Privacy Policy

-
+ diff --git a/OpenOversight/app/templates/description_delete.html b/OpenOversight/app/templates/description_delete.html new file mode 100644 index 000000000..1a33ff981 --- /dev/null +++ b/OpenOversight/app/templates/description_delete.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} + +{% block content %} +
+ + +

+ Are you sure you want to delete this description? + This cannot be undone. +

+ +
+

+
+{% endblock content %} diff --git a/OpenOversight/app/templates/description_edit.html b/OpenOversight/app/templates/description_edit.html new file mode 100644 index 000000000..dc4aea945 --- /dev/null +++ b/OpenOversight/app/templates/description_edit.html @@ -0,0 +1,18 @@ +{% extends "form.html" %} +{% import "bootstrap/wtf.html" as wtf %} + + +{% block page_title %} + Update Description +{% endblock page_title %} + + +{% block form %} + {% if form.errors %} + {% set post_url=url_for('main.description_api', officer_id=obj.officer_id, obj_id=obj.id) %} + {% else %} + {% set post_url="{}/edit".format(url_for('main.description_api', officer_id=obj.officer_id, obj_id=obj.id)) %} + {% endif %} + {{ wtf.quick_form(form, action=post_url, method='post', button_map={'submit':'primary'}) }} +
+{% endblock form %} diff --git a/OpenOversight/app/templates/description_new.html b/OpenOversight/app/templates/description_new.html new file mode 100644 index 000000000..f74dec3f5 --- /dev/null +++ b/OpenOversight/app/templates/description_new.html @@ -0,0 +1,14 @@ +{% extends 'form.html' %} + +{% block page_title %} + New Description +{% endblock page_title %} + +{% block form %} +

For officer with OOID {{ form.officer_id.data }}.
{{form.description}}

+ {{ super() }} +{% endblock form %} + +{% block js_footer %} + +{% endblock %} diff --git a/OpenOversight/app/templates/edit_officer.html b/OpenOversight/app/templates/edit_officer.html index c268be541..a64d62f1f 100644 --- a/OpenOversight/app/templates/edit_officer.html +++ b/OpenOversight/app/templates/edit_officer.html @@ -14,11 +14,13 @@

Edit Officer

{{ wtf.form_errors(form, hiddens="only") }} {{ wtf.form_field(form.first_name, autofocus="autofocus") }} {{ wtf.form_field(form.middle_initial) }} + {{ wtf.form_field(form.suffix) }} {{ wtf.form_field(form.last_name) }} {{ wtf.form_field(form.race) }} {{ wtf.form_field(form.gender) }} {{ wtf.form_field(form.employment_date) }} {{ wtf.form_field(form.birth_year) }} + {{ wtf.form_field(form.unique_internal_identifier) }} {{ wtf.form_field(form.department) }} {% include "partials/links_subform.html" %} {{ wtf.form_field(form.submit, id="submit", button_map={'submit':'primary'}) }} diff --git a/OpenOversight/app/templates/gallery.html b/OpenOversight/app/templates/gallery.html index ef3956351..61d8ca280 100644 --- a/OpenOversight/app/templates/gallery.html +++ b/OpenOversight/app/templates/gallery.html @@ -37,9 +37,7 @@

Digital Gallery Do you see the officer here?

@@ -50,6 +48,7 @@

That's the officer! {% endif %} diff --git a/OpenOversight/app/templates/list_officer.html b/OpenOversight/app/templates/list_officer.html index 388dc2307..9cd0e8a83 100644 --- a/OpenOversight/app/templates/list_officer.html +++ b/OpenOversight/app/templates/list_officer.html @@ -39,9 +39,9 @@

Rank
-
{{ officer.rank|default('Unknown') }}
+
{{ assignment.rank|default('Unknown') }}
Race
-
{{ officer.race.lower()|title|default('Unknown') }}
+
{{ officer.race|default('Unknown')|lower|title }}
diff --git a/OpenOversight/app/templates/note_new.html b/OpenOversight/app/templates/note_new.html index 1c6b479e9..cf21b405f 100644 --- a/OpenOversight/app/templates/note_new.html +++ b/OpenOversight/app/templates/note_new.html @@ -5,7 +5,7 @@ {% endblock page_title %} {% block form %} -

For officer with OOID {{ form.officer_id.data }}

+

For officer with OOID {{ form.officer_id.data }}.
{{form.description}}

{{ super() }} {% endblock form %} diff --git a/OpenOversight/app/templates/officer.html b/OpenOversight/app/templates/officer.html index 6a5dcfd20..73e851ea1 100644 --- a/OpenOversight/app/templates/officer.html +++ b/OpenOversight/app/templates/officer.html @@ -4,17 +4,21 @@
{% for path in paths %} + {% if current_user.is_administrator + or (current_user.is_area_coordinator and current_user.ac_department_id == officer.department_id) %} + + {% endif %} Submission + {% if current_user.is_administrator + or (current_user.is_area_coordinator and current_user.ac_department_id == officer.department_id) %} + + {% endif %} {% endfor %}
@@ -34,6 +38,10 @@

General Information OpenOversight ID {{ officer.id }} + + Unique Internal Identifier + {{ officer.unique_internal_identifier }} + Department {{ officer.department.name }} @@ -190,6 +198,41 @@

{% endif %}

{# end col #} {% endif %} +
+ {% if officer.descriptions %} +

Descriptions

+ {% endif %} +
    + {% for description in officer.descriptions %} +
  • + {{ description.date_updated.strftime('%b %d, %Y')}}
    + {{ description.text_contents }}
    + {{ description.creator.username }} + {% if description.creator_id == current_user.id or current_user.is_administrator %} + + Edit + + + + Delete + + + + {% endif %} +
  • + {% endfor %} +
+ {% if current_user.is_administrator + or (current_user.is_area_coordinator and current_user.ac_department_id == officer.department_id) %} + {% if not officer.descriptions %} +

Descriptions

+ {% endif %} + New description +
+ {% endif %} +
{# end col #} {% if current_user.is_administrator or (current_user.is_area_coordinator and current_user.ac_department_id == officer.department_id) %}
@@ -198,7 +241,7 @@

Notes

{% for note in officer.notes %}
  • {{ note.date_updated.strftime('%b %d, %Y')}}
    - {{ note.note }}
    + {{ note.text_contents }}
    {{ note.creator.username }} {% if note.creator_id == current_user.id or current_user.is_administrator %} Add another license plate
  • -
    - Officers Involved -
      - {% for field in form.officers %} -
    • - {{ wtf.form_field(field) }} -
    • - {% endfor %} - -
    -
    + {{ form.officers.label }} + {% for subform in form.officers %} + {% with id="js-officer", number=loop.index %} + {% include "partials/subform.html" %} + {% endwith %} + {% endfor %} +
    {{ form.links.label }} {% for subform in form.links %} diff --git a/OpenOversight/app/templates/partials/officer_name.html b/OpenOversight/app/templates/partials/officer_name.html index a98e005fd..2b57058a4 100644 --- a/OpenOversight/app/templates/partials/officer_name.html +++ b/OpenOversight/app/templates/partials/officer_name.html @@ -1,3 +1,4 @@ {{ officer.first_name.lower()|title }} -{% if officer.middle_initial %}{{ officer.middle_initial }}. {% endif %} -{{ officer.last_name.lower()|title }} +{% if officer.middle_initial %}{{ officer.middle_initial }}{% if officer.middle_initial|length == 1 %}.{% endif %} {% endif %} +{{ officer.last_name|capfirst }} +{% if officer.suffix %}{{ officer.suffix }}. {% endif %} diff --git a/OpenOversight/app/templates/partials/paginate_nav.html b/OpenOversight/app/templates/partials/paginate_nav.html index a99af5a38..b8ebd87e1 100644 --- a/OpenOversight/app/templates/partials/paginate_nav.html +++ b/OpenOversight/app/templates/partials/paginate_nav.html @@ -9,12 +9,15 @@ {% endif %} {% if paginate.has_next %} + Showing {{(paginate.page-1)*paginate.per_page + 1 }}-{{(paginate.page)*paginate.per_page}} of {{paginate.total}} + {% else %} + Showing {{(paginate.page-1)*paginate.per_page + 1 }}-{{paginate.total}} of {{paginate.total}} {% endif %} diff --git a/OpenOversight/app/templates/submit_department.html b/OpenOversight/app/templates/submit_department.html deleted file mode 100644 index a20919305..000000000 --- a/OpenOversight/app/templates/submit_department.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "base.html" %} - -{% block head %} - - -{% endblock %} - -{% block content %} -
    - - - -
    -

    What happens when I submit a photograph?

    -

    The next step after a photograph of an officer has been submitted is to match it to the correct badge number, name, and OpenOversight ID (a unique identifier in our system). Volunteers sort through submitted images by first confirming that officers are present in each photograph, and then by matching each photograph to the officer it depicts.

    -
    - -

    Drop images here to submit photos of officers in {{ department.name }}:

    - -
    -
    -

    Drag photographs from your computer directly into the box above or click the box to launch a finder window. If you are on mobile, you can click the box above to select pictures from your photo library or camera roll.

    - - -
    - -
    -

    High Security Submissions

    -

    We do not log unique identifying information of visitors to our website, but if you have privacy concerns in submitting photographs, we recommend using Tor Browser. For very high security submissions of photos or videos, you can use an anonymous dropbox called SecureDrop (launch instructions below). All files that we receive through SecureDrop are scrubbed of metadata.

    - Launch SecureDrop Instructions -
    - - - - -{% endblock %} diff --git a/OpenOversight/app/templates/submit_deptselect.html b/OpenOversight/app/templates/submit_deptselect.html deleted file mode 100644 index 082a7058c..000000000 --- a/OpenOversight/app/templates/submit_deptselect.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html" %} - - -{% block head %} - - -{% endblock %} - -{% block content %} - -
    - -
    -

    Submit images of officers in action in:

    - {% for department in departments %} -

    - - - {{ department.name }} -

    - {% endfor %} -
    - -
    - -{% endblock %} diff --git a/OpenOversight/app/templates/submit_image.html b/OpenOversight/app/templates/submit_image.html new file mode 100644 index 000000000..286e18734 --- /dev/null +++ b/OpenOversight/app/templates/submit_image.html @@ -0,0 +1,79 @@ +{% extends "base.html" %} +{% import "bootstrap/wtf.html" as wtf %}¬ + +{% block head %} + + +{% endblock %} + +{% block content %} +
    + + + +
    +

    What happens when I submit a photograph?

    +

    The next step after a photograph of an officer has been submitted is to match it to the correct badge number, name, and OpenOversight ID (a unique identifier in our system). Volunteers sort through submitted images by first confirming that officers are present in each photograph, and then by matching each photograph to the officer it depicts.

    +
    +

    Select the department that the police officer in your image belongs to:

    +
    +
    + {{ wtf.form_field(form.department) }} +
    +
    +
    + +

    Drop images here to submit photos of officers:

    + +
    +
    +

    Drag photographs from your computer directly into the box above or click the box to launch a finder window. If you are on mobile, you can click the box above to select pictures from your photo library or camera roll.

    + + + + + +
    + +
    +

    High Security Submissions

    +

    We do not log unique identifying information of visitors to our website, but if you have privacy concerns in submitting photographs, we recommend using Tor Browser. For very high security submissions of photos or videos, you can use an anonymous dropbox called SecureDrop (launch instructions below). All files that we receive through SecureDrop are scrubbed of metadata.

    + Launch SecureDrop Instructions +
    + +{% endblock %} diff --git a/OpenOversight/app/templates/tagger_gallery.html b/OpenOversight/app/templates/tagger_gallery.html index 7bf3bf6b9..580350695 100644 --- a/OpenOversight/app/templates/tagger_gallery.html +++ b/OpenOversight/app/templates/tagger_gallery.html @@ -36,9 +36,7 @@

    Matching Officers

    OpenOversight ID: {{ officer.id }}

    Race: {{ officer.race }}
    Gender: {{ officer.gender }}
    diff --git a/OpenOversight/app/utils.py b/OpenOversight/app/utils.py index e10451798..4d7c9927c 100644 --- a/OpenOversight/app/utils.py +++ b/OpenOversight/app/utils.py @@ -16,7 +16,7 @@ from PIL import Image as Pimage from .models import (db, Officer, Assignment, Image, Face, User, Unit, Department, - Incident, Location, LicensePlate, Link, Note) + Incident, Location, LicensePlate, Link, Note, Description) def set_dynamic_default(form_field, value): @@ -31,6 +31,9 @@ def set_dynamic_default(form_field, value): def get_or_create(session, model, defaults=None, **kwargs): if 'csrf_token' in kwargs: kwargs.pop('csrf_token') + # Because id is a keyword in Python, officers member is called oo_id + if 'oo_id' in kwargs: + kwargs = {'id': kwargs['oo_id']} instance = model.query.filter_by(**kwargs).first() if instance: return instance, False @@ -86,6 +89,7 @@ def add_officer_profile(form, current_user): officer = Officer(first_name=form.first_name.data, last_name=form.last_name.data, middle_initial=form.middle_initial.data, + suffix=form.suffix.data, race=form.race.data, gender=form.gender.data, birth_year=form.birth_year.data, @@ -115,14 +119,25 @@ def add_officer_profile(form, current_user): if form.notes.data: for note in form.data['notes']: # don't try to create with a blank string - if note['note']: + if note['text_contents']: new_note = Note( - note=note['note'], + note=note['text_contents'], user_id=current_user.id, officer=officer, date_created=datetime.datetime.now(), date_updated=datetime.datetime.now()) db.session.add(new_note) + if form.descriptions.data: + for description in form.data['descriptions']: + # don't try to create with a blank string + if description['text_contents']: + new_description = description( + description=description['text_contents'], + user_id=current_user.id, + officer=officer, + date_created=datetime.datetime.now(), + date_updated=datetime.datetime.now()) + db.session.add(new_description) db.session.commit() return officer @@ -341,9 +356,9 @@ def create_incident(self, form): fields['address'] = address if 'officers' in form.data: - for officer_id in form.data['officers']: - if officer_id: - of = Officer.query.filter_by(id=int(officer_id)).first() + for officer in form.data['officers']: + if officer['oo_id']: + of, _ = get_or_create(db.session, Officer, **officer) if of: fields['officers'].append(of) @@ -375,7 +390,16 @@ def create_incident(self, form): def create_note(self, form): return Note( - note=form.note.data, + text_contents=form.text_contents.data, + creator_id=form.creator_id.data, + officer_id=form.officer_id.data, + date_created=datetime.datetime.now(), + date_updated=datetime.datetime.now()) + + +def create_description(self, form): + return Description( + text_contents=form.text_contents.data, creator_id=form.creator_id.data, officer_id=form.officer_id.data, date_created=datetime.datetime.now(), diff --git a/OpenOversight/manage.py b/OpenOversight/manage.py index 4123ca34a..72db1ea7e 100644 --- a/OpenOversight/manage.py +++ b/OpenOversight/manage.py @@ -1,7 +1,7 @@ from getpass import getpass import sys -from flask_script import Manager, Server, Shell +from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand from app import app @@ -10,7 +10,6 @@ migrate = Migrate(app, db) manager = Manager(app) -manager.add_command("runserver", Server(host="0.0.0.0", port=3000)) manager.add_command("db", MigrateCommand) diff --git a/OpenOversight/migrations/versions/0acbb0f0b1ef_.py b/OpenOversight/migrations/versions/0acbb0f0b1ef_.py new file mode 100644 index 000000000..24031c411 --- /dev/null +++ b/OpenOversight/migrations/versions/0acbb0f0b1ef_.py @@ -0,0 +1,50 @@ +"""empty message + +Revision ID: 0acbb0f0b1ef +Revises: af933dc1ef93 +Create Date: 2018-05-03 15:00:36.849627 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '0acbb0f0b1ef' +down_revision = '0ed957db0058' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('assignments', 'resign_date', + existing_type=postgresql.TIMESTAMP(), + type_=sa.Date(), + existing_nullable=True) + op.alter_column('assignments', 'star_date', + existing_type=postgresql.TIMESTAMP(), + type_=sa.Date(), + existing_nullable=True) + op.alter_column('officers', 'employment_date', + existing_type=postgresql.TIMESTAMP(), + type_=sa.Date(), + existing_nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('officers', 'employment_date', + existing_type=sa.Date(), + type_=postgresql.TIMESTAMP(), + existing_nullable=True) + op.alter_column('assignments', 'star_date', + existing_type=sa.Date(), + type_=postgresql.TIMESTAMP(), + existing_nullable=True) + op.alter_column('assignments', 'resign_date', + existing_type=sa.Date(), + type_=postgresql.TIMESTAMP(), + existing_nullable=True) + # ### end Alembic commands ### diff --git a/OpenOversight/migrations/versions/0ed957db0058_add_description_to_officers.py b/OpenOversight/migrations/versions/0ed957db0058_add_description_to_officers.py new file mode 100644 index 000000000..d4f842f98 --- /dev/null +++ b/OpenOversight/migrations/versions/0ed957db0058_add_description_to_officers.py @@ -0,0 +1,40 @@ +"""empty message + +Revision ID: 0ed957db0058 +Revises: 7bb53dee8ac9 +Create Date: 2018-08-11 20:31:02.265231 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '0ed957db0058' +down_revision = '2c27bfebe66e' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('descriptions', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('text_contents', sa.Text(), nullable=True), + sa.Column('creator_id', sa.Integer(), nullable=True), + sa.Column('officer_id', sa.Integer(), nullable=True), + sa.Column('date_created', sa.DateTime(), nullable=True), + sa.Column('date_updated', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['users.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['officer_id'], ['officers.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.alter_column('notes', 'note', new_column_name='text_contents') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('notes', 'text_contents', new_column_name='note') + op.drop_table('descriptions') + # ### end Alembic commands ### diff --git a/OpenOversight/migrations/versions/2c27bfebe66e_add_unique_internal_identifier_to_.py b/OpenOversight/migrations/versions/2c27bfebe66e_add_unique_internal_identifier_to_.py new file mode 100644 index 000000000..8b20845b8 --- /dev/null +++ b/OpenOversight/migrations/versions/2c27bfebe66e_add_unique_internal_identifier_to_.py @@ -0,0 +1,30 @@ +"""Add unique_internal_identifier to officers table + +Revision ID: 2c27bfebe66e +Revises: 7bb53dee8ac9 +Create Date: 2018-08-18 13:36:00.987327 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2c27bfebe66e' +down_revision = '7bb53dee8ac9' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('officers', sa.Column('unique_internal_identifier', sa.String(length=50), nullable=True)) + op.create_index(op.f('ix_officers_unique_internal_identifier'), 'officers', ['unique_internal_identifier'], unique=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_officers_unique_internal_identifier'), table_name='officers') + op.drop_column('officers', 'unique_internal_identifier') + # ### end Alembic commands ### diff --git a/OpenOversight/migrations/versions/7bb53dee8ac9_add_suffix_column_to_officers.py b/OpenOversight/migrations/versions/7bb53dee8ac9_add_suffix_column_to_officers.py new file mode 100644 index 000000000..8c6cf1ffa --- /dev/null +++ b/OpenOversight/migrations/versions/7bb53dee8ac9_add_suffix_column_to_officers.py @@ -0,0 +1,30 @@ +"""Add suffix column to officers + +Revision ID: 7bb53dee8ac9 +Revises: 59e9993c169c +Create Date: 2018-07-26 18:36:10.061968 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7bb53dee8ac9' +down_revision = '59e9993c169c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('officers', sa.Column('suffix', sa.String(length=120), nullable=True)) + op.create_index(op.f('ix_officers_suffix'), 'officers', ['suffix'], unique=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_officers_suffix'), table_name='officers') + op.drop_column('officers', 'suffix') + # ### end Alembic commands ### diff --git a/OpenOversight/tests/conftest.py b/OpenOversight/tests/conftest.py index d4bd9daba..2740b7055 100644 --- a/OpenOversight/tests/conftest.py +++ b/OpenOversight/tests/conftest.py @@ -87,7 +87,12 @@ def build_assignment(officer, unit): def build_note(officer, user): date = factory.date_time_this_year() - return models.Note(note=factory.text(), officer_id=officer.id, creator_id=user.id, date_created=date, date_updated=date) + return models.Note(text_contents=factory.text(), officer_id=officer.id, creator_id=user.id, date_created=date, date_updated=date) + + +def build_description(officer, user): + date = factory.date_time_this_year() + return models.Description(text_contents=factory.text(), officer_id=officer.id, creator_id=user.id, date_created=date, date_updated=date) def assign_faces(officer, images): @@ -305,6 +310,19 @@ def mockdata(session, request): session.commit() + users_that_can_create_descriptions = [test_admin, test_area_coordinator] + + # for testing routes + first_officer = models.Officer.query.get(1) + description = build_description(first_officer, test_admin) + session.add(description) + for officer in models.Officer.query.limit(20): + user = random.choice(users_that_can_create_descriptions) + description = build_description(officer, user) + session.add(description) + + session.commit() + def teardown(): # Cleanup tables models.User.query.delete() diff --git a/OpenOversight/tests/routes/test_descriptions.py b/OpenOversight/tests/routes/test_descriptions.py new file mode 100644 index 000000000..5462c7b3c --- /dev/null +++ b/OpenOversight/tests/routes/test_descriptions.py @@ -0,0 +1,435 @@ +import pytest +from datetime import datetime +from flask import url_for, current_app +from OpenOversight.tests.conftest import AC_DEPT +from .route_helpers import login_user, login_admin, login_ac + + +from OpenOversight.app.main.forms import TextForm, EditTextForm +from OpenOversight.app.models import db, Officer, Description, User + + +@pytest.mark.parametrize("route", [ + ('officer/1/description/1/edit'), + ('officer/1/description/new'), + ('officer/1/description/1/delete') +]) +def test_route_login_required(route, client, mockdata): + rv = client.get(route) + assert rv.status_code == 302 + + +@pytest.mark.parametrize("route", [ + ('officer/1/description/1/edit'), + ('officer/1/description/new'), + ('officer/1/description/1/delete') +]) +def test_route_admin_or_required(route, client, mockdata): + with current_app.test_request_context(): + login_user(client) + rv = client.get(route) + assert rv.status_code == 403 + + +def test_admins_can_create_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + officer = Officer.query.first() + text_contents = 'I can haz descriptionz' + admin = User.query.filter_by(email='jen@example.org').first() + form = TextForm( + text_contents=text_contents, + officer_id=officer.id, + creator_id=admin.id + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id), + data=form.data, + follow_redirects=True + ) + + assert rv.status_code == 200 + assert 'created' in rv.data + + created_description = Description.query.filter_by(text_contents=text_contents).first() + assert created_description is not None + assert created_description.date_created is not None + + +def test_acs_can_create_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.first() + description = 'A description' + ac = User.query.filter_by(email='raq929@example.org').first() + form = TextForm( + text_contents=description, + officer_id=officer.id, + creator_id=ac.id + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id), + data=form.data, + follow_redirects=True + ) + + assert rv.status_code == 200 + assert 'created' in rv.data + + created_description = Description.query.filter_by(text_contents=description).first() + assert created_description is not None + assert created_description.date_created is not None + + +def test_admins_can_edit_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + officer = Officer.query.first() + old_description = 'meow' + new_description = 'I can haz editing descriptionz' + original_date = datetime.now() + description = Description( + text_contents=old_description, + officer_id=officer.id, + creator_id=1, + date_created=original_date, + date_updated=original_date, + ) + db.session.add(description) + db.session.commit() + + form = EditTextForm( + text_contents=new_description, + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/edit', + data=form.data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'updated' in rv.data + + assert description.text_contents == new_description + assert description.date_updated > original_date + + +def test_ac_can_edit_their_descriptions_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + ac = User.query.filter_by(email='raq929@example.org').first() + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + old_description = 'meow' + new_description = 'I can haz editing descriptionz' + original_date = datetime.now() + description = Description( + text_contents=old_description, + officer_id=officer.id, + creator_id=ac.id, + date_created=original_date, + date_updated=original_date, + ) + db.session.add(description) + db.session.commit() + + form = EditTextForm( + text_contents=new_description, + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/edit', + data=form.data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'updated' in rv.data + + assert description.text_contents == new_description + assert description.date_updated > original_date + + +def test_ac_can_edit_others_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + ac = User.query.filter_by(email='raq929@example.org').first() + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + old_description = 'meow' + new_description = 'I can haz editing descriptionz' + original_date = datetime.now() + description = Description( + text_contents=old_description, + officer_id=officer.id, + creator_id=ac.id - 1, + date_created=original_date, + date_updated=original_date, + ) + db.session.add(description) + db.session.commit() + + form = EditTextForm( + text_contents=new_description, + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/edit', + data=form.data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'updated' in rv.data + + assert description.text_contents == new_description + assert description.date_updated > original_date + + +def test_ac_cannot_edit_descriptions_not_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + + officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() + ac = User.query.filter_by(email='raq929@example.org').first() + old_description = 'meow' + new_description = 'I can haz editing descriptionz' + original_date = datetime.now() + description = Description( + text_contents=old_description, + officer_id=officer.id, + creator_id=ac.id, + date_created=original_date, + date_updated=original_date, + ) + db.session.add(description) + db.session.commit() + + form = EditTextForm( + text_contents=new_description, + ) + + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/edit', + data=form.data, + follow_redirects=True + ) + assert rv.status_code == 403 + + +def test_admins_can_delete_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + description = Description.query.first() + description_id = description.id + rv = client.post( + url_for('main.description_api', officer_id=description.officer_id, obj_id=description_id) + '/delete', + follow_redirects=True + ) + assert rv.status_code == 200 + deleted = Description.query.get(description_id) + assert deleted is None + + +def test_acs_can_delete_their_descriptions_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + ac = User.query.filter_by(email='raq929@example.org').first() + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + description = Description( + text_contents='Hello', + officer_id=officer.id, + creator_id=ac.id, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + description_id = description.id + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/delete', + follow_redirects=True + ) + assert rv.status_code == 200 + deleted = Description.query.get(description_id) + assert deleted is None + + +def test_acs_cannot_delete_descriptions_not_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() + description = Description( + text_contents='Hello', + officer_id=officer.id, + creator_id=2, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + description_id = description.id + rv = client.post( + url_for('main.description_api', officer_id=officer.id, obj_id=description.id) + '/delete', + follow_redirects=True + ) + + assert rv.status_code == 403 + not_deleted = Description.query.get(description_id) + assert not_deleted is not None + + +def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + ac = User.query.filter_by(email='raq929@example.org').first() + description = Description( + text_contents='Hello', + officer_id=officer.id, + creator_id=ac.id, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.description_api', obj_id=description.id, officer_id=officer.id) + '/edit', + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'Update' in rv.data + + +def test_acs_can_get_others_edit_form(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + ac = User.query.filter_by(email='raq929@example.org').first() + description = Description( + text_contents='Hello', + officer_id=officer.id, + creator_id=ac.id - 1, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.description_api', obj_id=description.id, officer_id=officer.id) + '/edit', + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'Update' in rv.data + + +def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() + description = Description( + text_contents='Hello', + officer_id=officer.id, + creator_id=2, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.description_api', obj_id=description.id, officer_id=officer.id) + '/edit', + follow_redirects=True + ) + assert rv.status_code == 403 + + +def test_users_can_see_descriptions(mockdata, client, session): + with current_app.test_request_context(): + officer = Officer.query.first() + text_contents = 'You can see me' + description = Description( + text_contents=text_contents, + officer_id=officer.id, + creator_id=1, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.officer_profile', officer_id=officer.id), + follow_redirects=True + ) + # ensures we're looking for a description that exists + assert description in officer.descriptions + assert rv.status_code == 200 + assert text_contents in rv.data + + +def test_admins_can_see_descriptions(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + officer = Officer.query.first() + text_contents = 'Kittens see everything' + description = Description( + text_contents=text_contents, + officer_id=officer.id, + creator_id=1, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.officer_profile', officer_id=officer.id), + follow_redirects=True + ) + assert description in officer.descriptions + assert rv.status_code == 200 + # import pdb; pdb.set_trace() + assert text_contents in rv.data + + +def test_acs_can_see_descriptions_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + officer = Officer.query.filter_by(department_id=AC_DEPT).first() + text_contents = 'I can haz descriptionz' + description = Description( + text_contents=text_contents, + officer_id=officer.id, + creator_id=1, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.officer_profile', officer_id=officer.id), + follow_redirects=True + ) + # ensures we're looking for a description that exists + assert description in officer.descriptions + assert rv.status_code == 200 + assert text_contents in rv.data + + +def test_acs_can_see_descriptions_not_in_their_department(mockdata, client, session): + with current_app.test_request_context(): + officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() + text_contents = 'Hello it me' + description = Description( + text_contents=text_contents, + officer_id=officer.id, + creator_id=1, + date_created=datetime.now(), + date_updated=datetime.now(), + ) + db.session.add(description) + db.session.commit() + rv = client.get( + url_for('main.officer_profile', officer_id=officer.id), + follow_redirects=True + ) + # ensures we're looking for a description that exists + assert description in officer.descriptions + assert rv.status_code == 200 + assert text_contents in rv.data diff --git a/OpenOversight/tests/routes/test_incidents.py b/OpenOversight/tests/routes/test_incidents.py index f853f792b..40d877c6d 100644 --- a/OpenOversight/tests/routes/test_incidents.py +++ b/OpenOversight/tests/routes/test_incidents.py @@ -6,7 +6,7 @@ from .route_helpers import login_user, login_admin, login_ac, process_form_data -from OpenOversight.app.main.forms import IncidentForm, LocationForm, LinkForm, LicensePlateForm +from OpenOversight.app.main.forms import IncidentForm, LocationForm, LinkForm, LicensePlateForm, OOIdForm from OpenOversight.app.models import Incident, Officer, Department @@ -100,6 +100,7 @@ def test_admins_can_edit_incident_date_and_address(mockdata, client, session): ) links_forms = [LinkForm(url=link.url, link_type=link.link_type).data for link in inc.links] license_plates_forms = [LicensePlateForm(number=lp.number, state=lp.state).data for lp in inc.license_plates] + ooid_forms = [OOIdForm(ooid=officer.id) for officer in inc.officers] form = IncidentForm( date_field=str(new_date.date()), @@ -110,7 +111,7 @@ def test_admins_can_edit_incident_date_and_address(mockdata, client, session): address=address_form.data, links=links_forms, license_plates=license_plates_forms, - officers=[officer.id for officer in inc.officers] + officers=ooid_forms ) data = process_form_data(form.data) @@ -146,6 +147,7 @@ def test_admins_can_edit_incident_links_and_licenses(mockdata, client, session): old_license_plates = inc.license_plates new_number = '453893' license_plates_form = LicensePlateForm(number=new_number, state='IA') + ooid_forms = [OOIdForm(ooid=officer.id) for officer in inc.officers] form = IncidentForm( date_field=str(inc.date.date()), @@ -156,7 +158,7 @@ def test_admins_can_edit_incident_links_and_licenses(mockdata, client, session): address=address_form.data, links=old_links_forms + [link_form.data], license_plates=[license_plates_form.data], - officers=[officer.id for officer in inc.officers] + officers=ooid_forms ) data = process_form_data(form.data) @@ -190,6 +192,7 @@ def test_admins_cannot_make_ancient_incidents(mockdata, client, session): state=inc.address.state, zip_code=inc.address.zip_code ) + ooid_forms = [OOIdForm(ooid=officer.id) for officer in inc.officers] form = IncidentForm( date_field=date(1899, 12, 5), @@ -198,7 +201,7 @@ def test_admins_cannot_make_ancient_incidents(mockdata, client, session): description=inc.description, department='1', address=address_form.data, - officers=[officer.id for officer in inc.officers] + officers=ooid_forms ) data = process_form_data(form.data) @@ -211,6 +214,92 @@ def test_admins_cannot_make_ancient_incidents(mockdata, client, session): assert 'Incidents prior to 1900 not allowed.' in rv.data +def test_admins_cannot_make_incidents_without_state(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + date = datetime(2000, 5, 25, 1, 45) + report_number = '42' + + address_form = LocationForm( + street_name='AAAAA', + cross_street1='BBBBB', + city='FFFFF', + state='', + zip_code='03435' + ) + ooid_forms = [OOIdForm(ooid=officer.id) + for officer in Officer.query.all()[:5]] + + form = IncidentForm( + date_field=str(date.date()), + time_field=str(date.time()), + report_number=report_number, + description='Something happened', + department='1', + address=address_form.data, + officers=ooid_forms + ) + data = process_form_data(form.data) + + incident_count_before = Incident.query.count() + rv = client.post( + url_for('main.incident_api') + 'new', + data=data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'Must select a state.' in rv.data + assert incident_count_before == Incident.query.count() + + +def test_admins_cannot_make_incidents_with_multiple_validation_errors(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + date = datetime(2000, 5, 25, 1, 45) + report_number = '42' + + address_form = LocationForm( + street_name='AAAAA', + cross_street1='BBBBB', + # no city given => 'This field is required.' + city='', + state='NY', + # invalid ZIP code => 'Zip codes must have 5 digits.' + zip_code='0343' + ) + + # license plate number given, but no state selected => 'Must also select a state.' + license_plate_form = LicensePlateForm(number='ABCDE', state='') + ooid_forms = [OOIdForm(ooid=officer.id) + for officer in Officer.query.all()[:5]] + + form = IncidentForm( + # no date given => 'This field is required.' + date_field='', + time_field=str(date.time()), + report_number=report_number, + description='Something happened', + # invalid department id => 'This field is required.' + department='-1', + address=address_form.data, + license_plates=[license_plate_form.data], + officers=ooid_forms + ) + data = process_form_data(form.data) + + incident_count_before = Incident.query.count() + rv = client.post( + url_for('main.incident_api') + 'new', + data=data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'Must also select a state.' in rv.data + assert 'Zip codes must have 5 digits.' in rv.data + assert rv.data.count('This field is required.') >= 3 + assert incident_count_before == Incident.query.count() + + def test_admins_can_edit_incident_officers(mockdata, client, session): with current_app.test_request_context(): login_admin(client) @@ -229,8 +318,10 @@ def test_admins_can_edit_incident_officers(mockdata, client, session): old_officers = inc.officers old_officer_ids = [officer.id for officer in inc.officers] + old_ooid_forms = [OOIdForm(oo_id=the_id) for the_id in old_officer_ids] # get a new officer that is different from the old officers new_officer = Officer.query.except_(Officer.query.filter(Officer.id.in_(old_officer_ids))).first() + new_ooid_form = OOIdForm(oo_id=new_officer.id) form = IncidentForm( date_field=str(inc.date.date()), @@ -241,7 +332,7 @@ def test_admins_can_edit_incident_officers(mockdata, client, session): address=address_form.data, links=links_forms, license_plates=license_plates_forms, - officers=old_officer_ids + [new_officer.id] + officers=old_ooid_forms + [new_ooid_form] ) data = process_form_data(form.data) @@ -257,6 +348,52 @@ def test_admins_can_edit_incident_officers(mockdata, client, session): assert new_officer.id in [off.id for off in inc.officers] +def test_admins_cannot_edit_nonexisting_officers(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + inc = Incident.query.first() + + address_form = LocationForm( + street_name=inc.address.street_name, + cross_street1=inc.address.cross_street1, + cross_street2=inc.address.cross_street2, + city=inc.address.city, + state=inc.address.state, + zip_code=inc.address.zip_code + ) + links_forms = [LinkForm(url=link.url, link_type=link.link_type).data for link in inc.links] + license_plates_forms = [LicensePlateForm(number=lp.number, state=lp.state).data for lp in inc.license_plates] + + old_officers = inc.officers + old_officer_ids = [officer.id for officer in inc.officers] + old_ooid_forms = [OOIdForm(oo_id=the_id) for the_id in old_officer_ids] + # create an OOIdForm with an invalid officer ID + new_ooid_form = OOIdForm(oo_id="99999999999999999") + + form = IncidentForm( + date_field=str(inc.date.date()), + time_field=str(inc.date.time()), + report_number=inc.report_number, + description=inc.description, + department='1', + address=address_form.data, + links=links_forms, + license_plates=license_plates_forms, + officers=old_ooid_forms + [new_ooid_form] + ) + data = process_form_data(form.data) + + rv = client.post( + url_for('main.incident_api', obj_id=inc.id) + '/edit', + data=data, + follow_redirects=True + ) + assert rv.status_code == 200 + assert 'Not a valid officer id' in rv.data + for officer in old_officers: + assert officer in inc.officers + + def test_ac_can_edit_incidents_in_their_department(mockdata, client, session): with current_app.test_request_context(): login_ac(client) @@ -272,6 +409,7 @@ def test_ac_can_edit_incidents_in_their_department(mockdata, client, session): ) links_forms = [LinkForm(url=link.url, link_type=link.link_type).data for link in inc.links] license_plates_forms = [LicensePlateForm(number=lp.number, state=lp.state).data for lp in inc.license_plates] + ooid_forms = [OOIdForm(ooid=officer.id) for officer in inc.officers] form = IncidentForm( date_field=str(new_date.date()), @@ -282,7 +420,7 @@ def test_ac_can_edit_incidents_in_their_department(mockdata, client, session): address=address_form.data, links=links_forms, license_plates=license_plates_forms, - officers=[officer.id for officer in inc.officers] + officers=ooid_forms ) data = process_form_data(form.data) @@ -313,6 +451,7 @@ def test_ac_cannot_edit_incidents_not_in_their_department(mockdata, client, sess ) links_forms = [LinkForm(url=link.url, link_type=link.link_type).data for link in inc.links] license_plates_forms = [LicensePlateForm(number=lp.number, state=lp.state).data for lp in inc.license_plates] + ooid_forms = [OOIdForm(ooid=officer.id) for officer in inc.officers] form = IncidentForm( date_field=str(new_date.date()), @@ -323,7 +462,7 @@ def test_ac_cannot_edit_incidents_not_in_their_department(mockdata, client, sess address=address_form.data, links=links_forms, license_plates=license_plates_forms, - officers=[officer.id for officer in inc.officers] + officers=ooid_forms ) data = process_form_data(form.data) diff --git a/OpenOversight/tests/routes/test_notes.py b/OpenOversight/tests/routes/test_notes.py index 107c8b584..332b80716 100644 --- a/OpenOversight/tests/routes/test_notes.py +++ b/OpenOversight/tests/routes/test_notes.py @@ -5,7 +5,7 @@ from .route_helpers import login_user, login_admin, login_ac -from OpenOversight.app.main.forms import NoteForm, EditNoteForm +from OpenOversight.app.main.forms import TextForm, EditTextForm from OpenOversight.app.models import db, Officer, Note, User @@ -35,10 +35,10 @@ def test_admins_can_create_notes(mockdata, client, session): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() - note = 'I can haz notez' + text_contents = 'I can haz notez' admin = User.query.filter_by(email='jen@example.org').first() - form = NoteForm( - note=note, + form = TextForm( + text_contents=text_contents, officer_id=officer.id, creator_id=admin.id ) @@ -52,7 +52,7 @@ def test_admins_can_create_notes(mockdata, client, session): assert rv.status_code == 200 assert 'created' in rv.data - created_note = Note.query.filter_by(note=note).first() + created_note = Note.query.filter_by(text_contents=text_contents).first() assert created_note is not None assert created_note.date_created is not None @@ -63,8 +63,8 @@ def test_acs_can_create_notes(mockdata, client, session): officer = Officer.query.first() note = 'I can haz notez' ac = User.query.filter_by(email='raq929@example.org').first() - form = NoteForm( - note=note, + form = TextForm( + text_contents=note, officer_id=officer.id, creator_id=ac.id ) @@ -78,7 +78,7 @@ def test_acs_can_create_notes(mockdata, client, session): assert rv.status_code == 200 assert 'created' in rv.data - created_note = Note.query.filter_by(note=note).first() + created_note = Note.query.filter_by(text_contents=note).first() assert created_note is not None assert created_note.date_created is not None @@ -91,7 +91,7 @@ def test_admins_can_edit_notes(mockdata, client, session): new_note = 'I can haz editing notez' original_date = datetime.now() note = Note( - note=old_note, + text_contents=old_note, officer_id=officer.id, creator_id=1, date_created=original_date, @@ -100,8 +100,8 @@ def test_admins_can_edit_notes(mockdata, client, session): db.session.add(note) db.session.commit() - form = EditNoteForm( - note=new_note, + form = EditTextForm( + text_contents=new_note, ) rv = client.post( @@ -109,11 +109,10 @@ def test_admins_can_edit_notes(mockdata, client, session): data=form.data, follow_redirects=True ) - print(url_for('main.note_api', officer_id=officer.id, obj_id=note.id) + '/edit') assert rv.status_code == 200 assert 'updated' in rv.data - assert note.note == new_note + assert note.text_contents == new_note assert note.date_updated > original_date @@ -126,7 +125,7 @@ def test_ac_can_edit_their_notes_in_their_department(mockdata, client, session): new_note = 'I can haz editing notez' original_date = datetime.now() note = Note( - note=old_note, + text_contents=old_note, officer_id=officer.id, creator_id=ac.id, date_created=original_date, @@ -135,8 +134,8 @@ def test_ac_can_edit_their_notes_in_their_department(mockdata, client, session): db.session.add(note) db.session.commit() - form = EditNoteForm( - note=new_note, + form = EditTextForm( + text_contents=new_note, ) rv = client.post( @@ -147,11 +146,11 @@ def test_ac_can_edit_their_notes_in_their_department(mockdata, client, session): assert rv.status_code == 200 assert 'updated' in rv.data - assert note.note == new_note + assert note.text_contents == new_note assert note.date_updated > original_date -def test_ac_cannot_edit_others_notes(mockdata, client, session): +def test_ac_can_edit_others_notes(mockdata, client, session): with current_app.test_request_context(): login_ac(client) ac = User.query.filter_by(email='raq929@example.org').first() @@ -160,7 +159,7 @@ def test_ac_cannot_edit_others_notes(mockdata, client, session): new_note = 'I can haz editing notez' original_date = datetime.now() note = Note( - note=old_note, + text_contents=old_note, officer_id=officer.id, creator_id=ac.id - 1, date_created=original_date, @@ -169,8 +168,8 @@ def test_ac_cannot_edit_others_notes(mockdata, client, session): db.session.add(note) db.session.commit() - form = EditNoteForm( - note=new_note, + form = EditTextForm( + text_contents=new_note, ) rv = client.post( @@ -181,7 +180,7 @@ def test_ac_cannot_edit_others_notes(mockdata, client, session): assert rv.status_code == 200 assert 'updated' in rv.data - assert note.note == new_note + assert note.text_contents == new_note assert note.date_updated > original_date @@ -195,7 +194,7 @@ def test_ac_cannot_edit_notes_not_in_their_department(mockdata, client, session) new_note = 'I can haz editing notez' original_date = datetime.now() note = Note( - note=old_note, + text_contents=old_note, officer_id=officer.id, creator_id=ac.id, date_created=original_date, @@ -204,8 +203,8 @@ def test_ac_cannot_edit_notes_not_in_their_department(mockdata, client, session) db.session.add(note) db.session.commit() - form = EditNoteForm( - note=new_note, + form = EditTextForm( + text_contents=new_note, ) rv = client.post( @@ -236,7 +235,7 @@ def test_acs_can_delete_their_notes_in_their_department(mockdata, client, sessio ac = User.query.filter_by(email='raq929@example.org').first() officer = Officer.query.filter_by(department_id=AC_DEPT).first() note = Note( - note='Hello', + text_contents='Hello', officer_id=officer.id, creator_id=ac.id, date_created=datetime.now(), @@ -259,7 +258,7 @@ def test_acs_cannot_delete_notes_not_in_their_department(mockdata, client, sessi login_ac(client) officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() note = Note( - note='Hello', + text_contents='Hello', officer_id=officer.id, creator_id=2, date_created=datetime.now(), @@ -284,7 +283,7 @@ def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): officer = Officer.query.filter_by(department_id=AC_DEPT).first() ac = User.query.filter_by(email='raq929@example.org').first() note = Note( - note='Hello', + text_contents='Hello', officer_id=officer.id, creator_id=ac.id, date_created=datetime.now(), @@ -306,7 +305,7 @@ def test_acs_can_get_others_edit_form(mockdata, client, session): officer = Officer.query.filter_by(department_id=AC_DEPT).first() ac = User.query.filter_by(email='raq929@example.org').first() note = Note( - note='Hello', + text_contents='Hello', officer_id=officer.id, creator_id=ac.id - 1, date_created=datetime.now(), @@ -327,7 +326,7 @@ def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): login_ac(client) officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() note = Note( - note='Hello', + text_contents='Hello', officer_id=officer.id, creator_id=2, date_created=datetime.now(), @@ -345,9 +344,9 @@ def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): def test_users_cannot_see_notes(mockdata, client, session): with current_app.test_request_context(): officer = Officer.query.first() - text = 'U can\'t see meeee' + text_contents = 'U can\'t see meeee' note = Note( - note=text, + text_contents=text_contents, officer_id=officer.id, creator_id=1, date_created=datetime.now(), @@ -362,16 +361,16 @@ def test_users_cannot_see_notes(mockdata, client, session): # ensures we're looking for a note that exists assert note in officer.notes assert rv.status_code == 200 - assert text not in rv.data + assert text_contents not in rv.data def test_admins_can_see_notes(mockdata, client, session): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() - text = 'Kittens see everything' + text_contents = 'Kittens see everything' note = Note( - note=text, + text_contents=text_contents, officer_id=officer.id, creator_id=1, date_created=datetime.now(), @@ -386,16 +385,16 @@ def test_admins_can_see_notes(mockdata, client, session): assert note in officer.notes assert rv.status_code == 200 # import pdb; pdb.set_trace() - assert text in rv.data + assert text_contents in rv.data def test_acs_can_see_notes_in_their_department(mockdata, client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() - text = 'I can haz notez' + text_contents = 'I can haz notez' note = Note( - note=text, + text_contents=text_contents, officer_id=officer.id, creator_id=1, date_created=datetime.now(), @@ -410,15 +409,15 @@ def test_acs_can_see_notes_in_their_department(mockdata, client, session): # ensures we're looking for a note that exists assert note in officer.notes assert rv.status_code == 200 - assert text in rv.data + assert text_contents in rv.data def test_acs_cannot_see_notes_not_in_their_department(mockdata, client, session): with current_app.test_request_context(): officer = Officer.query.except_(Officer.query.filter_by(department_id=AC_DEPT)).first() - text = 'Hello it me' + text_contents = 'Hello it me' note = Note( - note=text, + text_contents=text_contents, officer_id=officer.id, creator_id=1, date_created=datetime.now(), @@ -433,4 +432,4 @@ def test_acs_cannot_see_notes_not_in_their_department(mockdata, client, session) # ensures we're looking for a note that exists assert note in officer.notes assert rv.status_code == 200 - assert text not in rv.data + assert text_contents not in rv.data diff --git a/OpenOversight/tests/routes/test_officer_and_department.py b/OpenOversight/tests/routes/test_officer_and_department.py index 79dd20f4c..806cd026f 100644 --- a/OpenOversight/tests/routes/test_officer_and_department.py +++ b/OpenOversight/tests/routes/test_officer_and_department.py @@ -10,14 +10,14 @@ from OpenOversight.app.main.forms import (AssignmentForm, DepartmentForm, AddOfficerForm, AddUnitForm, - EditOfficerForm, LinkForm) + EditOfficerForm, LinkForm, + EditDepartmentForm,) from OpenOversight.app.models import Department, Unit, Officer @pytest.mark.parametrize("route", [ ('/submit'), - ('/submit/department/1'), ('/label'), ('/department/1'), ('/officer/3'), @@ -302,6 +302,129 @@ def test_admin_cannot_add_duplicate_police_department(mockdata, client, assert department.short_name == 'CPD' +def test_admin_can_edit_police_department(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + + misspelled_form = DepartmentForm(name='Misspelled Police Department', + short_name='MPD') + + misspelled_rv = client.post( + url_for('main.add_department'), + data=misspelled_form.data, + follow_redirects=True + ) + + assert 'New department' in misspelled_rv.data + + department = Department.query.filter_by(name='Misspelled Police Department').one() + + corrected_form = EditDepartmentForm(name='Corrected Police Department', + short_name='MPD') + + corrected_rv = client.post( + url_for('main.edit_department', department_id=department.id), + data=corrected_form.data, + follow_redirects=True + ) + + assert 'Department Corrected Police Department edited' in corrected_rv.data + + # Check the department with the new name is now in the database. + corrected_department = Department.query.filter_by( + name='Corrected Police Department').one() + assert corrected_department.short_name == 'MPD' + + # Check that the old name is no longer present: + assert Department.query.filter_by( + name='Misspelled Police Department').count() == 0 + + edit_short_name_form = EditDepartmentForm(name='Corrected Police Department', + short_name='CPD') + + edit_short_name_rv = client.post( + url_for('main.edit_department', department_id=department.id), + data=edit_short_name_form.data, + follow_redirects=True + ) + + assert 'Department Corrected Police Department edited' in edit_short_name_rv.data + + edit_short_name_department = Department.query.filter_by( + name='Corrected Police Department').one() + assert edit_short_name_department.short_name == 'CPD' + + +def test_ac_cannot_edit_police_department(mockdata, client, session): + with current_app.test_request_context(): + login_ac(client) + + department = Department.query.first() + + form = EditDepartmentForm(name='Corrected Police Department', + short_name='CPD') + + rv = client.post( + url_for('main.edit_department', department_id=department.id), + data=form.data, + follow_redirects=True + ) + + assert rv.status_code == 403 + + +def test_admin_cannot_duplicate_police_department_during_edit(mockdata, client, + session): + with current_app.test_request_context(): + login_admin(client) + + existing_dep_form = DepartmentForm(name='Existing Police Department', + short_name='EPD') + + existing_dep_rv = client.post( + url_for('main.add_department'), + data=existing_dep_form.data, + follow_redirects=True + ) + + assert 'New department' in existing_dep_rv.data + + new_dep_form = DepartmentForm(name='New Police Department', + short_name='NPD') + + new_dep_rv = client.post( + url_for('main.add_department'), + data=new_dep_form.data, + follow_redirects=True + ) + + assert 'New department' in new_dep_rv.data + + new_department = Department.query.filter_by( + name='New Police Department').one() + + edit_form = EditDepartmentForm(name='Existing Police Department', + short_name='EPD2') + + rv = client.post( + url_for('main.edit_department', department_id=new_department.id), + data=edit_form.data, + follow_redirects=True + ) + + assert 'already exists' in rv.data + + # make sure original department is still here + existing_department = Department.query.filter_by( + name='Existing Police Department').one() + assert existing_department.short_name == 'EPD' + + # make sure new department is left unchanged + new_department = Department.query.filter_by( + name='New Police Department').one() + assert new_department.short_name == 'NPD' + + def test_expected_dept_appears_in_submission_dept_selection(mockdata, client, session): with current_app.test_request_context(): @@ -523,11 +646,13 @@ def test_ac_can_edit_officer_in_their_dept(mockdata, client, session): first_name = 'Testier' last_name = 'OTester' middle_initial = 'R' + suffix = '' race = random.choice(RACE_CHOICES)[0] gender = random.choice(GENDER_CHOICES)[0] form = AddOfficerForm(first_name=first_name, last_name=last_name, middle_initial=middle_initial, + suffix=suffix, race=race, gender=gender, star_no=666, @@ -552,6 +677,7 @@ def test_ac_can_edit_officer_in_their_dept(mockdata, client, session): form = EditOfficerForm( first_name=first_name, last_name=new_last_name, + suffix=suffix, race=race, gender=gender, department=department.id, @@ -707,6 +833,45 @@ def test_ac_cannot_add_new_unit_not_in_their_dept(mockdata, client, session): assert unit is None +def test_admin_can_add_new_officer_with_suffix(mockdata, client, session): + with current_app.test_request_context(): + login_admin(client) + department = random.choice(dept_choices()) + links = [ + LinkForm(url='http://www.pleasework.com', link_type='link').data, + LinkForm(url='http://www.avideo/?v=2345jk', link_type='video').data + ] + form = AddOfficerForm(first_name='Testy', + last_name='McTesty', + middle_initial='T', + suffix='Jr', + race='WHITE', + gender='M', + star_no=666, + rank='COMMANDER', + department=department.id, + birth_year=1990, + links=links) + + data = process_form_data(form.data) + + rv = client.post( + url_for('main.add_officer'), + data=data, + follow_redirects=True + ) + + assert 'McTesty' in rv.data + + # Check the officer was added to the database + officer = Officer.query.filter_by( + last_name='McTesty').one() + assert officer.first_name == 'Testy' + assert officer.race == 'WHITE' + assert officer.gender == 'M' + assert officer.suffix == 'Jr' + + # def test_find_form_submission(client, mockdata): # with current_app.test_request_context(): # form = FindOfficerForm() diff --git a/OpenOversight/tests/test_functional.py b/OpenOversight/tests/test_functional.py index 66d8c4c8b..e29919e2d 100644 --- a/OpenOversight/tests/test_functional.py +++ b/OpenOversight/tests/test_functional.py @@ -4,6 +4,8 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from selenium.webdriver.common.by import By +from OpenOversight.app.models import Officer +from OpenOversight.app.config import BaseConfig @contextmanager @@ -69,3 +71,65 @@ def test_user_can_get_to_complaint(mockdata, browser): title_text = browser.find_element_by_tag_name("h1").text assert "File a Complaint" in title_text + + +def test_officer_browse_pagination(mockdata, browser): + dept_id = 1 + total = Officer.query.filter_by(department_id=dept_id).count() + perpage = BaseConfig.OFFICERS_PER_PAGE + + # first page of results + browser.get("http://localhost:5000/department/{}?from_search=False&page=1" + .format(dept_id)) + wait_for_element(browser, By.TAG_NAME, "body") + page_text = browser.find_element_by_tag_name("body").text + expected = 'Showing 1-{} of {}'.format(perpage, total) + assert expected in page_text + + # last page of results + last_page_index = (total / perpage) + 1 + browser.get("http://localhost:5000/department/{}?from_search=False&page={}" + .format(dept_id, last_page_index)) + wait_for_element(browser, By.TAG_NAME, "body") + page_text = browser.find_element_by_tag_name("body").text + expected = ('Showing {}-{} of {}' + .format(perpage * (total / perpage) + 1, total, total)) + assert expected in page_text + + +def test_lastname_capitalization(mockdata, browser): + browser.get("http://localhost:5000/auth/login") + wait_for_page_load(browser) + + # get past the login page + elem = browser.find_element_by_id("email") + elem.clear() + elem.send_keys("redshiftzero@example.org") + elem = browser.find_element_by_id("password") + elem.clear() + elem.send_keys("cat") + browser.find_element_by_id("submit").click() + wait_for_element(browser, By.ID, "cpd") + + test_pairs = [("mcDonald", "McDonald"), ("Mei-Ying", "Mei-Ying"), + ("G", "G"), ("oh", "Oh")] + + for test_pair in test_pairs: + test_input = test_pair[0] + test_output = test_pair[1] + + # enter a last name to test + browser.get("http://localhost:5000/officer/new") + wait_for_element(browser, By.ID, "last_name") + elem = browser.find_element_by_id("last_name") + elem.clear() + elem.send_keys(test_input) + browser.find_element_by_id("submit").click() + + # check result + wait_for_element(browser, By.TAG_NAME, "tbody") + # assumes the page-header field is of the form: + # + rendered_field = browser.find_element_by_class_name("page-header").text + rendered_name = rendered_field.split(":")[1].strip() + assert rendered_name == test_output diff --git a/OpenOversight/tests/test_models.py b/OpenOversight/tests/test_models.py index d628f335e..b0b1ad087 100644 --- a/OpenOversight/tests/test_models.py +++ b/OpenOversight/tests/test_models.py @@ -12,7 +12,7 @@ def test_department_repr(mockdata): def test_officer_repr(mockdata): officer = Officer.query.first() - assert officer.__repr__() == ''.format(officer.id, officer.first_name, officer.middle_initial, officer.last_name) + assert officer.__repr__() == ''.format(officer.id, officer.first_name, officer.middle_initial, officer.last_name, officer.suffix) def test_assignment_repr(mockdata): diff --git a/README.md b/README.md index bcdf1a450..aeca974b4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ ![](docs/img/lpl-logo.png) -# OpenOversight [![Build Status](https://travis-ci.org/lucyparsons/OpenOversight.svg?branch=develop)](https://travis-ci.org/lucyparsons/OpenOversight) [![Coverage Status](https://coveralls.io/repos/github/lucyparsons/OpenOversight/badge.svg?branch=develop)](https://coveralls.io/github/lucyparsons/OpenOversight?branch=develop) - -[![Join the chat at https://gitter.im/OpenOversight/Lobby](https://badges.gitter.im/OpenOversight/Lobby.svg)](https://gitter.im/OpenOversight/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +# OpenOversight [![Build Status](https://travis-ci.org/lucyparsons/OpenOversight.svg?branch=develop)](https://travis-ci.org/lucyparsons/OpenOversight) [![Coverage Status](https://coveralls.io/repos/github/lucyparsons/OpenOversight/badge.svg?branch=develop)](https://coveralls.io/github/lucyparsons/OpenOversight?branch=develop) [![Documentation Status](https://readthedocs.org/projects/openoversight/badge/?version=latest)](https://openoversight.readthedocs.io/en/latest/?badge=latest) [![Join the chat at https://gitter.im/OpenOversight/Lobby](https://badges.gitter.im/OpenOversight/Lobby.svg)](https://gitter.im/OpenOversight/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) OpenOversight is a Lucy Parsons Labs project to improve law enforcement accountability through public and crowdsourced data. We maintain a database of officer demographic information and provide digital galleries of photographs. This is done to help people identify law enforcement officers for filing complaints and in order for the public to see work-related information about law enforcement officers that interact with the public. @@ -24,11 +22,12 @@ contribution, just include "#notip" in your PR description. The amount of the ti ## Developer Quickstart +Make sure you have Docker installed and then: + ``` git clone https://github.com/lucyparsons/OpenOversight.git cd OpenOversight -vagrant up -vagrant ssh +make dev ``` And open `http://localhost:3000` in your favorite browser! @@ -43,6 +42,13 @@ Password: testtest Please see [CONTRIB.md](/CONTRIB.md) for the full developer setup instructions. +## Documentation Quickstart + +``` +pip install -r dev-requirements.txt +make docs +``` + ## Deployment Please see the [DEPLOY.md](/DEPLOY.md) file for deployment instructions. diff --git a/Rakefile b/Rakefile deleted file mode 100644 index e572c68fb..000000000 --- a/Rakefile +++ /dev/null @@ -1,16 +0,0 @@ -desc 'install the gems required for vagrant/puppet' -task :bundle_install do - sh 'bundle install' -end - -namespace :vagrant do - desc 'build the puppet modules required for vagrant' - task :build_puppet do - sh 'cd vagrant/puppet && librarian-puppet install --verbose --path=modules' - end - - desc 'bring up the vagrant development VM' - task :provision do - sh 'vagrant up' - end -end diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index c1829fa43..000000000 --- a/Vagrantfile +++ /dev/null @@ -1,29 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - config.vm.box = "ubuntu/trusty64" - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. - config.vm.network "forwarded_port", guest: 3000, host: 3000 - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # Customize the amount of memory on the VM: - vb.memory = "512" - end - - # Provision with our standalone-puppet provider - config.vm.provision "puppet" do |puppet| - puppet.manifests_path = 'vagrant/puppet/manifests' - puppet.module_path = 'vagrant/puppet/modules' - end -end diff --git a/database/create_officer_roster.sql b/database/create_officer_roster.sql index ed9f2e5b2..778e4cc4a 100644 --- a/database/create_officer_roster.sql +++ b/database/create_officer_roster.sql @@ -5,8 +5,9 @@ create table officers.roster ( last_name varchar(80), first_name varchar(80), middle_initial varchar(10), + suffix varchar(10), race varchar(40), gender varchar(40), employment_date date, birth_year integer -); \ No newline at end of file +); diff --git a/database/populate_officer_roster.sql b/database/populate_officer_roster.sql index 4d099812f..77b9e177d 100644 --- a/database/populate_officer_roster.sql +++ b/database/populate_officer_roster.sql @@ -15,11 +15,12 @@ from public.invisinst; -- merge in rows from more recent roster from foia -- recent foia data does not have birth year insert into officers.roster - (last_name, first_name, middle_initial, race, gender, employment_date) + (last_name, first_name, middle_initial, suffix, race, gender, employment_date) select "Last Name", "First Name", "Middle Initial", + "Suffix", "Race", "Gender", "Date of Employment" @@ -29,4 +30,4 @@ where select last_name, first_name from officers.roster where officers.roster.last_name = public.roster."Last Name" and officers.roster.first_name = public.roster."First Name" - ); \ No newline at end of file + ); diff --git a/database/populate_officer_roster_and_assignment.sql b/database/populate_officer_roster_and_assignment.sql index e753f9f93..d2ac98a3c 100644 --- a/database/populate_officer_roster_and_assignment.sql +++ b/database/populate_officer_roster_and_assignment.sql @@ -3,11 +3,12 @@ delete from public.assignments; -- populate chicago police department officers cpd corresponds to pd_id=1 insert into public.officers - (last_name, first_name, middle_initial, race, gender, employment_date, pd_id) + (last_name, first_name, middle_initial, suffix, race, gender, employment_date, pd_id) select "Last Name", "First Name", "Middle Initial", + "Suffix", "Race", "Gender", "Date of Employment", @@ -37,4 +38,4 @@ on t1."FIRST_NME" = t2.first_name and t1."LAST_NME" = t2.last_name and t1."SEX_CODE_CD" = t2.gender and t1."RACE" = t2.race and t1."MIDDLE_INITIAL" = t2.middle_initial) foo WHERE - foo.officer_id = officers.id; \ No newline at end of file + foo.officer_id = officers.id; diff --git a/dev-requirements.txt b/dev-requirements.txt index 81d95ffe9..9f7418597 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,9 +1,11 @@ -flake8 -selenium +flake8==3.5.0 +selenium==3.14.0 nose>=1.3.1 pytest==3.0.3 faker==0.7.3 pytest-cov==2.4.0 pytest-pep8==1.0.6 -xvfbwrapper -mock +xvfbwrapper==0.2.9 +mock==2.0.0 +sphinx==1.7.8 +sphinx-autobuild==0.7.1 diff --git a/docker-compose.yml b/docker-compose.yml index 844aaed5f..606ccd6a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,10 @@ services: POSTGRES_USER: openoversight POSTGRES_PASSWORD: terriblepassword POSTGRES_DB: openoversight-dev + volumes: + - ./container_data/postgres:/var/lib/postgresql/data + ports: + - "5432:5432" web: restart: always @@ -28,4 +32,3 @@ services: command: /usr/local/bin/gunicorn --reload -w 4 -b 0.0.0.0:3000 app:app ports: - "3000:3000" - - "5433:5432" diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..748e985c0 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,23 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = OpenOversight +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile clean + +clean: + rm -rf $(BUILDDIR)/* + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/area_coordinator.rst b/docs/area_coordinator.rst new file mode 100644 index 000000000..58018a335 --- /dev/null +++ b/docs/area_coordinator.rst @@ -0,0 +1,15 @@ +Area Coordinator +================ + +An area coordinator is a person with an account on +OpenOversight that is charged with curating the collection for a particular +department. There can be several area coordinators for a given department. +The tasks they perform include: + +* Add new officers +* Update officer information, such as new assignments or promotions +* Add private notes to particular officer profiles (visible to other area + coordinators or administrators) +* Add a brief description to an officer's profile +* Add links and videos to officer's profiles +* Add incidents linked to one or more officers diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..14a54bc11 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = u'OpenOversight' +copyright = u'2018, Lucy Parsons Labs' +author = u'Lucy Parsons Labs' + +# The short X.Y version +version = u'' +# The full version, including alpha/beta/rc tags +release = u'' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'OpenOversightdoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'OpenOversight.tex', u'OpenOversight Documentation', + u'Lucy Parsons Labs', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'openoversight', u'OpenOversight Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'OpenOversight', u'OpenOversight Documentation', + author, 'OpenOversight', 'One line description of project.', + 'Miscellaneous'), +] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..be2a57c17 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,26 @@ +.. OpenOversight documentation master file, created by + sphinx-quickstart on Fri Jun 29 23:35:10 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to OpenOversight's documentation! +========================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + area_coordinator + +OpenOversight is a Lucy Parsons Labs project to improve law enforcement +accountability through public and crowdsourced data. We maintain a database +of officer demographic information and provide digital galleries of photographs. +This is done to help people identify law enforcement officers for filing +complaints and in order for the public to see work-related information about +law enforcement officers that interact with the public. + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..66943f927 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=OpenOversight + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/requirements.txt b/requirements.txt index 063bc0b53..038a59bad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,7 @@ -Flask==0.12.2 +Flask==1.0.2 python-dotenv==0.7.1 boto3==1.5.10 -werkzeug>=0.11.1 -Flask==0.12.2 +werkzeug>=0.14 Flask-Bootstrap==3.3.7.1 Flask-Limiter==1.0.1 Flask-Login==0.4.1 diff --git a/vagrant/puppet/Puppetfile b/vagrant/puppet/Puppetfile deleted file mode 100644 index 6d660bbbc..000000000 --- a/vagrant/puppet/Puppetfile +++ /dev/null @@ -1,3 +0,0 @@ -forge 'https://forgeapi.puppetlabs.com' -mod 'puppetlabs/postgresql' -mod 'stankevich/python' diff --git a/vagrant/puppet/Puppetfile.lock b/vagrant/puppet/Puppetfile.lock deleted file mode 100644 index 757cad272..000000000 --- a/vagrant/puppet/Puppetfile.lock +++ /dev/null @@ -1,22 +0,0 @@ -FORGE - remote: https://forgeapi.puppetlabs.com - specs: - puppetlabs-apt (2.3.0) - puppetlabs-stdlib (< 5.0.0, >= 4.5.0) - puppetlabs-concat (2.2.0) - puppetlabs-stdlib (< 5.0.0, >= 4.2.0) - puppetlabs-postgresql (4.8.0) - puppetlabs-apt (< 3.0.0, >= 1.8.0) - puppetlabs-concat (< 3.0.0, >= 1.1.0) - puppetlabs-stdlib (~> 4.0) - puppetlabs-stdlib (4.12.0) - stahnma-epel (1.2.2) - puppetlabs-stdlib (>= 3.0.0) - stankevich-python (1.17.0) - puppetlabs-stdlib (< 6.0.0, >= 4.6.0) - stahnma-epel (< 2.0.0, >= 1.2.2) - -DEPENDENCIES - puppetlabs-postgresql (>= 0) - stankevich-python (>= 0) - diff --git a/vagrant/puppet/manifests/default.pp b/vagrant/puppet/manifests/default.pp deleted file mode 100644 index 898a732ee..000000000 --- a/vagrant/puppet/manifests/default.pp +++ /dev/null @@ -1,129 +0,0 @@ -# Install prerequisites and a development environment for OpenOversight - - - - # Ubuntu renamed their vagrant image's default user between - # ubuntu/trusty64 and ubuntu/xenial64. This doesn't work on - # xenial64 yet, because of stankevich/puppet-python, but we - # will be more prepared when the time comes maybe - case $operatingsystemmajrelease { - '16.04': { - $system_user = 'ubuntu' - } - default: { - $system_user = 'vagrant' - } - } - $development = true - - $geckodriver_version = 'v0.17.0' - $geckodriver_url = "https://github.com/mozilla/geckodriver/releases/download/${geckodriver_version}/geckodriver-${geckodriver_version}-linux64.tar.gz" - - $virtualenv = "/home/${system_user}/oovirtenv" - $source_path = '/vagrant' - $database_name = 'openoversight-dev' - $database_server = 'localhost' - $database_user = 'openoversight' - $database_password = 'terriblepassword' - - $database_uri = "postgresql://${database_user}:${database_password}@${database_server}/${database_name}" - - $csrf_token = "terriblecsrftoken" - - class { 'postgresql::server': - listen_addresses => '*', - } - - postgresql::server::db { [$database_name]: - user => $database_user, - password => postgresql_password($database_user, $database_password), - encoding => 'UTF8', - } - - class { 'python': - pip => present, - dev => present, - gunicorn => present, - virtualenv => present, - } - - python::dotfile {"${source_path}/OpenOversight/.env": - ensure => present, - owner => $system_user, - mode => '0644', - config => { - 'global' => { - 'SQLALCHEMY_DATABASE_URI' => $database_uri, - 'SECRET_KEY' => $csrf_token, - } - }, - notify => Python::Gunicorn['oo'], - } - - python::virtualenv {$virtualenv: - ensure => present, - requirements => "${source_path}/requirements.txt", - venv_dir => $virtualenv, - owner => $system_user, - require => Package['libpq-dev'], - } - - if $development { - python::requirements { "${source_path}/dev-requirements.txt": - virtualenv => $virtualenv, - owner => $system_user, - require => [ Package['firefox'], Python::Virtualenv[$virtualenv] ], - } - - package {['firefox', 'Xvfb']: } - - exec {'download and install geckodriver': # This is ugly but I'm not going to pull in an archive module for one file - command => "/usr/bin/wget ${geckodriver_url} && tar zxvf geckodriver-* && mv geckodriver bin", - cwd => "/usr/local", - } - } - - python::gunicorn {'oo': - ensure => present, - virtualenv => $virtualenv, - dir => "${source_path}/OpenOversight", - bind => '0.0.0.0:3000', - require => [ File["${source_path}/OpenOversight/.env"], Postgresql::Server::Db['openoversight-dev'] ] - } - - package {['libpq-dev', 'libffi-dev']: } - - exec{'set up database': - command => "python create_db.py", - cwd => $source_path, - path => "${virtualenv}/bin", - user => $system_user, - require => [ File["${source_path}/OpenOversight/.env"], Python::Virtualenv[$virtualenv], Postgresql::Server::Db[$database_name] ] - } - - exec{'stamp database on latest migration': - command => "python manage.py db stamp head", - cwd => "$source_path/OpenOversight", - path => "${virtualenv}/bin", - user => $system_user, - require => [ File["${source_path}/OpenOversight/.env"], Python::Virtualenv[$virtualenv], Postgresql::Server::Db[$database_name] ] - } - - exec{'create test data': - command => "python test_data.py -p", - cwd => $source_path, - path => "${virtualenv}/bin", - user => $system_user, - require => Exec['set up database'], - } - - file {'/tmp/openoversight.log': - ensure => present, - owner => $system_user, - group => "www-data", - mode => '0664', - require => Python::Virtualenv[$virtualenv], - } - - exec{'/usr/bin/apt-get update': } - Exec['/usr/bin/apt-get update'] -> Package <| |> diff --git a/vagrant/puppet/modules/apt/CHANGELOG.md b/vagrant/puppet/modules/apt/CHANGELOG.md deleted file mode 100644 index 44cc4f8f7..000000000 --- a/vagrant/puppet/modules/apt/CHANGELOG.md +++ /dev/null @@ -1,522 +0,0 @@ -## Supported Release 2.3.0 -### Summary -A release containing many bugfixes with additional features. - -#### Features -- Apt_updates facts now use /usr/bin/apt-get. -- Addition of notify update to apt::source. -- Update to newest modulesync_configs. -- Installs software-properties-common for Xenial. -- Modulesync updates. -- Add ability to specify a hash of apt::conf defines. - -#### Bugfixes -- A clean up of spec/defines/key_compat_specs, also now runs under STRICT_VARIABLES. -- Apt::setting expects priority to be an integer, set defaults accordingly. -- Fixed version check for Ubuntu on 16.04. -- Now uses hkps.pool.sks-keyservers.net instead of pgp.mit.edu. -- Updates and fixes to tests. General cleanup. -- Fixed regexp for $ensure params. -- Apt/params: Remove unused LSB facts. -- Replaced `-s` with `-f` in ppa rspec tests - After the repository is added, the "${::apt::sources_list_d}/${sources_list_d_filename}" file is created as an empty file. The unless condition of Exec["add-apt-repository-${name}"] calls test -s, which returns 1 if the file is empty. Because the file is empty, the unless condition is never true and the repository is added on every execution. This change replaces the -s test condition with -f, which is true if the file exists or false otherwise. -- Limit non-strict parsing to pre-3.5.0 only - Puppet 3.5.0 introduced strict variables and the module handles strict variables by using the defined() function. This does not work on prior versions of puppet so we now gate based on that version. Puppet 4 series has a new setting `strict` that may be set to enforce strict variables while `strict_variables` remains unset (see PUP-6358) which causes the conditional in manifests/params.pp to erroniously use non-strict 3.5-era parsing and fail. This new conditional corrects the cases such that strict variable behavior happens on versions 3.5.0 and later. - -##Supported Release 2.2.2 -###Summary - -Several bug fixes and the addition of support updates to Debian 8 and Ubuntu Wily. - -####Bugfixes -- Small fixes to descriptions within the readme and the addition of some examples. -- Updates to run on Ubuntu Wily. -- Fixed apt_key tempfile race condition. -- Run stages limitation added to the documentation. -- Remove unneeded whitespace in source.list template. -- Handle PPA names that contain a plus character. -- Update to current msync configs. -- Avoid duplicate package resources when package_manage => true. -- Avoid multiple package resource declarations. -- Ensure PPAs in tests have valid form. -- Look for correct sources.list.d file for apt::ppa. -- Debian 8 support addiiton to metadata. - -##Supported Release 2.2.1 -###Summary - -Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. - -##2015-09-29 - Supported Release 2.2.0 -###Summary - -This release includes a few bugfixes. - -####Features -- Adds an `ensure` parameter for user control of proxy presence. -- Adds ability to set `notify_update` to `apt::conf` (MODULES-2269). -- Apt pins no longer trigger an `apt-get update` run. -- Adds support for creating pins from main class. - -####Bugfixes -- Updates to use the official Debian mirrors. -- Fixes path to `preferences` and `preferences.d` -- Fixes pinning for backports (MODULES-2446). -- Fixes the name/extension of the preferences files. - -##2015-07-28 - Supported Release 2.1.1 -###Summary - -This release includes a few bugfixes. - -####Bugfixes -- Fix incorrect use of anchoring (MODULES-2190) -- Use correct comment type for apt.conf files -- Test fixes -- Documentation fixes - -##2015-06-16 - Supported Release 2.1.0 -###Summary - -This release largely makes `apt::key` and `apt::source` API-compatible with the 1.8.x versions for ease in upgrading, and also addresses some compatibility issues with older versions of Puppet. - -####Features -- Add API compatibility to `apt::key` and `apt::source` -- Added `apt_reboot_required` fact - -####Bugfixes -- Fix compatibility with Puppet versions 3.0-3.4 -- Work around future parser bug PUP-4133 - -##2015-04-28 - Supported Release 2.0.1 -###Summary - -This bug fixes a few compatibility issues that came up with the 2.0.0 release, and includes test and documentation updates. - -####Bugfixes -- Fix incompatibility with keyrings containing multiple keys -- Fix bugs preventing the module from working with Puppet < 3.5.0 - -##2015-04-07 - Supported Release 2.0.0 -###Summary - -This is a major rewrite of the apt module. Many classes and defines were removed, but all existing functionality should still work. Please carefully review documentation before upgrading. - -####Backwards-incompatible changes - -As this is a major rewrite of the module there are a great number of backwards incompatible changes. Please review this and the updated README carefully before upgrading. - -#####`apt_key` -- `keyserver_options` parameter renamed to `options` - -#####`apt::backports` -- This no longer works out of the box on Linux Mint. If using this on mint, you must specify the `location`, `release`, `repos`, and `key` parameters. [Example](examples/backports.pp) - -#####`apt::builddep` -- This define was removed. Functionality can be matched passing 'build-dep' to `install_options` in the package resource. [Example](examples/builddep.pp) - -#####`apt::debian::testing` -- This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_testing.pp) - -#####`apt::debian::unstable` -- This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_unstable.pp) - -#####`apt::force` -- This define was removed. Functionallity can be matched by setting `install_options` in the package resource. See [here](examples/force.pp) for how to set the options. - -#####`apt::hold` -- This define was removed. Simply use an `apt::pin` with `priority => 1001` for the same functionality. - -#####`apt` -- `always_apt_update` - This parameter was removed. Use `update => { 'frequency' => 'always' }` instead. -- `apt_update_frequency` - This parameter was removed. Use `update => { 'frequency' => }` instead. -- `disable_keys` - This parameter was removed. See this [example](examples/disable_keys.pp) if you need this functionality. -- `proxy_host` - This parameter was removed. Use `proxy => { 'host' => }` instead. -- `proxy_port` - This parameter was removed. Use `proxy => { 'port' => }` instead. -- `purge_sources_list` - This parameter was removed. Use `purge => { 'sources.list' => }` instead. -- `purge_sources_list_d` - This parameter was removed. Use `purge => { 'sources.list.d' => }` instead. -- `purge_preferences` - This parameter was removed. Use `purge => { 'preferences' => }` instead. -- `purge_preferences_d` - This parameter was removed. Use `purge => { 'preferences.d' => }` instead. -- `update_timeout` - This parameter was removed. Use `update => { 'timeout' => }` instead. -- `update_tries` - This parameter was removed. Use `update => { 'tries' => }` instead. - -#####`apt::key` -- `key` - This parameter was renamed to `id`. -- `key_content` - This parameter was renamed to `content`. -- `key_source` - This parameter was renamed to `source`. -- `key_server` - This parameter was renamed to `server`. -- `key_options` - This parameter was renamed to `options`. - -#####`apt::release` -- This class was removed. See this [example](examples/release.pp) for how to achieve this functionality. - -#####`apt::source` -- `include_src` - This parameter was removed. Use `include => { 'src' => }` instead. ***NOTE*** This now defaults to false. -- `include_deb` - This parameter was removed. Use `include => { 'deb' => }` instead. -- `required_packages` - This parameter was removed. Use package resources for these packages if needed. -- `key` - This can either be a key id or a hash including key options. If using a hash, `key => { 'id' => }` must be specified. -- `key_server` - This parameter was removed. Use `key => { 'server' => }` instead. -- `key_content` - This parameter was removed. Use `key => { 'content' => }` instead. -- `key_source` - This parameter was removed. Use `key => { 'source' => }` instead. -- `trusted_source` - This parameter was renamed to `allow_unsigned`. - -#####`apt::unattended_upgrades` -- This class was removed and is being republished under the puppet-community namespace. The git repository is available [here](https://github.com/puppet-community/puppet-unattended_upgrades) and it will be published to the forge [here](https://forge.puppetlabs.com/puppet/unattended_upgrades). - -####Changes to default behavior -- By default purge unmanaged files in 'sources.list', 'sources.list.d', 'preferences', and 'preferences.d'. -- Changed default for `package_manage` in `apt::ppa` to `false`. Set to `true` in a single PPA if you need the package to be managed. -- `apt::source` will no longer include the `src` entries by default. -- `pin` in `apt::source` now defaults to `undef` instead of `false` - -####Features -- Added the ability to pass hashes of `apt::key`s, `apt::ppa`s, and `apt::setting`s to `apt`. -- Added 'https' key to `proxy` hash to allow disabling `https_proxy` for the `apt::ppa` environment. -- Added `apt::setting` define to abstract away configuration. -- Added the ability to pass hashes to `pin` and `key` in `apt::backports` and `apt::source`. - -####Bugfixes -- Fixes for strict variables. - -##2015-03-17 - Supported Release 1.8.0 -###Summary - -This is the last planned feature release of the 1.x series of this module. All new features will be evaluated for puppetlabs-apt 2.x. - -This release includes many important features, including support for full fingerprints, and fixes issues where `apt_key` was not supporting user/password and `apt_has_updates` was not properly parsing the `apt-check` output. - -####Changes to default behavior -- The apt module will now throw warnings if you don't use full fingerprints for `apt_key`s - -####Features -- Use gpg to check keys to work around https://bugs.launchpad.net/ubuntu/+source/gnupg2/+bug/1409117 (MODULES-1675) -- Add 'oldstable' to the default update origins for wheezy -- Add utopic, vivid, and cumulus compatibility -- Add support for full fingerprints -- New parameter for `apt::source` - - `trusted_source` -- New parameters for `apt::ppa` - - `package_name` - - `package_manage` -- New parameter for `apt::unattended_upgrades` - - `legacy_origin` -- Separate `apt::pin` from `apt::backports` to allow pin by release instead of origin - -####Bugfixes -- Cleanup lint and future parser issues -- Fix to support username and passwords again for `apt_key` (MODULES-1119) -- Fix issue where `apt::force` `$install_check` didn't work with non-English locales (MODULES-1231) -- Allow 5 digit ports in `apt_key` -- Fix for `ensure => absent` in `apt_key` (MODULES-1661) -- Fix `apt_has_updates` not parsing `apt-check` output correctly -- Fix inconsistent headers across files (MODULES-1200) -- Clean up formatting for 50unattended-upgrades.erb - -##2014-10-28 - Supported Release 1.7.0 -###Summary - -This release includes several new features, documentation and test improvements, and a few bug fixes. - -####Features -- Updated unit and acceptance tests -- Update module to work with Linux Mint -- Documentation updates -- Future parser / strict variables support -- Improved support for long GPG keys -- New parameters! - - Added `apt_update_frequency` to apt - - Added `cfg_files` and `cfg_missing` parameters to apt::force - - Added `randomsleep` to apt::unattended_upgrades -- Added `apt_update_last_success` fact -- Refactored facts for performance improvements - -####Bugfixes -- Update apt::builddep to require Exec['apt_update'] instead of notifying it -- Clean up lint errors - -##2014-08-20 - Supported Release 1.6.0 -###Summary - -####Features -- Allow URL or domain name for key_server parameter -- Allow custom comment for sources list -- Enable auto-update for Debian squeeze LTS -- Add facts showing available updates -- Test refactoring - -####Bugfixes -- Allow dashes in URL or domain for key_server parameter - -##2014-08-13 - Supported Release 1.5.3 -###Summary - -This is a bugfix releases. It addresses a bad regex, failures with unicode -characters, and issues with the $proxy_host handling in apt::ppa. - -####Features -- Synced files from Modulesync - -####Bugfixes -- Fix regex to follow APT requirements in apt::pin -- Fix for unicode characters -- Fix inconsistent $proxy_host handling in apt and apt::ppa -- Fix typo in README -- Fix broken acceptance tests - -##2014-07-15 - Supported Release 1.5.2 -###Summary - -This release merely updates metadata.json so the module can be uninstalled and -upgraded via the puppet module command. - -##2014-07-10 - Supported Release 1.5.1 -###Summary - -This release has added tests to ensure graceful failure on OSX. - -##2014-06-04 - Release 1.5.0 -###Summary - -This release adds support for Ubuntu 14.04. It also includes many new features -and important bugfixes. One huge change is that apt::key was replaced with -apt_key, which allows you to use puppet resource apt_key to inventory keys on -your system. - -Special thanks to daenney, our intrepid unofficial apt maintainer! - -####Features -- Add support for Ubuntu Trusty! -- Add apt::hold define -- Generate valid *.pref files in apt::pin -- Made pin_priority configurable for apt::backports -- Add apt_key type and provider -- Rename "${apt_conf_d}/proxy" to "${apt_conf_d}/01proxy" -- apt::key rewritten to use apt_key type -- Add support for update_tries to apt::update - -####Bugfixes -- Typo fixes -- Fix unattended upgrades -- Removed bogus line when using purge_preferences -- Fix apt::force to upgrade allow packages to be upgraded to the pacakge from the specified release - -##2014-03-04 - Supported Release 1.4.2 -###Summary - -This is a supported release. This release tidies up 1.4.1 and re-enables -support for Ubuntu 10.04 - -####Features - -####Bugfixes -- Fix apt:ppa to include the -y Ubuntu 10.04 requires. -- Documentation changes. -- Test fixups. - -####Known Bugs - -* No known issues. - - - -##2014-02-13 1.4.1 -###Summary -This is a bugfix release. - -####Bugfixes -- Fix apt::force unable to upgrade packages from releases other than its original -- Removed a few refeneces to aptitude instead of apt-get for portability -- Removed call to getparam() due to stdlib dependency -- Correct apt::source template when architecture is provided -- Retry package installs if apt is locked -- Use root to exec in apt::ppa -- Updated tests and converted acceptance tests to beaker - -##2013-10-08 - Release 1.4.0 - -###Summary - -Minor bugfix and allow the timeout to be adjusted. - -####Features -- Add an `updates_timeout` to apt::params - -####Bugfixes -- Ensure apt::ppa can read a ppa removed by hand. - - -##2013-10-08 - Release 1.3.0 -###Summary - -This major feature in this release is the new apt::unattended_upgrades class, -allowing you to handle Ubuntu's unattended feature. This allows you to select -specific packages to automatically upgrade without any further user -involvement. - -In addition we extend our Wheezy support, add proxy support to apt:ppa and do -various cleanups and tweaks. - -####Features -- Add apt::unattended_upgrades support for Ubuntu. -- Add wheezy backports support. -- Use the geoDNS http.debian.net instead of the main debian ftp server. -- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command. -- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt). - -####Bugfixes -- Fix regsubst() calls to quote single letters (for future parser). -- Fix lint warnings and other misc cleanup. - - -##2013-07-03 - Release 1.2.0 - -####Features -- Add geppetto `.project` natures -- Add GH auto-release -- Add `apt::key::key_options` parameter -- Add complex pin support using distribution properties for `apt::pin` via new properties: - - `apt::pin::codename` - - `apt::pin::release_version` - - `apt::pin::component` - - `apt::pin::originator` - - `apt::pin::label` -- Add source architecture support to `apt::source::architecture` - -####Bugfixes -- Use apt-get instead of aptitude in apt::force -- Update default backports location -- Add dependency for required packages before apt-get update - - -##2013-06-02 - Release 1.1.1 -###Summary - -This is a bug fix release that resolves a number of issues: - -* By changing template variable usage, we remove the deprecation warnings - for Puppet 3.2.x -* Fixed proxy file removal, when proxy absent - -Some documentation, style and whitespaces changes were also merged. This -release also introduced proper rspec-puppet unit testing on Travis-CI to help -reduce regression. - -Thanks to all the community contributors below that made this patch possible. - -#### Detail Changes - -* fix minor comment type (Chris Rutter) -* whitespace fixes (Michael Moll) -* Update travis config file (William Van Hevelingen) -* Build all branches on travis (William Van Hevelingen) -* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) -* Updated content to conform to README best practices template (Lauren Rother) -* Fix apt::release example in readme (Brian Galey) -* add @ to variables in template (Peter Hoeg) -* Remove deprecation warnings for pin.pref.erb as well (Ken Barber) -* Update travis.yml to latest versions of puppet (Ken Barber) -* Fix proxy file removal (Scott Barber) -* Add spec test for removing proxy configuration (Dean Reilly) -* Fix apt::key listing longer than 8 chars (Benjamin Knofe) - - - - -## Release 1.1.0 -###Summary - -This release includes Ubuntu 12.10 (Quantal) support for PPAs. - ---- - -##2012-05-25 - Puppet Labs - Release 0.0.4 -###Summary - - * Fix ppa list filename when there is a period in the PPA name - * Add .pref extension to apt preferences files - * Allow preferences to be purged - * Extend pin support - - -##2012-05-04 - Puppet Labs - Release 0.0.3 -###Summary - - * only invoke apt-get update once - * only install python-software-properties if a ppa is added - * support 'ensure => absent' for all defined types - * add apt::conf - * add apt::backports - * fixed Modulefile for module tool dependency resolution - * configure proxy before doing apt-get update - * use apt-get update instead of aptitude for apt::ppa - * add support to pin release - - -##2012-03-26 - Puppet Labs - Release 0.0.2 -###Summary - -* 41cedbb (#13261) Add real examples to smoke tests. -* d159a78 (#13261) Add key.pp smoke test -* 7116c7a (#13261) Replace foo source with puppetlabs source -* 1ead0bf Ignore pkg directory. -* 9c13872 (#13289) Fix some more style violations -* 0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path -* a758247 (#13289) Clean up style violations and fix corresponding tests -* 99c3fd3 (#13289) Add puppet lint tests to Rakefile -* 5148cbf (#13125) Apt keys should be case insensitive -* b9607a4 Convert apt::key to use anchors - - -##2012-03-07 - Puppet Labs - Release 0.0.1 -###Summary - -* d4fec56 Modify apt::source release parameter test -* 1132a07 (#12917) Add contributors to README -* 8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it -* 7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input -* be2cc3e (#12522) Adjust spec test for splitting purge -* 7dc60ae (#12522) Split purge option to spare sources.list -* 9059c4e Fix source specs to test all key permutations -* 8acb202 Add test for python-software-properties package -* a4af11f Check if python-software-properties is defined before attempting to define it. -* 1dcbf3d Add tests for required_packages change -* f3735d2 Allow duplicate $required_packages -* 74c8371 (#12430) Add tests for changes to apt module -* 97ebb2d Test two sources with the same key -* 1160bcd (#12526) Add ability to reverse apt { disable_keys => true } -* 2842d73 Add Modulefile to puppet-apt -* c657742 Allow the use of the same key in multiple sources -* 8c27963 (#12522) Adding purge option to apt class -* 997c9fd (#12529) Add unit test for apt proxy settings -* 50f3cca (#12529) Add parameter to support setting a proxy for apt -* d522877 (#12094) Replace chained .with_* with a hash -* 8cf1bd0 (#12094) Remove deprecated spec.opts file -* 2d688f4 (#12094) Add rspec-puppet tests for apt -* 0fb5f78 (#12094) Replace name with path in file resources -* f759bc0 (#11953) Apt::force passes $version to aptitude -* f71db53 (#11413) Add spec test for apt::force to verify changes to unless -* 2f5d317 (#11413) Update dpkg query used by apt::force -* cf6caa1 (#10451) Add test coverage to apt::ppa -* 0dd697d include_src parameter in example; Whitespace cleanup -* b662eb8 fix typos in "repositories" -* 1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added -* 864302a Set the pin priority before adding the source (Fix #10449) -* 1de4e0a Refactored as per mlitteken -* 1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! -* 52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep -* 5c05fa0 added builddep command. -* a11af50 added the ability to specify the content of a key -* c42db0f Fixes ppa test. -* 77d2b0d reformatted whitespace to match recommended style of 2 space indentation. -* 27ebdfc ignore swap files. -* 377d58a added smoke tests for module. -* 18f614b reformatted apt::ppa according to recommended style. -* d8a1e4e Created a params class to hold global data. -* 636ae85 Added two params for apt class -* 148fc73 Update LICENSE. -* ed2d19e Support ability to add more than one PPA -* 420d537 Add call to apt-update after add-apt-repository in apt::ppa -* 945be77 Add package definition for python-software-properties -* 71fc425 Abs paths for all commands -* 9d51cd1 Adding LICENSE -* 71796e3 Heading fix in README -* 87777d8 Typo in README -* f848bac First commit diff --git a/vagrant/puppet/modules/apt/CONTRIBUTING.md b/vagrant/puppet/modules/apt/CONTRIBUTING.md deleted file mode 100644 index 3c3f1e799..000000000 --- a/vagrant/puppet/modules/apt/CONTRIBUTING.md +++ /dev/null @@ -1,218 +0,0 @@ -Checklist (and a short version for the impatient) -================================================= - - * Commits: - - - Make commits of logical units. - - - Check for unnecessary whitespace with "git diff --check" before - committing. - - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). - - - Do not check in commented out code or unneeded files. - - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. - - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". - - - The body should provide a meaningful commit message, which: - - - uses the imperative, present tense: "change", not "changed" or - "changes". - - - includes motivation for the change, and contrasts its - implementation with the previous behavior. - - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. - - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - - - When introducing a new feature, make sure it is properly - documented in the README.md - - * Submission: - - * Pre-requisites: - - - Make sure you have a [GitHub account](https://github.com/join) - - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. - - * Preferred method: - - - Fork the repository on GitHub. - - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). - - - Submit a pull request to the repository in the puppetlabs - organization. - -The long version -================ - - 1. Make separate commits for logically separate changes. - - Please break your commits down into logically consistent units - which include new or changed tests relevant to the rest of the - change. The goal of doing this is to make the diff easier to - read for whoever is reviewing your code. In general, the easier - your diff is to read, the more likely someone will be happy to - review it and get it into the code base. - - If you are going to refactor a piece of code, please do so as a - separate commit from your feature or bug fix changes. - - We also really appreciate changes that include tests to make - sure the bug is not re-introduced, and that the feature is not - accidentally broken. - - Describe the technical detail of the change(s). If your - description starts to get too long, that is a good sign that you - probably need to split up your commit into more finely grained - pieces. - - Commits which plainly describe the things which help - reviewers check the patch and future developers understand the - code are much more likely to be merged in with a minimum of - bike-shedding or requested changes. Ideally, the commit message - would include information, and be in a form suitable for - inclusion in the release notes for the version of Puppet that - includes them. - - Please also check that you are not introducing any trailing - whitespace or other "whitespace errors". You can do this by - running "git diff --check" on your changes before you commit. - - 2. Sending your patches - - To submit your changes via a GitHub pull request, we _highly_ - recommend that you have them on a topic branch, instead of - directly on "master". - It makes things much easier to keep track of, especially if - you decide to work on another thing before your first change - is merged in. - - GitHub has some pretty good - [general documentation](http://help.github.com/) on using - their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). - - In general, after pushing your topic branch up to your - repository on GitHub, you can switch to the branch in the - GitHub UI and click "Pull Request" towards the top of the page - in order to open a pull request. - - - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you - submitted, then you should update the ticket to include the - location of your branch, along with any other commentary you - may wish to make. - -Testing -======= - -Getting Started ---------------- - -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, -or Gems, are required to build, develop, and test this software. - -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running - -```shell -% bundle install -Fetching gem metadata from https://rubygems.org/........ -Fetching gem metadata from https://rubygems.org/.. -Using rake (10.1.0) -Using builder (3.2.2) --- 8><-- many more --><8 -- -Using rspec-system-puppet (2.2.0) -Using serverspec (0.6.3) -Using rspec-system-serverspec (1.0.0) -Using bundler (1.3.5) -Your bundle is complete! -Use `bundle show [gemname]` to see where a bundled gem is installed. -``` - -NOTE some systems may require you to run this command with sudo. - -If you already have those gems installed, make sure they are up-to-date: - -```shell -% bundle update -``` - -With all dependencies in place and up-to-date we can now run the tests: - -```shell -% bundle exec rake spec -``` - -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), -rspec tests define them in [.fixtures.yml](./fixtures.yml). - -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. - -You can run them by issuing the following command - -```shell -% bundle exec rake spec_clean -% bundle exec rspec spec/acceptance -``` - -This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) -and then run all the tests under [spec/acceptance](./spec/acceptance). - -Writing Tests -------------- - -XXX getting started writing tests. - -If you have commit access to the repository -=========================================== - -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. - -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. - - -Additional Resources -==================== - -* [Getting additional help](http://puppet.com/community/get-help) - -* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) - -* [General GitHub documentation](http://help.github.com/) - -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - diff --git a/vagrant/puppet/modules/apt/Gemfile b/vagrant/puppet/modules/apt/Gemfile deleted file mode 100644 index c97275bd8..000000000 --- a/vagrant/puppet/modules/apt/Gemfile +++ /dev/null @@ -1,48 +0,0 @@ -#This file is generated by ModuleSync, do not edit. - -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -def location_from_env(env, default_location = []) - if location = ENV[env] - if location =~ /^((?:git|https?)[:@][^#]*)#(.*)/ - [{ :git => $1, :branch => $2, :require => false }] - elsif location =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] - else - [location, { :require => false }] - end - else - default_location - end -end - -group :development, :unit_tests do - gem 'metadata-json-lint' - gem 'puppet_facts' - gem 'puppet-blacksmith', '>= 3.4.0' - gem 'puppetlabs_spec_helper', '>= 1.2.1' - gem 'rspec-puppet', '>= 2.3.2' - gem 'rspec-puppet-facts' - gem 'simplecov' - gem 'parallel_tests' - gem 'rubocop', '0.41.2' if RUBY_VERSION < '2.0.0' - gem 'rubocop' if RUBY_VERSION >= '2.0.0' - gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0' - gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0' -end -group :system_tests do - gem 'beaker', *location_from_env('BEAKER_VERSION', []) if RUBY_VERSION >= '2.3.0' - gem 'beaker', *location_from_env('BEAKER_VERSION', ['< 3']) if RUBY_VERSION < '2.3.0' - gem 'beaker-rspec', *location_from_env('BEAKER_RSPEC_VERSION', ['>= 3.4']) - gem 'serverspec' - gem 'beaker-puppet_install_helper' - gem 'master_manipulator' - gem 'beaker-hostgenerator', *location_from_env('BEAKER_HOSTGENERATOR_VERSION', []) -end - -gem 'facter', *location_from_env('FACTER_GEM_VERSION') -gem 'puppet', *location_from_env('PUPPET_GEM_VERSION') - -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end diff --git a/vagrant/puppet/modules/apt/LICENSE b/vagrant/puppet/modules/apt/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vagrant/puppet/modules/apt/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vagrant/puppet/modules/apt/NOTICE b/vagrant/puppet/modules/apt/NOTICE deleted file mode 100644 index 8da18e1c7..000000000 --- a/vagrant/puppet/modules/apt/NOTICE +++ /dev/null @@ -1,40 +0,0 @@ -apt puppet module - -Copyright (C) 2014-2016 Puppet Labs, Inc. - -Puppet Labs can be contacted at: info@puppetlabs.com - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - - -Copyright (c) 2011 Evolving Web Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vagrant/puppet/modules/apt/README.md b/vagrant/puppet/modules/apt/README.md deleted file mode 100644 index 2c1d3e39a..000000000 --- a/vagrant/puppet/modules/apt/README.md +++ /dev/null @@ -1,527 +0,0 @@ -# apt - -#### Table of Contents - - -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with apt](#setup) - * [What apt affects](#what-apt-affects) - * [Beginning with apt](#beginning-with-apt) -4. [Usage - Configuration options and additional functionality](#usage) - * [Add GPG keys](#add-gpg-keys) - * [Prioritize backports](#prioritize-backports) - * [Update the list of packages](#update-the-list-of-packages) - * [Pin a specific release](#pin-a-specific-release) - * [Add a Personal Package Archive repository](#add-a-personal-package-archive-repository) - * [Configure Apt from Hiera](#configure-apt-from-hiera) - * [Replace the default sources.list file](#replace-the-default-sourceslist-file) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Classes](#classes) - * [Defined Types](#defined-types) - * [Types](#types) - * [Facts](#facts) -6. [Limitations - OS compatibility, etc.](#limitations) -7. [Development - Guide for contributing to the module](#development) - -## Module Description - -The apt module lets you use Puppet to manage Apt sources, keys, and other configuration options. - -Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. - -**Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. - -## Setup - -### What apt affects - -* Your system's `preferences` file and `preferences.d` directory -* Your system's `sources.list` file and `sources.list.d` directory -* System repositories -* Authentication keys - -**Note:** This module offers `purge` parameters which, if set to 'true', **destroy** any configuration on the node's `sources.list(.d)` and `preferences(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. - -### Beginning with apt - -To use the apt module with default parameters, declare the `apt` class. - -```puppet -include apt -``` - -**Note:** The main `apt` class is required by all other classes, types, and defined types in this module. You must declare it whenever you use the module. - -## Usage - -### Add GPG keys - -**Warning:** Using short key IDs presents a serious security issue, potentially leaving you open to collision attacks. We recommend you always use full fingerprints to identify your GPG keys. This module allows short keys, but issues a security warning if you use them. - -Declare the `apt::key` class: - -```puppet -apt::key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'pgp.mit.edu', - options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', -} -``` - -### Prioritize backports - -```puppet -class { 'apt::backports': - pin => 500, -} -``` - -By default, the `apt::backports` class drops a pin file for backports, pinning it to a priority of 200. This is lower than the normal default of 500, so packages with `ensure => latest` don't get upgraded from backports without your explicit permission. - -If you raise the priority through the `pin` parameter to 500, normal policy goes into effect and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. - -### Update the list of packages - -By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': - -```puppet -class { 'apt': - update => { - frequency => 'daily', - }, -} -``` - -### Pin a specific release - -```puppet -apt::pin { 'karmic': priority => 700 } -apt::pin { 'karmic-updates': priority => 700 } -apt::pin { 'karmic-security': priority => 700 } -``` - -You can also specify more complex pins using distribution properties: - -```puppet -apt::pin { 'stable': - priority => -10, - originator => 'Debian', - release_version => '3.0', - component => 'main', - label => 'Debian' -} -``` - -To pin multiple packages, pass them to the `packages` parameter as an array or a space-delimited string. - -### Add a Personal Package Archive repository - -```puppet -apt::ppa { 'ppa:drizzle-developers/ppa': } -``` - -### Add an Apt source to `/etc/apt/sources.list.d/` - -```puppet -apt::source { 'debian_unstable': - comment => 'This is the iWeb Debian unstable mirror', - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - pin => '-10', - key => { - 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - 'server' => 'subkeys.pgp.net', - }, - include => { - 'src' => true, - 'deb' => true, - }, -} -``` - -To use the Puppet Labs Apt repository as a source: - -```puppet -apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => { - 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - 'server' => 'pgp.mit.edu', - }, -}, -``` - -### Configure Apt from Hiera - -Instead of specifying your sources directly as resources, you can instead just -include the `apt` class, which will pick up the values automatically from -hiera. - -```yaml -apt::sources: - 'debian_unstable': - comment: 'This is the iWeb Debian unstable mirror' - location: 'http://debian.mirror.iweb.ca/debian/' - release: 'unstable' - repos: 'main contrib non-free' - pin: '-10' - key: - id: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' - server: 'subkeys.pgp.net' - include: - src: true - deb: true - - 'puppetlabs': - location: 'http://apt.puppetlabs.com' - repos: 'main' - key: - id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - server: 'pgp.mit.edu' -``` - -### Replace the default sources.list file - -The following example replaces the default `/etc/apt/sources.list`. Along with this code, be sure to use the `purge` parameter, or you might get duplicate source warnings when running Apt. - -```puppet -apt::source { "archive.ubuntu.com-${lsbdistcodename}": - location => 'http://archive.ubuntu.com/ubuntu', - key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos => 'main universe multiverse restricted', -} - -apt::source { "archive.ubuntu.com-${lsbdistcodename}-security": - location => 'http://archive.ubuntu.com/ubuntu', - key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-security" -} - -apt::source { "archive.ubuntu.com-${lsbdistcodename}-updates": - location => 'http://archive.ubuntu.com/ubuntu', - key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-updates" -} - -apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports": - location => 'http://archive.ubuntu.com/ubuntu', - key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-backports" -} -``` - -## Reference - -### Classes - -#### Public Classes - -* [`apt`](#class-apt) -* [`apt::backports`](#class-aptbackports) - -#### Private Classes - -* `apt::params`: Provides defaults for the apt module parameters. -* `apt::update`: Updates the list of available packages using `apt-get update`. - -### Defined Types - -* [`apt::conf`](#defined-type-aptconf) -* [`apt::key`](#defined-type-aptkey) -* [`apt::pin`](#defined-type-aptpin) -* [`apt::ppa`](#defined-type-aptppa) -* [`apt::setting`](#defined-type-aptsetting) -* [`apt::source`](#defined-type-aptsource) - -### Types - -* [`apt_key`](#type-apt_key) - -### Facts - -* `apt_updates`: The number of installed packages with available updates. - -* `apt_security_updates`: The number of installed packages with available security updates. - -* `apt_package_updates`: The names of all installed packages with available updates. In Facter 2.0 and later this data is formatted as an array; in earlier versions it is a comma-delimited string. - -* `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run (based on the mtime of /var/lib/apt/periodic/update-success-stamp). - -* `apt_reboot_required`: Determines if a reboot is necessary after updates have been installed. - -#### Class: `apt` - -Main class, includes all other classes. - -##### Parameters (all optional) - -* `confs`: Creates new `apt::conf` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `keys`: Creates new `apt::key` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `ppas`: Creates new `apt::ppa` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `proxy`: Configures Apt to connect to a proxy server. Valid options: a hash made up from the following keys: - - * 'host': Specifies a proxy host to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a hostname. Default: undef. - - * 'port': Specifies a proxy port to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a port number. Default: '8080'. - - * 'https': Specifies whether to enable https proxies. Valid options: 'true' and 'false'. Default: 'false'. - - * 'ensure': Optional parameter. Valid options: 'file', 'present', and 'absent'. Default: 'undef'. Prefer 'file' over 'present'. - -* `purge`: Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys: - - * 'sources.list': Specifies whether to purge any unmanaged entries from `sources.list`. Valid options: 'true' and 'false'. Default: 'false'. - - * 'sources.list.d': Specifies whether to purge any unmanaged entries from `sources.list.d`. Valid options: 'true' and 'false'. Default: 'false'. - - * 'preferences': Specifies whether to purge any unmanaged entries from `preferences`. Valid options: 'true' and 'false'. Default: 'false'. - - * 'preferences.d': Specifies whether to purge any unmanaged entries from `preferences.d`. Valid options: 'true' and 'false'. Default: 'false'. - -* `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `sources`: Creates new `apt::source` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `pins`: Creates new `apt::pin` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. - -* `update`: Configures various update settings. Valid options: a hash made up from the following keys: - - * 'frequency': Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400); 'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource `apt_update` is notified). Default: 'reluctantly'. - - * 'timeout': Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: 300. - - * 'tries': Specifies how many times to retry the update after receiving a DNS or HTTP error. Valid options: an integer. Default: 1. - -#### Class: `apt::backports` - -Manages backports. - -##### Parameters (all optional on Debian and Ubuntu; all required on other operating systems, except where specified) - -* `key`: Specifies a key to authenticate the backports. Valid options: a string to be passed to the `id` parameter of the `apt::key` defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Defaults: - - * Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' - * Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5' - -* `location`: Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Defaults: - - * Debian (squeeze): 'http://httpredir.debian.org/debian-backports' - * Debian (other): 'http://httpredir.debian.org/debian' - * Ubuntu: 'http://archive.ubuntu.com/ubuntu' - -* `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. - -* `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. - -* `repos`: Specifies a component of the Apt repository containing the backports to manage. Valid options: A string containing the repos to include, used in populating the `source.list` configuration file. Defaults: - - * Debian: 'main contrib non-free' - * Ubuntu: 'main universe multiverse restricted' - -#### Defined Type: `apt::conf` - -Specifies a custom Apt configuration file. - -##### Parameters - -* `content`: *Required, unless `ensure` is set to 'absent'.* Directly supplies content for the configuration file. Valid options: a string. Default: undef. - -* `ensure`: Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. Default: 'present'. - -* `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'. - -* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. - -#### Defined Type: `apt::key` - -Manages the GPG keys that Apt uses to authenticate packages. - -The `apt::key` defined type makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. - -##### Parameters (all optional) - -* `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. - -* `ensure`: Specifies whether the key should exist. Valid options: 'present' and 'absent'. Default: 'present'. - -* `id`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: $title. - -* `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. - -* `source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. - -* `server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. - -* `key`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: undef. **Note** This parameter is deprecated and will be removed in a future release. - -* `key_content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. - -* `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. - -* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. **Note** This parameter is deprecated and will be removed in a future release. - -* `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. - -#### Defined Type: `apt::pin` - -Manages Apt pins. Does not trigger an `apt-get update` run. - -**Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences) - -##### Parameters (all optional) - -* `codename`: Specifies the distribution (lsbdistcodename) of the Apt repository. Valid options: a string. Default: ''. - -* `component`: Names the licensing component associated with the packages in the directory tree of the Release file. Valid options: a string. Default: ''. - -* `ensure`: Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. Default: 'present'. - -* `explanation`: Supplies a comment to explain the pin. Valid options: a string. Default: "${caller_module_name}: ${name}". - -* `label`: Names the label of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. - -* `order`: Determines the order in which Apt processes the pin file. Files with lower order numbers are loaded first. Valid options: an integer. Default: 50. - -* `origin`: Tells Apt to prefer packages from the specified server. Valid options: a string containing a hostname. Default: ''. - -* `originator`: Names the originator of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. - -* `packages`: Specifies which package(s) to pin. Valid options: a string or an array. Default: '*'. - -* `priority`: Sets the priority of the package. If multiple versions of a given package are available, `apt-get` installs the one with the highest priority number (subject to dependency constraints). Valid options: an integer. Default: 0. - -* `release`: Tells Apt to prefer packages that support the specified release. Typical values include 'stable', 'testing', and 'unstable' Valid options: a string. Default: ''. - -* `release_version`: Tells Apt to prefer packages that support the specified operating system release version (e.g., Debian release version 7). Valid options: a string. Default: ''. - -* `version`: Tells Apt to prefer a specified package version or version range. Valid options: a string. Default: ''. - -#### Defined Type: `apt::ppa` - -Manages PPA repositories using `add-apt-repository`. Not supported on Debian. - -##### Parameters (all optional, except where specified) - -* `ensure`: Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. Default: 'present'. - -* `options`: Supplies options to be passed to the `add-apt-repository` command. Valid options: a string. Defaults: - - * Lucid: undef - * All others: '-y' - -* `package_manage`: Specifies whether Puppet should manage the package that provides `apt-add-repository`. Valid options: 'true' and 'false'. Default: 'false'. - -* `package_name`: Names the package that provides the `apt-add-repository` command. Valid options: a string. Defaults: - - * Lucid and Precise: 'python-software-properties' - * Trusty and newer: 'software-properties-common' - * All others: 'python-software-properties' - -* `release`: *Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).* Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. Default: "$lsbdistcodename". - -#### Defined Type: `apt::setting` - -Manages Apt configuration files. - -##### Parameters - -* `content`: *Required, unless `source` is set.* Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid options: see the `content` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-content). Default: undef. - -* `ensure`: Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'. Default: 'file'. - -* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. - -* `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first. Valid options: an integer or zero-padded integer. Default: 50. - -* `source`: *Required, unless `content` is set.* Specifies a source file to supply the content of the configuration file. Cannot be used in combination with `content`. Valid options: see the `source` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source). Default: undef. - -#### Defined Type: `apt::source` - -Manages the Apt sources in `/etc/apt/sources.list.d/`. - -##### Parameters (all optional, except where specified) - -* `allow_unsigned`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: 'false'. - -* `architecture`: Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option). - -* `comment`: Supplies a comment for adding to the Apt source file. Valid options: a string. Default: $name. - -* `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: 'present'. - -* `key`: Creates a declaration of the apt::key defined type. Valid options: a string to be passed to the `id` parameter of the `apt::key` defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. - -* `include`: Configures include options. Valid options: a hash of available keys. Default: {}. Available keys are: - - * 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. - - * 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. - -* `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. - -* `pin`: Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: undef. - -* `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". - - * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. - -* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `required_packages`: Installs packages required for this Apt source via an exec. Default: 'false'. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `key_content`: Specifies the content to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `key_server`: Specifies the server to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `key_source`: Specifies the source to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. - -* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module. - -* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. - -#### Type: `apt_key` - -Manages the GPG keys that Apt uses to authenticate packages. - -**Note:** In most cases, we recommend using the `apt::key` defined type. It makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. - -##### Parameters (all optional) - -* `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Cannot be used in combination with `source`. Valid options: a string. Default: undef. - -* `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. - -* `server`: Specifies a keyserver to provide Puppet's GPG key. Valid options: a string containing a domain name or a full URL. Default: 'keyserver.ubuntu.com'. - -* `source`: Specifies the location of an existing GPG key file to copy. Cannot be used in combination with `content`. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. - -## Limitations - -This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.04, 12.04, and 14.04. Testing on other platforms has been light and cannot be guaranteed. - -This module is not designed to be split across [run stages](https://docs.puppetlabs.com/puppet/latest/reference/lang_run_stages.html). - -### Adding new sources or PPAs - -If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior). - -```puppet -Class['apt::update'] -> Package <| provider == 'apt' |> -``` - -## Development -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) - -To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) diff --git a/vagrant/puppet/modules/apt/Rakefile b/vagrant/puppet/modules/apt/Rakefile deleted file mode 100644 index 3e8d4cb95..000000000 --- a/vagrant/puppet/modules/apt/Rakefile +++ /dev/null @@ -1,38 +0,0 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppetlabs_spec_helper/rake_tasks' - -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end - - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end - - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) - end - puts nodeset -end diff --git a/vagrant/puppet/modules/apt/checksums.json b/vagrant/puppet/modules/apt/checksums.json deleted file mode 100644 index acd4e4eec..000000000 --- a/vagrant/puppet/modules/apt/checksums.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "CHANGELOG.md": "c24929dfaaca5ff8da267a78d798a9ad", - "CONTRIBUTING.md": "b78f71c1104f00538d50ad2775f58e95", - "Gemfile": "d197734139f44a800a88d49ad4c34192", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "NOTICE": "f0fd8d07c4a816a2655400c7403db877", - "README.md": "cc9b74db429f73efea640b9e17cbd190", - "Rakefile": "6db744f1deed7ae0746abe59e3d50863", - "examples/backports.pp": "af57ea62ed1b73f540858e00327e6517", - "examples/builddep.pp": "eddb8b7d7c0ef7383d85a74c1cd0de3f", - "examples/debian_testing.pp": "2e50a41180e2afeac2de15ade05ddaa1", - "examples/debian_unstable.pp": "82890803cc4423443db8f40353e16262", - "examples/disable_keys.pp": "3d4e7ac49946d961ff51a719ee713293", - "examples/fancy_progress.pp": "9a55d4ea52be4ebd670befff7ca3b87f", - "examples/force.pp": "f71857eba704a0eb3d8d6b146e80da6d", - "examples/hold.pp": "5e58e0a30d6407a05691d96c7647ae14", - "examples/key.pp": "a530d40c487e7e5ecee6b01a0c082012", - "examples/pin.pp": "4b4c3612d75a19dba8eb7227070fa4ab", - "examples/ppa.pp": "b902cce8159128b5e8b21bed540743ff", - "examples/release.pp": "2bc960babf8c4dd24b7ffa4220a601f8", - "examples/source.pp": "485c64e5d2ea69e238b68fac837714c3", - "examples/unattended_upgrades.pp": "e7a797388ef03077f110f4f268f5ecd1", - "lib/facter/apt_reboot_required.rb": "7c3fc46f254fc4b4579d011578caaadb", - "lib/facter/apt_update_last_success.rb": "2926ff059cd2f63a2a7824ba898837f9", - "lib/facter/apt_updates.rb": "2662a82fe574e565d225f7838278d9eb", - "lib/puppet/provider/apt_key/apt_key.rb": "f6ad8e3cacfa8a199921730d61e96105", - "lib/puppet/type/apt_key.rb": "b167dc62db19a482a5b46abf3095904b", - "lib/puppet_x/apt_key/patch_openuri.rb": "951bad007a3b5db035be069c1d1c9c09", - "manifests/backports.pp": "7d4a6e58ae3dc364e6279358e4f4b957", - "manifests/conf.pp": "f2da7513dc9ac2d0e6f702ea01eb0501", - "manifests/init.pp": "7d18b442184fe82fdd5287555ee32135", - "manifests/key.pp": "7181cd40208e5228059c5cdb6bba8a08", - "manifests/params.pp": "0d4669cb467dd39294d0974de9718d3e", - "manifests/pin.pp": "dbba5555b65c0beb56bbfb71b24a7878", - "manifests/ppa.pp": "b0de5cc9759cc08481ceee558a29e031", - "manifests/setting.pp": "cde5492c31b2b94c49bf67c7c96a6058", - "manifests/source.pp": "95184d85bf526d931223b96faf38f9bf", - "manifests/update.pp": "93f132802d6280debfc46b35c656486f", - "metadata.json": "94a865f92f99ff21fd5f3853cbd4e080", - "spec/acceptance/apt_key_provider_spec.rb": "8252cd4d80c435b0e22cc2a04b93aad9", - "spec/acceptance/apt_spec.rb": "bd023d4dff35f45dbab664d68f3e3995", - "spec/acceptance/class_spec.rb": "7fa3ee3cade5e27891fe01aa8af8941d", - "spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd", - "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", - "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808", - "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", - "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", - "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/classes/apt_backports_spec.rb": "782f04ee20f75a4af29c3d91d0128ae0", - "spec/classes/apt_spec.rb": "73c77f93c196bf3fb81058df09b06c9b", - "spec/classes/apt_update_spec.rb": "e1bae3848f53c709a14c1e6def93865e", - "spec/classes/params_spec.rb": "7691f074096952a2996b3648d5ef43cd", - "spec/defines/conf_spec.rb": "4c07a034a6e55098962535d5dca611b0", - "spec/defines/key_compat_spec.rb": "da0d6160c3c427997d62b29a4c1c3cb5", - "spec/defines/key_spec.rb": "5506adba2c05c13356bbf1a9f1c91c72", - "spec/defines/pin_spec.rb": "5a3866f7a49f88e6e14e3335872e387b", - "spec/defines/ppa_spec.rb": "d68d807e9979b92d2526c6d1a76875eb", - "spec/defines/setting_spec.rb": "740578ed09763c7573c0bfafab6c94a1", - "spec/defines/source_compat_spec.rb": "11c684da04726e3638951bab0508667a", - "spec/defines/source_spec.rb": "305c708509478255a00ee5e127db634e", - "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "2d4884491c0eed85a780cbe694074945", - "spec/unit/facter/apt_has_updates_spec.rb": "8294711c589fb1efa9aa23be0faf8500", - "spec/unit/facter/apt_package_updates_spec.rb": "2a0549f8656f094d9d0006ce12f61b2c", - "spec/unit/facter/apt_reboot_required_spec.rb": "9d58cb2aeaed624f7c4ca118ec1b6410", - "spec/unit/facter/apt_security_updates_spec.rb": "ec8a6711feac739866743dfaf4baf3d0", - "spec/unit/facter/apt_update_last_success_spec.rb": "cbc907ca27e6f9bb803fa9654c4a1836", - "spec/unit/facter/apt_updates_spec.rb": "ffde1130fda5990d2786ff7878ade5e0", - "spec/unit/puppet/type/apt_key_spec.rb": "986c3cf60937eb89cbf6335dc7923dc5", - "templates/15update-stamp.erb": "b9de0ac9e2c9854b1bb213e362dc4e41", - "templates/_conf_header.erb": "6f3077f2eabd3e929a44d55bc1c5446e", - "templates/_header.erb": "9300ac105fe777787ac9e793b8df8d25", - "templates/conf.erb": "b4bc626b0d998cd681ee6b8c507c0d1d", - "templates/pin.pref.erb": "c3885c6816db46cf66e3a9bf57973c61", - "templates/proxy.erb": "3d0f7b88020d8a29bafc690e05ca69d6", - "templates/source.list.erb": "72648dd11918d5c03db82065d3bef73b" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/apt/examples/backports.pp b/vagrant/puppet/modules/apt/examples/backports.pp deleted file mode 100644 index 5f1f1ee18..000000000 --- a/vagrant/puppet/modules/apt/examples/backports.pp +++ /dev/null @@ -1,11 +0,0 @@ -# Set up a backport for linuxmint qiana -class { 'apt': } -apt::backports { 'qiana': - location => 'http://us.archive.ubuntu.com/ubuntu', - release => 'trusty-backports', - repos => 'main universe multiverse restricted', - key => { - id => '630239CC130E1A7FD81A27B140976EAF437D05B5', - server => 'hkps.pool.sks-keyservers.net', - }, -} diff --git a/vagrant/puppet/modules/apt/examples/builddep.pp b/vagrant/puppet/modules/apt/examples/builddep.pp deleted file mode 100644 index deaaef8c8..000000000 --- a/vagrant/puppet/modules/apt/examples/builddep.pp +++ /dev/null @@ -1,3 +0,0 @@ -package{ 'glusterfs-server': - install_options => 'build-dep', -} diff --git a/vagrant/puppet/modules/apt/examples/debian_testing.pp b/vagrant/puppet/modules/apt/examples/debian_testing.pp deleted file mode 100644 index 3ed98f21f..000000000 --- a/vagrant/puppet/modules/apt/examples/debian_testing.pp +++ /dev/null @@ -1,18 +0,0 @@ -package { 'debian-keyring': - ensure => present -} - -package { 'debian-archive-keyring': - ensure => present -} - -apt::source { 'debian_testing': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'testing', - repos => 'main contrib non-free', - pin => '-10', - key => { - id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - server => 'subkeys.pgp.net', - }, -} diff --git a/vagrant/puppet/modules/apt/examples/debian_unstable.pp b/vagrant/puppet/modules/apt/examples/debian_unstable.pp deleted file mode 100644 index b1492cd53..000000000 --- a/vagrant/puppet/modules/apt/examples/debian_unstable.pp +++ /dev/null @@ -1,18 +0,0 @@ -package { 'debian-keyring': - ensure => present -} - -package { 'debian-archive-keyring': - ensure => present -} - -apt::source { 'debian_unstable': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - pin => '-10', - key => { - id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - server => 'subkeys.pgp.net', - }, -} diff --git a/vagrant/puppet/modules/apt/examples/disable_keys.pp b/vagrant/puppet/modules/apt/examples/disable_keys.pp deleted file mode 100644 index 50d0ea802..000000000 --- a/vagrant/puppet/modules/apt/examples/disable_keys.pp +++ /dev/null @@ -1,5 +0,0 @@ -#Note: This is generally a bad idea. You should not disable verifying repository signatures. -apt::conf { 'unauth': - priority => 99, - content => 'APT::Get::AllowUnauthenticated 1;' -} diff --git a/vagrant/puppet/modules/apt/examples/fancy_progress.pp b/vagrant/puppet/modules/apt/examples/fancy_progress.pp deleted file mode 100644 index db78441b6..000000000 --- a/vagrant/puppet/modules/apt/examples/fancy_progress.pp +++ /dev/null @@ -1,4 +0,0 @@ -apt::conf { 'progressbar': - priority => 99, - content => 'Dpkg::Progress-Fancy "1";', -} diff --git a/vagrant/puppet/modules/apt/examples/force.pp b/vagrant/puppet/modules/apt/examples/force.pp deleted file mode 100644 index 4cfaa96fd..000000000 --- a/vagrant/puppet/modules/apt/examples/force.pp +++ /dev/null @@ -1,28 +0,0 @@ -#if you need to specify a release -$rel_string = '-t ' -#else -$rel_string = '' - -#if you need to specify a version -$ensure = '' -#else -$ensure = installed - -#if overwrite existing cfg files -$config_files = '-o Dpkg::Options::="--force-confnew"' -#elsif force use of old files -$config_files = '-o Dpkg::Options::="--force-confold"' -#elsif update only unchanged files -$config_files = '-o Dpkg::Options::="--force-confdef"' -#else -$config_files = '' - -#if install missing configuration files for the package -$config_missing = '-o Dpkg::Options::="--force-confmiss"' -#else -$config_missing = '' - -package { '': - ensure => $ensure, - install_options => "${config_files} ${config_missing} ${rel_string}", -} diff --git a/vagrant/puppet/modules/apt/examples/hold.pp b/vagrant/puppet/modules/apt/examples/hold.pp deleted file mode 100644 index 00f760c4e..000000000 --- a/vagrant/puppet/modules/apt/examples/hold.pp +++ /dev/null @@ -1,5 +0,0 @@ -apt::pin { 'hold-vim': - packages => 'vim', - version => '2:7.4.488-5', - priority => 1001, -} diff --git a/vagrant/puppet/modules/apt/examples/key.pp b/vagrant/puppet/modules/apt/examples/key.pp deleted file mode 100644 index 18c2dd039..000000000 --- a/vagrant/puppet/modules/apt/examples/key.pp +++ /dev/null @@ -1,6 +0,0 @@ -# Declare Apt key for apt.puppetlabs.com source -apt::key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'hkps.pool.sks-keyservers.net', - options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', -} diff --git a/vagrant/puppet/modules/apt/examples/pin.pp b/vagrant/puppet/modules/apt/examples/pin.pp deleted file mode 100644 index 6a9024c23..000000000 --- a/vagrant/puppet/modules/apt/examples/pin.pp +++ /dev/null @@ -1,5 +0,0 @@ -# pin a release in apt, useful for unstable repositories -apt::pin { 'foo': - packages => '*', - priority => 0, -} diff --git a/vagrant/puppet/modules/apt/examples/ppa.pp b/vagrant/puppet/modules/apt/examples/ppa.pp deleted file mode 100644 index e728f6f10..000000000 --- a/vagrant/puppet/modules/apt/examples/ppa.pp +++ /dev/null @@ -1,4 +0,0 @@ -class { 'apt': } - -# Example declaration of an Apt PPA -apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } diff --git a/vagrant/puppet/modules/apt/examples/release.pp b/vagrant/puppet/modules/apt/examples/release.pp deleted file mode 100644 index 46d6893b0..000000000 --- a/vagrant/puppet/modules/apt/examples/release.pp +++ /dev/null @@ -1,4 +0,0 @@ -apt::conf { 'release': - content => 'APT::Default-Release "karmic";', - priority => '01', -} diff --git a/vagrant/puppet/modules/apt/examples/source.pp b/vagrant/puppet/modules/apt/examples/source.pp deleted file mode 100644 index 86cab2f2d..000000000 --- a/vagrant/puppet/modules/apt/examples/source.pp +++ /dev/null @@ -1,35 +0,0 @@ -# Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d -class { 'apt': } - -# Install the puppetlabs apt source -# Release is automatically obtained from lsbdistcodename fact if available. -apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => { - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'hkps.pool.sks-keyservers.net', - }, -} - -# test two sources with the same key -apt::source { 'debian_testing': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'testing', - repos => 'main contrib non-free', - key => { - id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - server => 'hkps.pool.sks-keyservers.net', - }, - pin => '-10', -} -apt::source { 'debian_unstable': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - key => { - id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - server => 'hkps.pool.sks-keyservers.net', - }, - pin => '-10', -} diff --git a/vagrant/puppet/modules/apt/examples/unattended_upgrades.pp b/vagrant/puppet/modules/apt/examples/unattended_upgrades.pp deleted file mode 100644 index 464090415..000000000 --- a/vagrant/puppet/modules/apt/examples/unattended_upgrades.pp +++ /dev/null @@ -1 +0,0 @@ -# TODO diff --git a/vagrant/puppet/modules/apt/lib/facter/apt_reboot_required.rb b/vagrant/puppet/modules/apt/lib/facter/apt_reboot_required.rb deleted file mode 100644 index 8de904af2..000000000 --- a/vagrant/puppet/modules/apt/lib/facter/apt_reboot_required.rb +++ /dev/null @@ -1,7 +0,0 @@ -# apt_reboot_required.rb -Facter.add(:apt_reboot_required) do - confine :osfamily => 'Debian' - setcode do - File.file?('/var/run/reboot-required') - end -end diff --git a/vagrant/puppet/modules/apt/lib/facter/apt_update_last_success.rb b/vagrant/puppet/modules/apt/lib/facter/apt_update_last_success.rb deleted file mode 100644 index 21c33d594..000000000 --- a/vagrant/puppet/modules/apt/lib/facter/apt_update_last_success.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'facter' - -#This is derived from the file /var/lib/apt/periodic/update-success-stamp -# This is generated upon a successful apt-get update run natively in ubuntu. -# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes -Facter.add('apt_update_last_success') do - confine :osfamily => 'Debian' - setcode do - if File.exists?('/var/lib/apt/periodic/update-success-stamp') - #get epoch time - lastsuccess = File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i - lastsuccess - else - lastsuccess = -1 - lastsuccess - end - end -end diff --git a/vagrant/puppet/modules/apt/lib/facter/apt_updates.rb b/vagrant/puppet/modules/apt/lib/facter/apt_updates.rb deleted file mode 100644 index e880fdf29..000000000 --- a/vagrant/puppet/modules/apt/lib/facter/apt_updates.rb +++ /dev/null @@ -1,57 +0,0 @@ -apt_package_updates = nil -Facter.add("apt_has_updates") do - confine :osfamily => 'Debian' - if File.executable?("/usr/bin/apt-get") - apt_get_result = Facter::Util::Resolution.exec('/usr/bin/apt-get -s upgrade 2>&1') - if not apt_get_result.nil? - apt_package_updates = [[], []] - apt_get_result.each_line do |line| - if line =~ /^Inst\s/ - package = line.gsub(/^Inst\s([^\s]+)\s.*/, '\1').strip - apt_package_updates[0].push(package) - security_matches = [ - / Debian[^\s]+-updates /, - / Debian-Security:/, - / Ubuntu[^\s]+-security /, - / gNewSense[^\s]+-security / - ] - re = Regexp.union(security_matches) - if line.match(re) - apt_package_updates[1].push(package) - end - end - end - end - end - - setcode do - if not apt_package_updates.nil? and apt_package_updates.length == 2 - apt_package_updates != [[], []] - end - end -end - -Facter.add("apt_package_updates") do - confine :apt_has_updates => true - setcode do - if Facter.version < '2.0.0' - apt_package_updates[0].join(',') - else - apt_package_updates[0] - end - end -end - -Facter.add("apt_updates") do - confine :apt_has_updates => true - setcode do - Integer(apt_package_updates[0].length) - end -end - -Facter.add("apt_security_updates") do - confine :apt_has_updates => true - setcode do - Integer(apt_package_updates[1].length) - end -end diff --git a/vagrant/puppet/modules/apt/lib/puppet/provider/apt_key/apt_key.rb b/vagrant/puppet/modules/apt/lib/puppet/provider/apt_key/apt_key.rb deleted file mode 100644 index a6d68b173..000000000 --- a/vagrant/puppet/modules/apt/lib/puppet/provider/apt_key/apt_key.rb +++ /dev/null @@ -1,225 +0,0 @@ -require 'open-uri' -require 'net/ftp' -require 'tempfile' - -if RUBY_VERSION == '1.8.7' - # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be - # monkeypatched to support passing in :ftp_passive_mode. - require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', - 'puppet_x', 'apt_key', 'patch_openuri.rb')) - OpenURI::Options.merge!({:ftp_active_mode => false,}) -end - -Puppet::Type.type(:apt_key).provide(:apt_key) do - - confine :osfamily => :debian - defaultfor :osfamily => :debian - commands :apt_key => 'apt-key' - commands :gpg => '/usr/bin/gpg' - - def self.instances - cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'] - - if RUBY_VERSION > '1.8.7' - key_output = apt_key(cli_args).encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') - else - key_output = apt_key(cli_args) - end - - pub_line, fpr_line = nil - - key_array = key_output.split("\n").collect do |line| - if line.start_with?('pub') - pub_line = line - elsif line.start_with?('fpr') - fpr_line = line - end - - next unless (pub_line and fpr_line) - - line_hash = key_line_hash(pub_line, fpr_line) - - # reset everything - pub_line, fpr_line = nil - - expired = false - - if line_hash[:key_expiry] - expired = Time.now >= line_hash[:key_expiry] - end - - new( - :name => line_hash[:key_fingerprint], - :id => line_hash[:key_long], - :fingerprint => line_hash[:key_fingerprint], - :short => line_hash[:key_short], - :long => line_hash[:key_long], - :ensure => :present, - :expired => expired, - :expiry => line_hash[:key_expiry].nil? ? nil : line_hash[:key_expiry].strftime("%Y-%m-%d"), - :size => line_hash[:key_size], - :type => line_hash[:key_type], - :created => line_hash[:key_created].strftime("%Y-%m-%d") - ) - end - key_array.compact! - end - - def self.prefetch(resources) - apt_keys = instances - resources.keys.each do |name| - if name.length == 40 - if provider = apt_keys.find{ |key| key.fingerprint == name } - resources[name].provider = provider - end - elsif name.length == 16 - if provider = apt_keys.find{ |key| key.long == name } - resources[name].provider = provider - end - elsif name.length == 8 - if provider = apt_keys.find{ |key| key.short == name } - resources[name].provider = provider - end - end - end - end - - def self.key_line_hash(pub_line, fpr_line) - pub_split = pub_line.split(':') - fpr_split = fpr_line.split(':') - - fingerprint = fpr_split.last - return_hash = { - :key_fingerprint => fingerprint, - :key_long => fingerprint[-16..-1], # last 16 characters of fingerprint - :key_short => fingerprint[-8..-1], # last 8 characters of fingerprint - :key_size => pub_split[2], - :key_type => nil, - :key_created => Time.at(pub_split[5].to_i), - :key_expiry => pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i), - } - - # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz - case pub_split[3] - when "1" - return_hash[:key_type] = :rsa - when "17" - return_hash[:key_type] = :dsa - when "18" - return_hash[:key_type] = :ecc - when "19" - return_hash[:key_type] = :ecdsa - end - - return return_hash - end - - def source_to_file(value) - parsedValue = URI::parse(value) - if parsedValue.scheme.nil? - fail("The file #{value} does not exist") unless File.exists?(value) - # Because the tempfile method has to return a live object to prevent GC - # of the underlying file from occuring too early, we also have to return - # a file object here. The caller can still call the #path method on the - # closed file handle to get the path. - f = File.open(value, 'r') - f.close - f - else - begin - key = parsedValue.read - rescue OpenURI::HTTPError, Net::FTPPermError => e - fail("#{e.message} for #{resource[:source]}") - rescue SocketError - fail("could not resolve #{resource[:source]}") - else - tempfile(key) - end - end - end - - # The tempfile method needs to return the tempfile object to the caller, so - # that it doesn't get deleted by the GC immediately after it returns. We - # want the caller to control when it goes out of scope. - def tempfile(content) - file = Tempfile.new('apt_key') - file.write content - file.close - #confirm that the fingerprint from the file, matches the long key that is in the manifest - if name.size == 40 - if File.executable? command(:gpg) - extracted_key = execute(["#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false) - extracted_key = extracted_key.chomp - - found_match = false - extracted_key.each_line do |line| - if line.chomp == name - found_match = true - end - end - if not found_match - fail("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") - end - else - warning('/usr/bin/gpg cannot be found for verification of the id.') - end - end - file - end - - def exists? - @property_hash[:ensure] == :present - end - - def create - command = [] - if resource[:source].nil? and resource[:content].nil? - # Breaking up the command like this is needed because it blows up - # if --recv-keys isn't the last argument. - command.push('adv', '--keyserver', resource[:server]) - unless resource[:options].nil? - command.push('--keyserver-options', resource[:options]) - end - command.push('--recv-keys', resource[:id]) - elsif resource[:content] - key_file = tempfile(resource[:content]) - command.push('add', key_file.path) - elsif resource[:source] - key_file = source_to_file(resource[:source]) - command.push('add', key_file.path) - # In case we really screwed up, better safe than sorry. - else - fail("an unexpected condition occurred while trying to add the key: #{resource[:id]}") - end - apt_key(command) - @property_hash[:ensure] = :present - end - - def destroy - begin - apt_key('del', resource.provider.short) - r = execute(["#{command(:apt_key)} list | grep '/#{resource.provider.short}\s'"], :failonfail => false) - end while r.exitstatus == 0 - @property_hash.clear - end - - def read_only(value) - fail('This is a read-only property.') - end - - mk_resource_methods - - # Needed until PUP-1470 is fixed and we can drop support for Puppet versions - # before that. - def expired - @property_hash[:expired] - end - - # Alias the setters of read-only properties - # to the read_only function. - alias :created= :read_only - alias :expired= :read_only - alias :expiry= :read_only - alias :size= :read_only - alias :type= :read_only -end diff --git a/vagrant/puppet/modules/apt/lib/puppet/type/apt_key.rb b/vagrant/puppet/modules/apt/lib/puppet/type/apt_key.rb deleted file mode 100644 index 81b66a263..000000000 --- a/vagrant/puppet/modules/apt/lib/puppet/type/apt_key.rb +++ /dev/null @@ -1,135 +0,0 @@ -require 'pathname' - -Puppet::Type.newtype(:apt_key) do - - @doc = <<-EOS - This type provides Puppet with the capabilities to manage GPG keys needed - by apt to perform package validation. Apt has it's own GPG keyring that can - be manipulated through the `apt-key` command. - - apt_key { '4BD6EC30': - source => 'http://apt.puppetlabs.com/pubkey.gpg' - } - - **Autorequires**: - - If Puppet is given the location of a key file which looks like an absolute - path this type will autorequire that file. - EOS - - ensurable - - validate do - if self[:content] and self[:source] - fail('The properties content and source are mutually exclusive.') - end - if self[:id].length < 40 - warning('The id should be a full fingerprint (40 characters), see README.') - end - end - - newparam(:id, :namevar => true) do - desc 'The ID of the key you want to manage.' - # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's - # and may start with the optional 0x, or they can be 40-digit key fingerprints - newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/) - munge do |value| - if value.start_with?('0x') - id = value.partition('0x').last.upcase - else - id = value.upcase - end - id - end - end - - newparam(:content) do - desc 'The content of, or string representing, a GPG key.' - end - - newparam(:source) do - desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://' - newvalues(/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/) - end - - autorequire(:file) do - if self[:source] and Pathname.new(self[:source]).absolute? - self[:source] - end - end - - newparam(:server) do - desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' - defaultto :'keyserver.ubuntu.com' - - newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) - end - - newparam(:options) do - desc 'Additional options to pass to apt-key\'s --keyserver-options.' - end - - newproperty(:fingerprint) do - desc <<-EOS - The 40-digit hexadecimal fingerprint of the specified GPG key. - - This property is read-only. - EOS - end - - newproperty(:long) do - desc <<-EOS - The 16-digit hexadecimal id of the specified GPG key. - - This property is read-only. - EOS - end - - newproperty(:short) do - desc <<-EOS - The 8-digit hexadecimal id of the specified GPG key. - - This property is read-only. - EOS - end - - newproperty(:expired) do - desc <<-EOS - Indicates if the key has expired. - - This property is read-only. - EOS - end - - newproperty(:expiry) do - desc <<-EOS - The date the key will expire, or nil if it has no expiry date. - - This property is read-only. - EOS - end - - newproperty(:size) do - desc <<-EOS - The key size, usually a multiple of 1024. - - This property is read-only. - EOS - end - - newproperty(:type) do - desc <<-EOS - The key type, one of: rsa, dsa, ecc, ecdsa - - This property is read-only. - EOS - end - - newproperty(:created) do - desc <<-EOS - Date the key was created. - - This property is read-only. - EOS - end -end diff --git a/vagrant/puppet/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb b/vagrant/puppet/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb deleted file mode 100644 index 722c7bdeb..000000000 --- a/vagrant/puppet/modules/apt/lib/puppet_x/apt_key/patch_openuri.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'uri' -require 'stringio' -require 'time' - -module URI - class FTP - def buffer_open(buf, proxy, options) # :nodoc: - if proxy - OpenURI.open_http(buf, self, proxy, options) - return - end - require 'net/ftp' - - directories = self.path.split(%r{/}, -1) - directories.shift if directories[0] == '' # strip a field before leading slash - directories.each {|d| - d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") } - } - unless filename = directories.pop - raise ArgumentError, "no filename: #{self.inspect}" - end - directories.each {|d| - if /[\r\n]/ =~ d - raise ArgumentError, "invalid directory: #{d.inspect}" - end - } - if /[\r\n]/ =~ filename - raise ArgumentError, "invalid filename: #{filename.inspect}" - end - typecode = self.typecode - if typecode && /\A[aid]\z/ !~ typecode - raise ArgumentError, "invalid typecode: #{typecode.inspect}" - end - - # The access sequence is defined by RFC 1738 - ftp = Net::FTP.open(self.host) - ftp.passive = true if !options[:ftp_active_mode] - # todo: extract user/passwd from .netrc. - user = 'anonymous' - passwd = nil - user, passwd = self.userinfo.split(/:/) if self.userinfo - ftp.login(user, passwd) - directories.each {|cwd| - ftp.voidcmd("CWD #{cwd}") - } - if typecode - # xxx: typecode D is not handled. - ftp.voidcmd("TYPE #{typecode.upcase}") - end - if options[:content_length_proc] - options[:content_length_proc].call(ftp.size(filename)) - end - ftp.retrbinary("RETR #{filename}", 4096) { |str| - buf << str - options[:progress_proc].call(buf.size) if options[:progress_proc] - } - ftp.close - buf.io.rewind - end - - include OpenURI::OpenRead - end -end diff --git a/vagrant/puppet/modules/apt/manifests/backports.pp b/vagrant/puppet/modules/apt/manifests/backports.pp deleted file mode 100644 index f7e85f59e..000000000 --- a/vagrant/puppet/modules/apt/manifests/backports.pp +++ /dev/null @@ -1,65 +0,0 @@ -class apt::backports ( - $location = undef, - $release = undef, - $repos = undef, - $key = undef, - $pin = 200, -){ - if $location { - validate_string($location) - $_location = $location - } - if $release { - validate_string($release) - $_release = $release - } - if $repos { - validate_string($repos) - $_repos = $repos - } - if $key { - unless is_hash($key) { - validate_string($key) - } - $_key = $key - } - if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') { - unless $location { - $_location = $::apt::backports['location'] - } - unless $release { - $_release = "${::apt::xfacts['lsbdistcodename']}-backports" - } - unless $repos { - $_repos = $::apt::backports['repos'] - } - unless $key { - $_key = $::apt::backports['key'] - } - } else { - unless $location and $release and $repos and $key { - fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key') - } - } - - if is_hash($pin) { - $_pin = $pin - } elsif is_numeric($pin) or is_string($pin) { - # apt::source defaults to pinning to origin, but we should pin to release - # for backports - $_pin = { - 'priority' => $pin, - 'release' => $_release, - } - } else { - fail('pin must be either a string, number or hash') - } - - apt::source { 'backports': - location => $_location, - release => $_release, - repos => $_repos, - key => $_key, - pin => $_pin, - } -} diff --git a/vagrant/puppet/modules/apt/manifests/conf.pp b/vagrant/puppet/modules/apt/manifests/conf.pp deleted file mode 100644 index 8cd9c64e7..000000000 --- a/vagrant/puppet/modules/apt/manifests/conf.pp +++ /dev/null @@ -1,20 +0,0 @@ -define apt::conf ( - $content = undef, - $ensure = present, - $priority = 50, - $notify_update = undef, -) { - - unless $ensure == 'absent' { - unless $content { - fail('Need to pass in content parameter') - } - } - - apt::setting { "conf-${name}": - ensure => $ensure, - priority => $priority, - content => template('apt/_conf_header.erb', 'apt/conf.erb'), - notify_update => $notify_update, - } -} diff --git a/vagrant/puppet/modules/apt/manifests/init.pp b/vagrant/puppet/modules/apt/manifests/init.pp deleted file mode 100644 index 5664edeed..000000000 --- a/vagrant/puppet/modules/apt/manifests/init.pp +++ /dev/null @@ -1,171 +0,0 @@ -# == Class: apt -# -# Manage APT (Advanced Packaging Tool) -# -class apt ( - $confs = {}, - $update = {}, - $purge = {}, - $proxy = {}, - $sources = {}, - $keys = {}, - $ppas = {}, - $pins = {}, - $settings = {}, -) inherits ::apt::params { - - $frequency_options = ['always','daily','weekly','reluctantly'] - validate_hash($update) - if $update['frequency'] { - validate_re($update['frequency'], $frequency_options) - } - if $update['timeout'] { - unless is_integer($update['timeout']) { - fail('timeout value for update must be an integer') - } - } - if $update['tries'] { - unless is_integer($update['tries']) { - fail('tries value for update must be an integer') - } - } - - $_update = merge($::apt::update_defaults, $update) - include ::apt::update - - validate_hash($purge) - if $purge['sources.list'] { - validate_bool($purge['sources.list']) - } - if $purge['sources.list.d'] { - validate_bool($purge['sources.list.d']) - } - if $purge['preferences'] { - validate_bool($purge['preferences']) - } - if $purge['preferences.d'] { - validate_bool($purge['preferences.d']) - } - - $_purge = merge($::apt::purge_defaults, $purge) - - validate_hash($proxy) - if $proxy['ensure'] { - validate_re($proxy['ensure'], ['file', 'present', 'absent']) - } - if $proxy['host'] { - validate_string($proxy['host']) - } - if $proxy['port'] { - unless is_integer($proxy['port']) { - fail('$proxy port must be an integer') - } - } - if $proxy['https'] { - validate_bool($proxy['https']) - } - - $_proxy = merge($apt::proxy_defaults, $proxy) - - validate_hash($confs) - validate_hash($sources) - validate_hash($keys) - validate_hash($settings) - validate_hash($ppas) - validate_hash($pins) - - if $_proxy['ensure'] == 'absent' or $_proxy['host'] { - apt::setting { 'conf-proxy': - ensure => $_proxy['ensure'], - priority => '01', - content => template('apt/_conf_header.erb', 'apt/proxy.erb'), - } - } - - $sources_list_content = $_purge['sources.list'] ? { - true => "# Repos managed by puppet.\n", - default => undef, - } - - $preferences_ensure = $_purge['preferences'] ? { - true => absent, - default => file, - } - - if $_update['frequency'] == 'always' { - Exec <| title=='apt_update' |> { - refreshonly => false, - } - } - - apt::setting { 'conf-update-stamp': - priority => 15, - content => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'), - } - - file { 'sources.list': - ensure => file, - path => $::apt::sources_list, - owner => root, - group => root, - mode => '0644', - content => $sources_list_content, - notify => Class['apt::update'], - } - - file { 'sources.list.d': - ensure => directory, - path => $::apt::sources_list_d, - owner => root, - group => root, - mode => '0644', - purge => $_purge['sources.list.d'], - recurse => $_purge['sources.list.d'], - notify => Class['apt::update'], - } - - file { 'preferences': - ensure => $preferences_ensure, - path => $::apt::preferences, - owner => root, - group => root, - mode => '0644', - notify => Class['apt::update'], - } - - file { 'preferences.d': - ensure => directory, - path => $::apt::preferences_d, - owner => root, - group => root, - mode => '0644', - purge => $_purge['preferences.d'], - recurse => $_purge['preferences.d'], - notify => Class['apt::update'], - } - - if $confs { - create_resources('apt::conf', $confs) - } - # manage sources if present - if $sources { - create_resources('apt::source', $sources) - } - # manage keys if present - if $keys { - create_resources('apt::key', $keys) - } - # manage ppas if present - if $ppas { - create_resources('apt::ppa', $ppas) - } - # manage settings if present - if $settings { - create_resources('apt::setting', $settings) - } - - # manage pins if present - if $pins { - create_resources('apt::pin', $pins) - } -} diff --git a/vagrant/puppet/modules/apt/manifests/key.pp b/vagrant/puppet/modules/apt/manifests/key.pp deleted file mode 100644 index 914ec88ca..000000000 --- a/vagrant/puppet/modules/apt/manifests/key.pp +++ /dev/null @@ -1,111 +0,0 @@ -# == Define: apt::key -define apt::key ( - $id = $title, - $ensure = present, - $content = undef, - $source = undef, - $server = $::apt::keyserver, - $options = undef, - $key = undef, - $key_content = undef, - $key_source = undef, - $key_server = undef, - $key_options = undef, -) { - - if $key != undef { - warning('$key is deprecated and will be removed in the next major release. Please use $id instead.') - $_id = $key - } else { - $_id = $id - } - - if $key_content != undef { - warning('$key_content is deprecated and will be removed in the next major release. Please use $content instead.') - $_content = $key_content - } else { - $_content = $content - } - - if $key_source != undef { - warning('$key_source is deprecated and will be removed in the next major release. Please use $source instead.') - $_source = $key_source - } else { - $_source = $source - } - - if $key_server != undef { - warning('$key_server is deprecated and will be removed in the next major release. Please use $server instead.') - $_server = $key_server - } else { - $_server = $server - } - - if $key_options != undef { - warning('$key_options is deprecated and will be removed in the next major release. Please use $options instead.') - $_options = $key_options - } else { - $_options = $options - } - - validate_re($_id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) - validate_re($ensure, ['\A(absent|present)\Z',]) - - if $_content { - validate_string($_content) - } - - if $_source { - validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) - } - - if $_server { - validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) - } - - if $_options { - validate_string($_options) - } - - case $ensure { - present: { - if defined(Anchor["apt_key ${_id} absent"]){ - fail("key with id ${_id} already ensured as absent") - } - - if !defined(Anchor["apt_key ${_id} present"]) { - apt_key { $title: - ensure => $ensure, - id => $_id, - source => $_source, - content => $_content, - server => $_server, - options => $_options, - } -> - anchor { "apt_key ${_id} present": } - } - } - - absent: { - if defined(Anchor["apt_key ${_id} present"]){ - fail("key with id ${_id} already ensured as present") - } - - if !defined(Anchor["apt_key ${_id} absent"]){ - apt_key { $title: - ensure => $ensure, - id => $_id, - source => $_source, - content => $_content, - server => $_server, - options => $_options, - } -> - anchor { "apt_key ${_id} absent": } - } - } - - default: { - fail "Invalid 'ensure' value '${ensure}' for apt::key" - } - } -} diff --git a/vagrant/puppet/modules/apt/manifests/params.pp b/vagrant/puppet/modules/apt/manifests/params.pp deleted file mode 100644 index ea1087e7a..000000000 --- a/vagrant/puppet/modules/apt/manifests/params.pp +++ /dev/null @@ -1,142 +0,0 @@ -class apt::params { - - if $::osfamily != 'Debian' { - fail('This module only works on Debian or derivatives like Ubuntu') - } - - # prior to puppet 3.5.0, defined() couldn't test if a variable was defined. - # strict_variables wasn't added until 3.5.0, so this should be fine. - if $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 { - $xfacts = { - 'lsbdistcodename' => $::lsbdistcodename, - 'lsbdistrelease' => $::lsbdistrelease, - 'lsbdistid' => $::lsbdistid, - } - } else { - # Strict variables facts lookup compatibility - $xfacts = { - 'lsbdistcodename' => defined('$lsbdistcodename') ? { - true => $::lsbdistcodename, - default => undef, - }, - 'lsbdistrelease' => defined('$lsbdistrelease') ? { - true => $::lsbdistrelease, - default => undef, - }, - 'lsbdistid' => defined('$lsbdistid') ? { - true => $::lsbdistid, - default => undef, - }, - } - } - - $root = '/etc/apt' - $provider = '/usr/bin/apt-get' - $sources_list = "${root}/sources.list" - $sources_list_d = "${root}/sources.list.d" - $conf_d = "${root}/apt.conf.d" - $preferences = "${root}/preferences" - $preferences_d = "${root}/preferences.d" - $keyserver = 'keyserver.ubuntu.com' - - $config_files = { - 'conf' => { - 'path' => $conf_d, - 'ext' => '', - }, - 'pref' => { - 'path' => $preferences_d, - 'ext' => '.pref', - }, - 'list' => { - 'path' => $sources_list_d, - 'ext' => '.list', - } - } - - $update_defaults = { - 'frequency' => 'reluctantly', - 'timeout' => undef, - 'tries' => undef, - } - - $proxy_defaults = { - 'ensure' => undef, - 'host' => undef, - 'port' => 8080, - 'https' => false, - } - - $purge_defaults = { - 'sources.list' => false, - 'sources.list.d' => false, - 'preferences' => false, - 'preferences.d' => false, - } - - $source_key_defaults = { - 'server' => $keyserver, - 'options' => undef, - 'content' => undef, - 'source' => undef, - } - - $include_defaults = { - 'deb' => true, - 'src' => false, - } - - case $xfacts['lsbdistid'] { - 'debian': { - case $xfacts['lsbdistcodename'] { - 'squeeze': { - $backports = { - 'location' => 'http://httpredir.debian.org/debian-backports', - 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - 'repos' => 'main contrib non-free', - } - } - default: { - $backports = { - 'location' => 'http://httpredir.debian.org/debian', - 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - 'repos' => 'main contrib non-free', - } - } - } - - $ppa_options = undef - $ppa_package = undef - - } - 'ubuntu': { - $backports = { - 'location' => 'http://archive.ubuntu.com/ubuntu', - 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', - 'repos' => 'main universe multiverse restricted', - } - - if $xfacts['lsbdistcodename'] == 'lucid' { - $ppa_options = undef - $ppa_package = 'python-software-properties' - } elsif $xfacts['lsbdistcodename'] == 'precise' { - $ppa_options = '-y' - $ppa_package = 'python-software-properties' - } elsif versioncmp($xfacts['lsbdistrelease'], '14.04') >= 0 { - $ppa_options = '-y' - $ppa_package = 'software-properties-common' - } else { - $ppa_options = '-y' - $ppa_package = 'python-software-properties' - } - } - undef: { - fail('Unable to determine lsbdistid, please install lsb-release first') - } - default: { - $ppa_options = undef - $ppa_package = undef - $backports = undef - } - } -} diff --git a/vagrant/puppet/modules/apt/manifests/pin.pp b/vagrant/puppet/modules/apt/manifests/pin.pp deleted file mode 100644 index dff2c297c..000000000 --- a/vagrant/puppet/modules/apt/manifests/pin.pp +++ /dev/null @@ -1,80 +0,0 @@ -# pin.pp -# pin a release in apt, useful for unstable repositories - -define apt::pin( - $ensure = present, - $explanation = undef, - $order = 50, - $packages = '*', - $priority = 0, - $release = '', # a= - $origin = '', - $version = '', - $codename = '', # n= - $release_version = '', # v= - $component = '', # c= - $originator = '', # o= - $label = '' # l= -) { - if $order and !is_integer($order) { - fail('Only integers are allowed in the apt::pin order param') - } - - if $explanation { - $_explanation = $explanation - } else { - if defined('$caller_module_name') { # strict vars check - $_explanation = "${caller_module_name}: ${name}" - } else { - $_explanation = ": ${name}" - } - } - - $pin_release_array = [ - $release, - $codename, - $release_version, - $component, - $originator, - $label] - $pin_release = join($pin_release_array, '') - - # Read the manpage 'apt_preferences(5)', especially the chapter - # 'The Effect of APT Preferences' to understand the following logic - # and the difference between specific and general form - if is_array($packages) { - $packages_string = join($packages, ' ') - } else { - $packages_string = $packages - } - - if $packages_string != '*' { # specific form - if ( $pin_release != '' and ( $origin != '' or $version != '' )) or - ( $version != '' and ( $pin_release != '' or $origin != '' )) { - fail('parameters release, origin, and version are mutually exclusive') - } - } else { # general form - if $version != '' { - fail('parameter version cannot be used in general form') - } - if ( $pin_release != '' and $origin != '' ) { - fail('parameters release and origin are mutually exclusive') - } - } - - # According to man 5 apt_preferences: - # The files have either no or "pref" as filename extension - # and only contain alphanumeric, hyphen (-), underscore (_) and period - # (.) characters. Otherwise APT will print a notice that it has ignored a - # file, unless that file matches a pattern in the - # Dir::Ignore-Files-Silently configuration list - in which case it will - # be silently ignored. - $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') - - apt::setting { "pref-${file_name}": - ensure => $ensure, - priority => $order, - content => template('apt/_header.erb', 'apt/pin.pref.erb'), - notify_update => false, - } -} diff --git a/vagrant/puppet/modules/apt/manifests/ppa.pp b/vagrant/puppet/modules/apt/manifests/ppa.pp deleted file mode 100644 index 6b025d7a7..000000000 --- a/vagrant/puppet/modules/apt/manifests/ppa.pp +++ /dev/null @@ -1,69 +0,0 @@ -# ppa.pp -define apt::ppa( - $ensure = 'present', - $options = $::apt::ppa_options, - $release = $::apt::xfacts['lsbdistcodename'], - $package_name = $::apt::ppa_package, - $package_manage = false, -) { - unless $release { - fail('lsbdistcodename fact not available: release parameter required') - } - - if $::apt::xfacts['lsbdistid'] == 'Debian' { - fail('apt::ppa is not currently supported on Debian.') - } - - if versioncmp($::apt::xfacts['lsbdistrelease'], '15.10') >= 0 { - $distid = downcase($::apt::xfacts['lsbdistid']) - $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2-${release}") - } else { - $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2-${release}") - } - - $filename_no_slashes = regsubst($filename, '/', '-', 'G') - $filename_no_specialchars = regsubst($filename_no_slashes, '[\.\+]', '_', 'G') - $sources_list_d_filename = "${filename_no_specialchars}.list" - - if $ensure == 'present' { - if $package_manage { - ensure_packages($package_name) - - $_require = [File['sources.list.d'], Package[$package_name]] - } else { - $_require = File['sources.list.d'] - } - - $_proxy = $::apt::_proxy - if $_proxy['host'] { - if $_proxy['https'] { - $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"] - } else { - $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"] - } - } else { - $_proxy_env = [] - } - - exec { "add-apt-repository-${name}": - environment => $_proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename}", - user => 'root', - logoutput => 'on_failure', - notify => Class['apt::update'], - require => $_require, - } - - file { "${::apt::sources_list_d}/${sources_list_d_filename}": - ensure => file, - require => Exec["add-apt-repository-${name}"], - } - } - else { - file { "${::apt::sources_list_d}/${sources_list_d_filename}": - ensure => 'absent', - notify => Class['apt::update'], - } - } -} diff --git a/vagrant/puppet/modules/apt/manifests/setting.pp b/vagrant/puppet/modules/apt/manifests/setting.pp deleted file mode 100644 index b0fb62b1d..000000000 --- a/vagrant/puppet/modules/apt/manifests/setting.pp +++ /dev/null @@ -1,64 +0,0 @@ -define apt::setting ( - $priority = 50, - $ensure = file, - $source = undef, - $content = undef, - $notify_update = true, -) { - - include 'apt::params' - if $content and $source { - fail('apt::setting cannot have both content and source') - } - - if !$content and !$source { - fail('apt::setting needs either of content or source') - } - - validate_re($ensure, ['file', 'present', 'absent']) - validate_bool($notify_update) - - $title_array = split($title, '-') - $setting_type = $title_array[0] - $base_name = join(delete_at($title_array, 0), '-') - - validate_re($setting_type, ['\Aconf\z', '\Apref\z', '\Alist\z'], "apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'") - - unless is_integer($priority) { - # need this to allow zero-padded priority. - validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer') - } - - if $source { - validate_string($source) - } - - if $content { - validate_string($content) - } - - if ($setting_type == 'list') or ($setting_type == 'pref') { - $_priority = '' - } else { - $_priority = $priority - } - - $_path = $::apt::params::config_files[$setting_type]['path'] - $_ext = $::apt::params::config_files[$setting_type]['ext'] - - if $notify_update { - $_notify = Class['apt::update'] - } else { - $_notify = undef - } - - file { "${_path}/${_priority}${base_name}${_ext}": - ensure => $ensure, - owner => 'root', - group => 'root', - mode => '0644', - content => $content, - source => $source, - notify => $_notify, - } -} diff --git a/vagrant/puppet/modules/apt/manifests/source.pp b/vagrant/puppet/modules/apt/manifests/source.pp deleted file mode 100644 index 0bb9b3be7..000000000 --- a/vagrant/puppet/modules/apt/manifests/source.pp +++ /dev/null @@ -1,158 +0,0 @@ -# source.pp -# add an apt source -define apt::source( - $location = undef, - $comment = $name, - $ensure = present, - $release = undef, - $repos = 'main', - $include = {}, - $key = undef, - $pin = undef, - $architecture = undef, - $allow_unsigned = false, - $include_src = undef, - $include_deb = undef, - $required_packages = undef, - $key_server = undef, - $key_content = undef, - $key_source = undef, - $trusted_source = undef, - $notify_update = undef, -) { - validate_string($architecture, $comment, $location, $repos) - validate_bool($allow_unsigned) - validate_hash($include) - - # This is needed for compat with 1.8.x - include ::apt - - $_before = Apt::Setting["list-${title}"] - - if $include_src != undef { - warning("\$include_src is deprecated and will be removed in the next major release, please use \$include => { 'src' => ${include_src} } instead") - } - - if $include_deb != undef { - warning("\$include_deb is deprecated and will be removed in the next major release, please use \$include => { 'deb' => ${include_deb} } instead") - } - - if $required_packages != undef { - warning('$required_packages is deprecated and will be removed in the next major release, please use package resources instead.') - exec { "Required packages: '${required_packages}' for ${name}": - command => "${::apt::params::provider} -y install ${required_packages}", - logoutput => 'on_failure', - refreshonly => true, - tries => 3, - try_sleep => 1, - before => $_before, - } - } - - if $key_server != undef { - warning("\$key_server is deprecated and will be removed in the next major release, please use \$key => { 'server' => ${key_server} } instead.") - } - - if $key_content != undef { - warning("\$key_content is deprecated and will be removed in the next major release, please use \$key => { 'content' => ${key_content} } instead.") - } - - if $key_source != undef { - warning("\$key_source is deprecated and will be removed in the next major release, please use \$key => { 'source' => ${key_source} } instead.") - } - - if $trusted_source != undef { - warning('$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.') - $_allow_unsigned = $trusted_source - } else { - $_allow_unsigned = $allow_unsigned - } - - if ! $release { - $_release = $::apt::params::xfacts['lsbdistcodename'] - unless $_release { - fail('lsbdistcodename fact not available: release parameter required') - } - } else { - $_release = $release - } - - if $ensure == 'present' and ! $location { - fail('cannot create a source entry without specifying a location') - } - - if $include_src != undef and $include_deb != undef { - $_deprecated_include = { - 'src' => $include_src, - 'deb' => $include_deb, - } - } elsif $include_src != undef { - $_deprecated_include = { 'src' => $include_src } - } elsif $include_deb != undef { - $_deprecated_include = { 'deb' => $include_deb } - } else { - $_deprecated_include = {} - } - - $_include = merge($::apt::params::include_defaults, $_deprecated_include, $include) - - $_deprecated_key = { - 'key_server' => $key_server, - 'key_content' => $key_content, - 'key_source' => $key_source, - } - - if $key { - if is_hash($key) { - unless $key['id'] { - fail('key hash must contain at least an id entry') - } - $_key = merge($::apt::params::source_key_defaults, $_deprecated_key, $key) - } else { - validate_string($key) - $_key = merge( { 'id' => $key }, $_deprecated_key) - } - } - - apt::setting { "list-${name}": - ensure => $ensure, - content => template('apt/_header.erb', 'apt/source.list.erb'), - notify_update => $notify_update, - } - - if $pin { - if is_hash($pin) { - $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before }) - } elsif (is_numeric($pin) or is_string($pin)) { - $url_split = split($location, '/') - $host = $url_split[2] - $_pin = { - 'ensure' => $ensure, - 'priority' => $pin, - 'before' => $_before, - 'origin' => $host, - } - } else { - fail('Received invalid value for pin parameter') - } - create_resources('apt::pin', { "${name}" => $_pin }) - } - - # We do not want to remove keys when the source is absent. - if $key and ($ensure == 'present') { - if is_hash($_key) { - apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": - ensure => present, - id => $_key['id'], - server => $_key['server'], - content => $_key['content'], - source => $_key['source'], - options => $_key['options'], - key_server => $_key['key_server'], - key_content => $_key['key_content'], - key_source => $_key['key_source'], - before => $_before, - } - } - } -} diff --git a/vagrant/puppet/modules/apt/manifests/update.pp b/vagrant/puppet/modules/apt/manifests/update.pp deleted file mode 100644 index 9b1f68670..000000000 --- a/vagrant/puppet/modules/apt/manifests/update.pp +++ /dev/null @@ -1,61 +0,0 @@ -class apt::update { - #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we - #opt to do this, a info/warn would likely be all you'd need likely to happen - #on the first run, but if it's not run in awhile something is likely borked - #with apt and we'd want to know about it. - - case $::apt::_update['frequency'] { - 'always': { - $_kick_apt = true - } - 'daily': { - #compare current date with the apt_update_last_success fact to determine - #if we should kick apt_update. - $daily_threshold = (strftime('%s') - 86400) - if $::apt_update_last_success { - if $::apt_update_last_success < $daily_threshold { - $_kick_apt = true - } else { - $_kick_apt = false - } - } else { - #if apt-get update has not successfully run, we should kick apt_update - $_kick_apt = true - } - } - 'weekly':{ - #compare current date with the apt_update_last_success fact to determine - #if we should kick apt_update. - $weekly_threshold = (strftime('%s') - 604800) - if $::apt_update_last_success { - if ( $::apt_update_last_success < $weekly_threshold ) { - $_kick_apt = true - } else { - $_kick_apt = false - } - } else { - #if apt-get update has not successfully run, we should kick apt_update - $_kick_apt = true - } - } - default: { - #catches 'reluctantly', and any other value (which should not occur). - #do nothing. - $_kick_apt = false - } - } - - if $_kick_apt { - $_refresh = false - } else { - $_refresh = true - } - exec { 'apt_update': - command => "${::apt::provider} update", - logoutput => 'on_failure', - refreshonly => $_refresh, - timeout => $::apt::_update['timeout'], - tries => $::apt::_update['tries'], - try_sleep => 1 - } -} diff --git a/vagrant/puppet/modules/apt/metadata.json b/vagrant/puppet/modules/apt/metadata.json deleted file mode 100644 index a7bc3b233..000000000 --- a/vagrant/puppet/modules/apt/metadata.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "puppetlabs-apt", - "version": "2.3.0", - "author": "Puppet Labs", - "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", - "license": "Apache-2.0", - "source": "https://github.com/puppetlabs/puppetlabs-apt", - "project_page": "https://github.com/puppetlabs/puppetlabs-apt", - "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0 < 5.0.0"} - ], - "data_provider": null, - "operatingsystem_support": [ - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04", - "16.04" - ] - } - ], - "requirements": [ - { - "name": "puppet", - "version_requirement": ">= 3.0.0 < 5.0.0" - } - ] -} diff --git a/vagrant/puppet/modules/apt/spec/acceptance/apt_key_provider_spec.rb b/vagrant/puppet/modules/apt/spec/acceptance/apt_key_provider_spec.rb deleted file mode 100644 index 1661a2bfa..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/apt_key_provider_spec.rb +++ /dev/null @@ -1,723 +0,0 @@ -require 'spec_helper_acceptance' - -PUPPETLABS_GPG_KEY_SHORT_ID = '4BD6EC30' -PUPPETLABS_GPG_KEY_LONG_ID = '1054B7A24BD6EC30' -PUPPETLABS_GPG_KEY_FINGERPRINT = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' -PUPPETLABS_APT_URL = 'apt.puppetlabs.com' -PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' -CENTOS_GPG_KEY_SHORT_ID = 'C105B9DE' -CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE' -CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE' -CENTOS_REPO_URL = 'ftp.cvut.cz/centos' -CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' - -SHOULD_NEVER_EXIST_ID = '4BD6EC30' - -KEY_CHECK_COMMAND = "apt-key adv --list-keys --with-colons --fingerprint | grep " -PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}" -CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}" - -describe 'apt_key' do - before(:each) do - # Delete twice to make sure everything is cleaned - # up after the short key collision - shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", - :acceptable_exit_codes => [0,1,2]) - shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", - :acceptable_exit_codes => [0,1,2]) - end - - describe 'default options' do - key_versions = { - '32bit key id' => '4BD6EC30', - '64bit key id' => '1054B7A24BD6EC30', - '160bit key fingerprint' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - '32bit lowercase key id' => '4bd6ec30', - '64bit lowercase key id' => '1054b7a24bd6ec30', - '160bit lowercase key fingerprint' => '47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', - '0x formatted 32bit key id' => '0x4BD6EC30', - '0x formatted 64bit key id' => '0x1054B7A24BD6EC30', - '0x formatted 160bit key fingerprint' => '0x47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - '0x formatted 32bit lowercase key id' => '0x4bd6ec30', - '0x formatted 64bit lowercase key id' => '0x1054b7a24bd6ec30', - '0x formatted 160bit lowercase key fingerprint' => '0x47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', - } - - key_versions.each do |key, value| - context "#{key}" do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{value}', - ensure => 'present', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - end - - context 'invalid length key id' do - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '4B7A24BD6EC30', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/Valid values match/) - end - end - end - end - - describe 'ensure =>' do - context 'absent' do - it 'is removed' do - pp = <<-EOS - apt_key { 'centos': - id => '#{CENTOS_GPG_KEY_LONG_ID}', - ensure => 'absent', - } - EOS - - # Install the key first - shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net \ - --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") - shell(CENTOS_KEY_CHECK_COMMAND) - - # Time to remove it using Puppet - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - - shell(CENTOS_KEY_CHECK_COMMAND, - :acceptable_exit_codes => [1]) - - shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net \ - --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") - end - end - - context 'absent, added with long key', :unless => (fact('operatingsystem') == 'Debian' and fact('operatingsystemmajrelease') == '6') do - it 'is removed' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'absent', - } - EOS - - # Install the key first - shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net \ - --recv-keys #{PUPPETLABS_GPG_KEY_LONG_ID}") - shell(PUPPETLABS_KEY_CHECK_COMMAND) - - # Time to remove it using Puppet - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - - shell(PUPPETLABS_KEY_CHECK_COMMAND, - :acceptable_exit_codes => [1]) - end - end - end - - describe 'content =>' do - context 'puppetlabs gpg key' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', - ensure => 'present', - content => "-----BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.12 (GNU/Linux) -Comment: GPGTools - http://gpgtools.org - -mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b -fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg -5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ -S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY -GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH -Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v -VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 -Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI -wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN -NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl -f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB -tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL -ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn -AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob -pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF -eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ -aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M -2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ -VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU -3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh -qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 -IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 -1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp -HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN -MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ -UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh -R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ -N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc -kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e -lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT -DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb -kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf -DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei -BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z -XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 -+zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU -fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH -dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 -qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 -7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq -UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x -Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA -KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 -okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 -bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 -4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX -vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 -jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y -ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD -7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR -M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf -REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y -DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk -ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= -=a34C ------END PGP PUBLIC KEY BLOCK-----", - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - - context 'multiple keys' do - it 'runs without errors' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', - ensure => 'present', - content => "-----BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.12 (GNU/Linux) -Comment: GPGTools - http://gpgtools.org - -mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b -fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg -5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ -S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY -GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH -Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v -VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 -Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI -wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN -NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl -f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB -tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL -ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn -AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob -pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF -eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ -aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M -2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ -VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU -3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh -qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 -IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 -1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp -HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN -MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ -UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh -R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ -N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc -kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e -lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT -DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb -kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf -DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei -BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z -XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 -+zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU -fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH -dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 -qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 -7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq -UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x -Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA -KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 -okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 -bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 -4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX -vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 -jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y -ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD -7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR -M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf -REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y -DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk -ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYWJAhwEEAEC -AAYFAlHk3M4ACgkQSjMLmtZI+uP5hA//UTZfD340ukip6jPlMzxwSD/QapwtO7D4 -gsGTsXezDkO97D21d1pNaNT0RrXAMagwk1ElDxmn/YHUDfMovZa2bKagjWmV38xk -Ws+Prh1P44vUDG30CAU6KZ+mTGLUbolfOvDffCTm9Mn1i2kxFaJxbVhWR6zR28KZ -R28s1IBsrqeTCksYfdKdkuw1/j850hW8MM3hPBJ/48VLx5QEFfnlXwt1fp+LygAv -rIyJw7vJtsa9QjCIkQk2tcv77rhkiZ6ADthgVIx5j3yDWSm4nLqFpwbQTKrNRrCb -5XbL/oIMeHJuFICb2HckDS1KuKXHmqvDuLoRr0/wFEZMps5XQevomUa7JkMeS5j9 -AubCG4g1zKEtPPaGDsfDKBljCHBKwUysQj5oGU5w8VvlOPnS62DBfsgU2y5ipmmI -TYkjSOL6LXwO6xG5/sxA8cyoJSmbN286imcY6AHloTiiu6/N7Us+CNrhw/V7HAun -56etWBn3bZWCRGGAPF3qJr4y2sUMY0E3Ha7OPEHIKfBb4MiJnpXntWT28nQfF3dl -TFTthAzwcnZchx2es4yrfDXn33Y4eisqxWCbTluErXUogUEKH1KohSatYMtxencv -7bUlzIr22zSUCYyVf9cyg50kBy+0J7seEpqG5K5R8z9s/63BT5Oghmi6bB2s5iK5 -fBt3Tu1IYpyZAg0EURGeeQEQALoU2rlo+usvGKqmBKaEl8Cbx0UZY4tQa1OQSDCj -6QeCBc36rq2NCAFpjYg0nrxMN86e0aHYVVetT75rSX701jRJD/TRCPzr03QVwEtk -GpGIpBXtdx0962I0We5rSZL2TWKuPtGRKrbs6CSVlNynLprIEnN+2sJYd/1yEsrR -9wBtUfVOkq6o4hBWOj4oEqhqQv1MPv1RPqGEgJl19s4LS9277cMIwrj553nGzsy1 -XwO6BQIP8IhJQZ+8Okw3UaJjLHkJExgo3UHMFdZhAOOYbrlxwq3lENmkdgjxCUBZ -iVNiEX9NLm8x1HWaW/nnBIHu6g7r+1Ff5qMSI2hBVan6om4gKHdI9wThG89V16Nq -3YztuK5L6Nh9a7BVQJos0r419NHGXPqXqN99jWRL+jAqwKozviUYijDx8k4xLnpQ -1dIbHfwE0MPuIkgHeQIoBMkxD1tiQC7ouqVRqU1gg9VKhOZf0opDnvqQ+cDMyfUC -hgrjjikSoCBIVCDvr1r7T/gUMDEXfnaMfAdEy1z9qnUzTRRzMbl4BN3Zn+4Htf+B -zpAln6H8h7sBb6CO1TX2Qh3JPTrV9zSSbbOW/kuySU+rkHBQPza5l+pnWD7eXaVj -7+WEx+TsYIP9Gpe/FOVp2ht93NgjNFAodPW+i5jm7MRk+vlzjidHJ69pEUoQQtuk -Td8LABEBAAG0V1B1cHBldCBMYWJzIE5pZ2h0bHkgQnVpbGQgS2V5IChQdXBwZXQg -TGFicyBOaWdodGx5IEJ1aWxkIEtleSkgPGRlbGl2ZXJ5QHB1cHBldGxhYnMuY29t -PokCPwQTAQIAKQUCURGzrQIbAwUJBaOagAcLCQgHAwIBBhUIAgkKCwQWAgMBAh4B -AheAAAoJELj5mcAHu2xX7UUQAKGDOQS20BRNEa3top+dQONWmC/j1ABDVTOkF7Zc -9JT5oEESzVof/yIWKAfCbYyH5l3yySZI3NOQt7CswIWDYe0JR/uBhyGoHkA1t52L -zP45UxI29K5XaeBm3qoQbV3W6GWScGkijfaJ2yz/dIHh0m3SkC8mUGBrIqqVwV38 -JcsW1/CzTetZiWGlk8/nPeUg+snGwd22zUlZkTaVh3FbHrqh2xsMFdrphDOtSU5s -Jzebu5h6mp7cMZELaRNNmg3O7VeQMA1hwaq05jQuPisS/ktOqSgJXh8pOaUpDoV0 -ta4JSwaqEkWsZHv3tmaXGy0Qzs9X9bOjRbIKgN2w9JY+z2OKJ5L4Yg5VMJPYMdKp -wGSQf70YaaT0d1N/84P8j7CRsDBnVME/TDuE2u1XM/9B7xmdcI28FxZrqQc06OGS -UvK9vSgTkTxXSsjobah8ssi4C4/zRgTZu94KOhSlH4YGrzLX7g25M708NxgXJiPZ -7K8Ceea28mHYf3f+JobEbpzPeewURAFCXHCm4cFU31FsiXQrNhGmUpRKVayiMMzN -JF8yjuHpwB2DjGdV3QR5C8Ms+RO86JnD/Yq9zeoF7T7jCAkQKuh76cQe60XllKhV -Dlh2rpKXAtLAbea9hcSraZkm3Lj+oKzXUSf3Ml9xp65yjUjm9O+a4AMQ1wFroGEP -QUEEiQEcBBABCgAGBQJT0XkMAAoJELrV8KOS6YVy7O8IAKJYT0Afd6Ufkx4cR0rj -soCoPpDDiyITmSdeLSzvl9rr1X39+PqR0dcncEhO1heCZo8sm/iMNsiV4UORv2Wh -lCriE2fDpu9ByX1rwuKl9nEu9xx2WTRWtdx4M4fB+ZXYiJbgb1vuM46mGp51NYRK -ByPIm1EAjOhsfXm14BZICOQO5WLy5Sv/oRVSEBiGXNXf1kweXSzrhRCNEWYfPhQJ -4pCsvNeiQuhqQIB+J9FbA48x47JikMM92w0aEa4aVVokNF2PBCp9/SdRAzlY7Ikx -aAdIzuyc0ANIZBPgYxIgdH/Fltwz6VW6iFNk3gS7jR6TFBjRQba73I53IBbiVIRq -dnWJAhwEEAECAAYFAlPRd2QACgkQRp6bNpsPDx1HiQ//TEOYPkp+iHT/wNcTUO4A -r00La6xl9bw3v5XlnW83YjrB0ieChbXcHpChNRk08vdRSgxyWCtbIwmMeOO8mDiv -aJbYrgngJY+FSMsAzhSyPauze0l4PV3dnLRMZmK5Nro4GNI4oiOGp0qXPcBjstlc -BnEa6XuLHDnRYFhkcVboZDu2o/tdz+OJD+CZjyeiIAtChMJ+ghlpfO3cOuK0wmTh -Jtn/eDAfjB34CZdkt1paKZap5bLZCF0QwP+DbJd189HZy/ot6w2jpNXFt1JFnoyn -7Nluo6MPNTZSG3pzh7fvzb924M1sm+CyLFzEV1rYi6ujyHOsW+KYc6fOUB5jk/BZ -QPaU6vG1JRDLHWPjbPf9Ax8uGQSrVXC3txiu2OLZcn4Ti54PoHed5m7Fxk9fnaiT -gNGL0ox/wmIPbIsdGrXuTHcdmPyuRM5btXFWCMbknTIbefEEOQdbPl+e5QgWR5cf -EVOvo6qTBstH7aHqiWMQpuvnU7l9xpfcJ40SawHxiY/UCKXhpf7SJXAvE8zkMIvi -PJaHKDy2FyCwtCHwG1wiQSqjnCJt5gmTGCXzO/yAGhcgUWbTpykIMij9IPboL7VL -er+I/3CikWeszcjBp5lJhg4k2OCBi5LOiI+8EUTlFcAqxbTFEyM+IQDOwnW8Gznf -nMb070gS9iBk0GTVC9iXHla0U1B1cHBldCBMYWJzIE5pZ2h0bHkgQnVpbGQgS2V5 -IChQdXBwZXQgTGFicyBOaWdodGx5IEJ1aWxkIEtleSkgPGluZm9AcHVwcGV0bGFi -cy5jb20+iQI+BBMBAgAoBQJREZ55AhsDBQkFo5qABgsJCAcDAgYVCAIJCgsEFgID -AQIeAQIXgAAKCRC4+ZnAB7tsVyjmEACSw9ZLq1ehcq8/QemiB+i8W/yVYZAxphmq -w547JXOxk19V5joR5Wp0fwqIEvE1Thw0mAiMUDAgM4TpdZc8zOaILj2OH1gWsuyi -fbFTHExTZAuZ1Lx1Nc1AlUv5Q+bmrzjAhx13Nk3LE7yfe4DLZnSyF3cZxAcSXYSq -wSo1sBrWxf2bOYnuyJwLlz94eeEkNdSi0mfANqt+ihiiAeTe9OXf65iPFn8SYRqV -W0hUayVlOedoCl0kviVXHvIgHxgkfazeIPqncFgPiRyYGNCVhKjaFjpUm+RzBFOk -HQzzcyNovlnjHmhxKkN+L2f1JqmHmUQguTTpJfpRdwmnEkA1BYY6m0WQ5Owga1eE -WEeHh9AjtVrukJOOibvpoS/M5FdAgaUgGXPIOziURDKBjQ0zuYMtlXgEDzKt0ugp -7YO74EAv1JiyeZ0Mu+m6WnxRX0Sb/op0ef74xZYD4eKYixOxahQ7kxtO9qTy+pOs -c3/KSNGv+oQh/CgChBbN3oq1UBfL6gVioRIp2GmP6Jmfipfod+VGIVI8xyfD3h/Z -nKF7dEHHMsyB03Ap2ypCcy8OEVwCeAZ4eY+lKXNyBSnddXcMGuFTqgJ1IMvTm0T8 -BfYn74A4fDqwNKKQGYjb67MZ+3N7YaWwCgWUvFpfd557fTQmZfV1arok2urvWIGa -x82lgKTA64kBHAQQAQoABgUCU9F5DwAKCRC61fCjkumFchUwB/wLfX/PA0LUbSen -es6ilcbHOZVZKyppMA5bIU6fG6SIS9FVauL0lgkEnJAhr5w3rXGd14LM33QkkPbs -/uNe2YQHzzrsffLhFyJkKJXH5rc6sSM7RYbAxtMNXKpkdMhPGmHgIgMzJo3ZuD8+ -ixsyR/8tGAMXbHwX5aAJDKYfg8X4kkPBxzysWJzN5/wFbYEK8FHiULkHNfJv480H -UBLNwczVeg9Etaje0tCQuGkD/CJHR50Kxuc/BiGYdYVjAnQVILXa2NcBizXtUU3f -N+6L+K2m9Fm3Dvhw0ZVEq7TxTMmHA23HGt8fMJ7zNCRO3krK7vtjUQxSXKOM7HF+ -D60QA/oGiQIcBBABAgAGBQJT0XdkAAoJEEaemzabDw8dtt0QAITarh4rsJWupVXD -BFHbxsUyT7AXspJ7kW3vxG3Y/gHSjleDX0VdblzUUBmD5y5JvR/DHrAgDd8XQN4E -4+hTOpZhzILZcoSWhiAW+VuL5b+R5NxSzIiHEt/qKgslvcx/sbQz8+Ro/zWHxhn9 -1uFf5JOFw+5W2wBmC4OdQby7B8AiV58OBAGcVUs0+57oJRYIU0zTRAJKRstMlD7s -F3R1d6EyNUbGjnJhPcltk6RRsYuJJx8vJzyY4pEy5eZPNSPEpFBjWlWyRnKDbQ6/ -TbtSB7bojbtjQFhh905kvdKxzcBkFgYTyzqJffUwHqJti8QQMraGAtC79/D/0vmf -lIJtzTB+gA/NOhyriaSXoGzi0oA/ZKReU3uJd5Yl202s/hvG+xpBkh7ouaVa5zFX -cqfi6gmmpQzVo6snI7d+Wonyvg1lhqZ7TXvtUIilsmbc5zEedidaCei77buX/ZuV -8jo+32HtsSKTYYHVsJzY6YzEy1SVfrUY+EdXXWG7Y97JaXKJc8oCNT1YA8BG4c+M -1cMXO1LTiP56gyYnrH6/oTIFrBXMl3dO/gKpcwUmf8lScFXIfVn5Wm3D0n6cUBKT -aRmmpfu7UhzBMEA7ZrIGxNBuD8WwfVi8ZSwBbV92fHkukkfixkhmeUmCB9vyq31+ -UfTwFXkHDTMZ4jfctKuBU+3p5sEwuQINBFERnnkBEAC0XpaBe0L9yvF1oc7rDLEt -XMrjDWHL6qPEW8ei94D619n1eo1QbZA4zZSZFjmN1SWtxg+2VRJazIlaFNMTpp+q -7lpmHPwzGdFdZZPVvjwd7cIe5KrGjEiTD1zf7i5Ws5Xh9jTh6VzY8nseakhIGTOC -lWzxl/+X2cJlMAR4/nLJjiTi3VwI2JBT8w2H8j8EgfRpjf6P1FyLv0WWMODc/hgc -/o5koLb4WRsK2w5usP/a3RNeh6L6iqHiiAL1Y9+0GZXOrjtNpkzPRarIL3MiX29o -VKSFcjUREpsEZHBHLwuA3WIR6WBX49LhrA6uLgofYhALeky6/H3ZFEH9ZS3plmnX -/vow8YWmz0Lyzzf848qsg5E5cHg36m2CXSEUeZfH748H78R62uIf/shusffl9Op2 -aZnQoPyeYIkA6N8m29CqIa/pzd68rLEQ+MNHHkp0KjQ0oKyrz9/YCXeQg3lIBXAv -+FIVK/04fMA3rr5tnynkeG9Ow6fGEtqzNjZhMZtx5BnkhdLTt6qu+wyaDw3q9X1/ -/j3lhplXteYzUkNUIinCHODGXaI55R/I4HNsbvtvy904g5sTHZX9QBn0x7QpVZaW -90jCgl6+NPH96g1cuHFuk+HED4H6XYFcdt1VRVb9YA7GgRXkSyfw6KdtGFT15e7o -7PcaD6NpqyBfbYfrNQmiOwARAQABiQIlBBgBAgAPBQJREZ55AhsMBQkFo5qAAAoJ -ELj5mcAHu2xXR8cP/Ai4PqUKBZdN6Jz628VQdiVX2EO7jhQ7KYdt9RWz87kfm0rC -LhdROCyeddgGsYbpdikC3Gzrk0JFIs/qAzpZOMIip0cXTxDEWWObuwShIac8hmZz -BE5SM7TcA9+/jmBwLajcreGgKs/MfDkkWkiBT/B+FyHkqS6O/rdBvYqFzLtvUigG -SRf1clP4QEGWcR6LLsJ1uiH+brK3G1GsILVpX5iQ0Y4wNv0xNRGZzAPVZ1/vgHCM -sAG7TZy26oOraigvnZeo1Q9r7pg+i6uSIu4ywfdNTOuoBK+VY+RKyAybBHIqH07w -p9TmYOY1x+wmIe0oSYcR47OcvZU57fdLsEB9djYvkGkkmbz0gwXQL0iEW3kX+05J -zrLzPsx6muR35SPNCvfR2T/0VCDwtNwwxACWuZI/tqsobU/+lA/MqRZ4kOD/Bx07 -CpZfYIAi2STc0MIDvpyDnZLiYVMMkqV4+gn2ANtkF+GKbra3Aeof9b4KEVabSaQ5 -5W70DJF0G5bmHBSdyqdYnKB/yRj1rH+dgRbiRMv7rBAx5Q8rbYiym8im+5XNUDy2 -ZTQcCD53HcBLvKX6RJ4ByYawKaQqMa27WK/YWVmFXqVDVk12iKrQW6zktDdGInnD -+f0rRH7c/7F/QuBR6Y4Zkso0CuVMNsmxv0E+7Zk0z4dWalzQuXpN7OXcZ8Gp -=Gl+v ------END PGP PUBLIC KEY BLOCK-----", - } - EOS - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - - context 'bogus key' do - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - content => 'For posterity: such content, much bogus, wow', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/no valid OpenPGP data found/) - end - end - end - end - - describe 'server =>' do - context 'hkps.pool.sks-keyservers.net' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - server => 'hkps.pool.sks-keyservers.net', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - - context 'hkp://hkps.pool.sks-keyservers.net:80' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', - ensure => 'present', - server => 'hkp://hkps.pool.sks-keyservers.net:80', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - - context 'nonexistant.key.server' do - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - server => 'nonexistant.key.server', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/) - end - end - end - - context 'key server start with dot' do - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - server => '.pgp.key.server', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/Invalid value \".pgp.key.server\"/) - end - end - end - end - - describe 'source =>' do - context 'http://' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - - it 'fails with a 404' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/404 Not Found/) - end - end - - it 'fails with a socket error' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'http://apt.puppetlabss.com/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/could not resolve/) - end - end - end - - context 'ftp://' do - before(:each) do - shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", - :acceptable_exit_codes => [0,1,2]) - end - - it 'works' do - pp = <<-EOS - apt_key { 'CentOS 6': - id => '#{CENTOS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(CENTOS_KEY_CHECK_COMMAND) - end - - it 'fails with a 550' do - pp = <<-EOS - apt_key { 'CentOS 6': - id => '#{SHOULD_NEVER_EXIST_ID}', - ensure => 'present', - source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/550 Failed to open/) - end - end - - it 'fails with a socket error' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'ftp://apt.puppetlabss.com/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/could not resolve/) - end - end - end - - context 'https://' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - - it 'fails with a 404' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{SHOULD_NEVER_EXIST_ID}', - ensure => 'present', - source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/404 Not Found/) - end - end - - it 'fails with a socket error' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{SHOULD_NEVER_EXIST_ID}', - ensure => 'present', - source => 'https://apt.puppetlabss.com/herpderp.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/could not resolve/) - end - end - end - - context '/path/that/exists' do - before(:each) do - shell("curl -o /tmp/puppetlabs-pubkey.gpg \ - http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}") - end - - after(:each) do - shell('rm /tmp/puppetlabs-pubkey.gpg') - end - - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '4BD6EC30', - ensure => 'present', - source => '/tmp/puppetlabs-pubkey.gpg', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - - context '/path/that/does/not/exist' do - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => '/tmp/totally_bogus.file', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/does not exist/) - end - end - end - - context '/path/that/exists/with/bogus/content' do - before(:each) do - shell('echo "here be dragons" > /tmp/fake-key.gpg') - end - - after(:each) do - shell('rm /tmp/fake-key.gpg') - end - it 'fails' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - source => '/tmp/fake-key.gpg', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/no valid OpenPGP data found/) - end - end - end - end - - describe 'options =>' do - context 'debug' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - options => 'debug', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - shell(PUPPETLABS_KEY_CHECK_COMMAND) - end - end - end - - describe 'fingerprint validation against source/content' do - context 'fingerprint in id matches fingerprint from remote key' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', - ensure => 'present', - source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - end - end - - context 'fingerprint in id does NOT match fingerprint from remote key' do - it 'works' do - pp = <<-EOS - apt_key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6E666', - ensure => 'present', - source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', - } - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/do not match/) - end - end - end - end - -end diff --git a/vagrant/puppet/modules/apt/spec/acceptance/apt_spec.rb b/vagrant/puppet/modules/apt/spec/acceptance/apt_spec.rb deleted file mode 100644 index 5c389e3ee..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/apt_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'apt class' do - - context 'reset' do - it 'fixes the sources.list' do - shell('cp /etc/apt/sources.list /tmp') - end - end - - context 'all the things' do - it 'should work with no errors' do - pp = <<-EOS - if $::lsbdistcodename == 'lucid' { - $sources = undef - } else { - $sources = { - 'puppetlabs' => { - 'ensure' => present, - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { - 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - 'server' => 'hkps.pool.sks-keyservers.net', - }, - }, - } - } - class { 'apt': - update => { - 'frequency' => 'always', - 'timeout' => '400', - 'tries' => '3', - }, - purge => { - 'sources.list' => true, - 'sources.list.d' => true, - 'preferences' => true, - 'preferences.d' => true, - }, - sources => $sources, - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - end - it 'should still work' do - shell('apt-get update') - shell('apt-get -y --force-yes upgrade') - end - end - - context 'reset' do - it 'fixes the sources.list' do - shell('cp /tmp/sources.list /etc/apt') - end - end - -end diff --git a/vagrant/puppet/modules/apt/spec/acceptance/class_spec.rb b/vagrant/puppet/modules/apt/spec/acceptance/class_spec.rb deleted file mode 100644 index f228e4c45..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/class_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'apt class' do - - context 'default parameters' do - # Using puppet_apply as a helper - it 'should work with no errors' do - pp = <<-EOS - class { 'apt': } - EOS - - # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/centos-7-x64.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/centos-7-x64.yml deleted file mode 100644 index 5eebdefbf..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/centos-7-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-7-x64: - roles: - - agent - - default - platform: el-7-x86_64 - hypervisor: vagrant - box: puppetlabs/centos-7.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/debian-8-x64.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/debian-8-x64.yml deleted file mode 100644 index fef6e63ca..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/debian-8-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - debian-8-x64: - roles: - - agent - - default - platform: debian-8-amd64 - hypervisor: vagrant - box: puppetlabs/debian-8.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/default.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/default.yml deleted file mode 100644 index dba339c46..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - roles: - - agent - - default - platform: ubuntu-14.04-amd64 - hypervisor: vagrant - box: puppetlabs/ubuntu-14.04-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/centos-7.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/centos-7.yml deleted file mode 100644 index a3333aac5..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/centos-7.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' - # install various tools required to get the image up to usable levels - docker_image_commands: - - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/debian-8.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/debian-8.yml deleted file mode 100644 index df5c31944..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/debian-8.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/ubuntu-14.04.yml deleted file mode 100644 index b1efa5839..000000000 --- a/vagrant/puppet/modules/apt/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - # ensure that upstart is booting correctly in the container - - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/apt/spec/classes/apt_backports_spec.rb b/vagrant/puppet/modules/apt/spec/classes/apt_backports_spec.rb deleted file mode 100644 index 5762025ea..000000000 --- a/vagrant/puppet/modules/apt/spec/classes/apt_backports_spec.rb +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/env rspec -require 'spec_helper' - -describe 'apt::backports', :type => :class do - let (:pre_condition) { "class{ '::apt': }" } - describe 'debian/ubuntu tests' do - context 'defaults on deb' do - let(:facts) do - { - :lsbdistid => 'Debian', - :osfamily => 'Debian', - :lsbdistcodename => 'wheezy', - :puppetversion => Puppet.version, - } - end - it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://httpredir.debian.org/debian', - :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - :repos => 'main contrib non-free', - :release => 'wheezy-backports', - :pin => { 'priority' => 200, 'release' => 'wheezy-backports' }, - }) - } - end - context 'defaults on squeeze' do - let(:facts) do - { - :lsbdistid => 'Debian', - :osfamily => 'Debian', - :lsbdistcodename => 'squeeze', - :puppetversion => Puppet.version, - } - end - it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://httpredir.debian.org/debian-backports', - :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - :repos => 'main contrib non-free', - :release => 'squeeze-backports', - :pin => { 'priority' => 200, 'release' => 'squeeze-backports' }, - }) - } - end - context 'defaults on ubuntu' do - let(:facts) do - { - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistcodename => 'trusty', - :lsbdistrelease => '14.04', - :puppetversion => Puppet.version, - } - end - it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://archive.ubuntu.com/ubuntu', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - :repos => 'main universe multiverse restricted', - :release => 'trusty-backports', - :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, - }) - } - end - context 'set everything' do - let(:facts) do - { - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistcodename => 'trusty', - :lsbdistrelease => '14.04', - :puppetversion => Puppet.version, - } - end - let(:params) do - { - :location => 'http://archive.ubuntu.com/ubuntu-test', - :release => 'vivid', - :repos => 'main', - :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - :pin => '90', - } - end - it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://archive.ubuntu.com/ubuntu-test', - :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - :repos => 'main', - :release => 'vivid', - :pin => { 'priority' => 90, 'release' => 'vivid' }, - }) - } - end - context 'set things with hashes' do - let(:facts) do - { - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistcodename => 'trusty', - :lsbdistrelease => '14.04', - :puppetversion => Puppet.version, - } - end - let(:params) do - { - :key => { - 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - }, - :pin => { - 'priority' => '90', - }, - } - end - it { is_expected.to contain_apt__source('backports').with({ - :key => { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, - :pin => { 'priority' => '90' }, - }) - } - end - end - describe 'mint tests' do - let(:facts) do - { - :lsbdistid => 'linuxmint', - :osfamily => 'Debian', - :lsbdistcodename => 'qiana', - :puppetversion => Puppet.version, - } - end - context 'sets all the needed things' do - let(:params) do - { - :location => 'http://archive.ubuntu.com/ubuntu', - :release => 'trusty-backports', - :repos => 'main universe multiverse restricted', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - } - end - it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://archive.ubuntu.com/ubuntu', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - :repos => 'main universe multiverse restricted', - :release => 'trusty-backports', - :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, - }) - } - end - context 'missing location' do - let(:params) do - { - :release => 'trusty-backports', - :repos => 'main universe multiverse restricted', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) - end - end - context 'missing release' do - let(:params) do - { - :location => 'http://archive.ubuntu.com/ubuntu', - :repos => 'main universe multiverse restricted', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) - end - end - context 'missing repos' do - let(:params) do - { - :location => 'http://archive.ubuntu.com/ubuntu', - :release => 'trusty-backports', - :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) - end - end - context 'missing key' do - let(:params) do - { - :location => 'http://archive.ubuntu.com/ubuntu', - :release => 'trusty-backports', - :repos => 'main universe multiverse restricted', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) - end - end - end - describe 'validation' do - let(:facts) do - { - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistcodename => 'trusty', - :lsbdistrelease => '14.04', - :puppetversion => Puppet.version, - } - end - context 'invalid location' do - let(:params) do - { - :location => true - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /is not a string/) - end - end - context 'invalid release' do - let(:params) do - { - :release => true - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /is not a string/) - end - end - context 'invalid repos' do - let(:params) do - { - :repos => true - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /is not a string/) - end - end - context 'invalid key' do - let(:params) do - { - :key => true - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /is not a string/) - end - end - context 'invalid pin' do - let(:params) do - { - :pin => true - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/) - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/classes/apt_spec.rb b/vagrant/puppet/modules/apt/spec/classes/apt_spec.rb deleted file mode 100644 index bf539bb35..000000000 --- a/vagrant/puppet/modules/apt/spec/classes/apt_spec.rb +++ /dev/null @@ -1,333 +0,0 @@ -require 'spec_helper' -describe 'apt' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} } - - context 'defaults' do - it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({ - :ensure => 'file', - :path => '/etc/apt/sources.list', - :owner => 'root', - :group => 'root', - :mode => '0644', - :notify => 'Class[Apt::Update]', - })} - - it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({ - :ensure => 'directory', - :path => '/etc/apt/sources.list.d', - :owner => 'root', - :group => 'root', - :mode => '0644', - :purge => false, - :recurse => false, - :notify => 'Class[Apt::Update]', - })} - - it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({ - :ensure => 'file', - :path => '/etc/apt/preferences', - :owner => 'root', - :group => 'root', - :mode => '0644', - :notify => 'Class[Apt::Update]', - })} - - it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({ - :ensure => 'directory', - :path => '/etc/apt/preferences.d', - :owner => 'root', - :group => 'root', - :mode => '0644', - :purge => false, - :recurse => false, - :notify => 'Class[Apt::Update]', - })} - - it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do - is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ - :group => 'root', - :mode => '0644', - :owner => 'root', - }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/) - end - - it { is_expected.to contain_exec('apt_update').with({ - :refreshonly => 'true', - })} - - it { is_expected.not_to contain_apt__setting('conf-proxy') } - end - - describe 'proxy=' do - context 'host=localhost' do - let(:params) { { :proxy => { 'host' => 'localhost'} } } - it { is_expected.to contain_apt__setting('conf-proxy').with({ - :priority => '01', - }).with_content( - /Acquire::http::proxy "http:\/\/localhost:8080\/";/ - ).without_content( - /Acquire::https::proxy/ - )} - end - - context 'host=localhost and port=8180' do - let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } } - it { is_expected.to contain_apt__setting('conf-proxy').with({ - :priority => '01', - }).with_content( - /Acquire::http::proxy "http:\/\/localhost:8180\/";/ - ).without_content( - /Acquire::https::proxy/ - )} - end - - context 'host=localhost and https=true' do - let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } } - it { is_expected.to contain_apt__setting('conf-proxy').with({ - :priority => '01', - }).with_content( - /Acquire::http::proxy "http:\/\/localhost:8080\/";/ - ).with_content( - /Acquire::https::proxy "https:\/\/localhost:8080\/";/ - )} - end - - context 'ensure=absent' do - let(:params) { { :proxy => { 'ensure' => 'absent'} } } - it { is_expected.to contain_apt__setting('conf-proxy').with({ - :ensure => 'absent', - :priority => '01', - })} - end - end - context 'lots of non-defaults' do - let :params do - { - :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, - :purge => { 'sources.list' => false, 'sources.list.d' => false, - 'preferences' => false, 'preferences.d' => false, }, - } - end - - it { is_expected.to contain_file('sources.list').with({ - :content => nil, - })} - - it { is_expected.to contain_file('sources.list.d').with({ - :purge => false, - :recurse => false, - })} - - it { is_expected.to contain_file('preferences').with({ - :ensure => 'file', - })} - - it { is_expected.to contain_file('preferences.d').with({ - :purge => false, - :recurse => false, - })} - - it { is_expected.to contain_exec('apt_update').with({ - :refreshonly => false, - :timeout => 1, - :tries => 3, - })} - - end - - context 'with sources defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :sources => { - 'debian_unstable' => { - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'unstable', - 'repos' => 'main contrib non-free', - 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, - 'pin' => '-10', - 'include' => {'src' => true,}, - }, - 'puppetlabs' => { - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' }, - } - } } } - - it { - is_expected.to contain_apt__setting('list-debian_unstable').with({ - :ensure => 'present', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } - it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } - - it { - is_expected.to contain_apt__setting('list-puppetlabs').with({ - :ensure => 'present', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } - end - - context 'with confs defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :confs => { - 'foo' => { - 'content' => 'foo', - }, - 'bar' => { - 'content' => 'bar', - } - } } } - - it { is_expected.to contain_apt__conf('foo').with({ - :content => 'foo', - })} - - it { is_expected.to contain_apt__conf('bar').with({ - :content => 'bar', - })} - end - - context 'with keys defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :keys => { - '55BE302B' => { - 'server' => 'subkeys.pgp.net', - }, - '4BD6EC30' => { - 'server' => 'pgp.mit.edu', - } - } } } - - it { is_expected.to contain_apt__key('55BE302B').with({ - :server => 'subkeys.pgp.net', - })} - - it { is_expected.to contain_apt__key('4BD6EC30').with({ - :server => 'pgp.mit.edu', - })} - end - - context 'with ppas defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'ubuntu', - :lsbdistrelease => '12.04', - :puppetversion => Puppet.version, - } - end - let(:params) { { :ppas => { - 'ppa:drizzle-developers/ppa' => {}, - 'ppa:nginx/stable' => {}, - } } } - - it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')} - it { is_expected.to contain_apt__ppa('ppa:nginx/stable')} - end - - context 'with settings defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :settings => { - 'conf-banana' => { 'content' => 'banana' }, - 'pref-banana' => { 'content' => 'banana' }, - } } } - - it { is_expected.to contain_apt__setting('conf-banana')} - it { is_expected.to contain_apt__setting('pref-banana')} - end - - context 'with pins defined on valid osfamily' do - let :facts do - { :osfamily => 'Debian', - :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :pins => { - 'stable' => { 'priority' => 600, 'order' => 50 }, - 'testing' => { 'priority' => 700, 'order' => 100 }, - } } } - - it { is_expected.to contain_apt__pin('stable') } - it { is_expected.to contain_apt__pin('testing') } - end - - describe 'failing tests' do - context "purge['sources.list']=>'banana'" do - let(:params) { { :purge => { 'sources.list' => 'banana' }, } } - it do - expect { - subject.call - }.to raise_error(Puppet::Error) - end - end - - context "purge['sources.list.d']=>'banana'" do - let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } } - it do - expect { - subject.call - }.to raise_error(Puppet::Error) - end - end - - context "purge['preferences']=>'banana'" do - let(:params) { { :purge => { 'preferences' => 'banana' }, } } - it do - expect { - subject.call - }.to raise_error(Puppet::Error) - end - end - - context "purge['preferences.d']=>'banana'" do - let(:params) { { :purge => { 'preferences.d' => 'banana' }, } } - it do - expect { - subject.call - }.to raise_error(Puppet::Error) - end - end - - context 'with unsupported osfamily' do - let :facts do - { :osfamily => 'Darwin', :puppetversion => Puppet.version,} - end - - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/) - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/classes/apt_update_spec.rb b/vagrant/puppet/modules/apt/spec/classes/apt_update_spec.rb deleted file mode 100644 index d031104dd..000000000 --- a/vagrant/puppet/modules/apt/spec/classes/apt_update_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env rspec -require 'spec_helper' - -describe 'apt::update', :type => :class do - context "and apt::update['frequency']='always'" do - { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" } - it 'should trigger an apt-get update run' do - #set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } - it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - context "and apt::update['frequency']='reluctantly'" do - {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version,} } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } - it 'should not trigger an apt-get update run' do - #don't change the apt_update exec's refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) - end - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } - it 'should not trigger an apt-get update run' do - #don't change the apt_update exec's refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) - end - end - end - ['daily','weekly'].each do |update_frequency| - context "and apt::update['frequency'] has the value of #{update_frequency}" do - { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } - it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - context 'when the $::apt_update_last_success fact has a recent value' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } - it 'should not trigger an apt-get update run' do - #don't change the apt_update exec\'s refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => Puppet.version, } } - let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } - it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/classes/params_spec.rb b/vagrant/puppet/modules/apt/spec/classes/params_spec.rb deleted file mode 100644 index 3161cf027..000000000 --- a/vagrant/puppet/modules/apt/spec/classes/params_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' -describe 'apt::params', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - - # There are 4 resources in this class currently - # there should not be any more resources because it is a params class - # The resources are class[apt::params], class[main], class[settings], stage[main] - it "Should not contain any resources" do - expect(subject.call.resources.size).to eq(4) - end - - describe "With lsb-release not installed" do - let(:facts) { { :osfamily => 'Debian', :puppetversion => Puppet.version, } } - let (:title) { 'my_package' } - - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, please install lsb-release first/) - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/conf_spec.rb b/vagrant/puppet/modules/apt/spec/defines/conf_spec.rb deleted file mode 100644 index c74bf1aca..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/conf_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper' -describe 'apt::conf', :type => :define do - let :pre_condition do - 'class { "apt": }' - end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let :title do - 'norecommends' - end - - describe "when creating an apt preference" do - let :default_params do - { - :priority => '00', - :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" - } - end - let :params do - default_params - end - - let :filename do - "/etc/apt/apt.conf.d/00norecommends" - end - - it { is_expected.to contain_file(filename).with({ - 'ensure' => 'present', - 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - }) - } - - context "with notify_update = true (default)" do - let :params do - default_params - end - it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) } - end - - context "with notify_update = false" do - let :params do - default_params.merge({ - :notify_update => false - }) - end - it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) } - end - end - - describe "when creating a preference without content" do - let :params do - { - :priority => '00', - } - end - - it 'fails' do - expect { subject.call } .to raise_error(/pass in content/) - end - end - - describe "when removing an apt preference" do - let :params do - { - :ensure => 'absent', - :priority => '00', - } - end - - let :filename do - "/etc/apt/apt.conf.d/00norecommends" - end - - it { is_expected.to contain_file(filename).with({ - 'ensure' => 'absent', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - }) - } - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/key_compat_spec.rb b/vagrant/puppet/modules/apt/spec/defines/key_compat_spec.rb deleted file mode 100644 index 7937c78db..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/key_compat_spec.rb +++ /dev/null @@ -1,330 +0,0 @@ -require 'spec_helper' - -describe 'apt::key', :type => :define do - let(:facts) { { - :lsbdistid => 'Debian', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } } - GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - - let :title do - GPG_KEY_ID - end - - let :pre_condition do - 'include apt' - end - - describe 'normal operation' do - describe 'default options' do - it { - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :keyserver_options => nil, - }) - } - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") - end - end - - describe 'title and key =>' do - let :title do - 'puppetlabs' - end - - let :params do { - :key => GPG_KEY_ID, - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => GPG_KEY_ID, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :keyserver_options => nil, - }) - end - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") - end - end - - describe 'ensure => absent' do - let :params do { - :ensure => 'absent', - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'absent', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :keyserver_options => nil, - }) - end - it 'contains the apt_key absent anchor' do - is_expected.to contain_anchor("apt_key #{title} absent") - end - end - - describe 'set a bunch of things!' do - let :params do { - :key_content => 'GPG key content', - :key_source => 'http://apt.puppetlabs.com/pubkey.gpg', - :key_server => 'pgp.mit.edu', - :key_options => 'debug', - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :server => 'pgp.mit.edu', - :content => params[:key_content], - :options => 'debug', - }) - end - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") - end - end - - context "domain with dash" do - let(:params) do{ - :key_server => 'p-gp.m-it.edu', - } end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'p-gp.m-it.edu', - }) - end - end - - context "url" do - let :params do - { - :key_server => 'hkp://pgp.mit.edu', - } - end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'hkp://pgp.mit.edu', - }) - end - end - context "url with port number" do - let :params do - { - :key_server => 'hkp://pgp.mit.edu:80', - } - end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'hkp://pgp.mit.edu:80', - }) - end - end - end - - describe 'validation' do - context "domain begin with dash" do - let(:params) do{ - :key_server => '-pgp.mit.edu', - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - - context "domain begin with dot" do - let(:params) do{ - :key_server => '.pgp.mit.edu', - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - - context "domain end with dot" do - let(:params) do{ - :key_server => "pgp.mit.edu.", - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - context "exceed character url" do - let :params do - { - :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "incorrect port number url" do - let :params do - { - :key_server => 'hkp://pgp.mit.edu:8008080' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "incorrect protocol for url" do - let :params do - { - :key_server => 'abc://pgp.mit.edu:80' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "missing port number url" do - let :params do - { - :key_server => 'hkp://pgp.mit.edu:' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "url ending with a dot" do - let :params do - { - :key_server => 'hkp://pgp.mit.edu.' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "url begin with a dash" do - let(:params) do{ - :key_server => "hkp://-pgp.mit.edu", - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context 'invalid key' do - let :title do - 'Out of rum. Why? Why are we out of rum?' - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid source' do - let :params do { - :key_source => 'afp://puppetlabs.com/key.gpg', - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid content' do - let :params do { - :key_content => [], - } end - it 'fails' do - expect { subject.call }.to raise_error(/is not a string/) - end - end - - context 'invalid server' do - let :params do { - :key_server => 'two bottles of rum', - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid keyserver_options' do - let :params do { - :key_options => {}, - } end - it 'fails' do - expect { subject.call }.to raise_error(/is not a string/) - end - end - - context 'invalid ensure' do - let :params do - { - :ensure => 'foo', - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - describe 'duplication' do - context 'two apt::key resources for same key, different titles' do - let :pre_condition do - "#{super()}\napt::key { 'duplicate': key => '#{title}', }" - end - - it 'contains the duplicate apt::key resource' do - is_expected.to contain_apt__key('duplicate').with({ - :key => title, - :ensure => 'present', - }) - end - - it 'contains the original apt::key resource' do - is_expected.to contain_apt__key(title).with({ - :id => title, - :ensure => 'present', - }) - end - - it 'contains the native apt_key' do - is_expected.to contain_apt_key('duplicate').with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :keyserver_options => nil, - }) - end - - it 'does not contain the original apt_key' do - is_expected.not_to contain_apt_key(title) - end - end - - context 'two apt::key resources, different ensure' do - let :pre_condition do - "#{super()}\napt::key { 'duplicate': key => '#{title}', ensure => 'absent', }" - end - it 'informs the user of the impossibility' do - expect { subject.call }.to raise_error(/already ensured as absent/) - end - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/key_spec.rb b/vagrant/puppet/modules/apt/spec/defines/key_spec.rb deleted file mode 100644 index 14a3efbc5..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/key_spec.rb +++ /dev/null @@ -1,325 +0,0 @@ -require 'spec_helper' - -describe 'apt::key' do - let :pre_condition do - 'class { "apt": }' - end - - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - - GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - - let :title do - GPG_KEY_ID - end - - describe 'normal operation' do - describe 'default options' do - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :options => nil, - }) - end - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") - end - end - - describe 'title and key =>' do - let :title do - 'puppetlabs' - end - - let :params do { - :id => GPG_KEY_ID, - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => GPG_KEY_ID, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :options => nil, - }) - end - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") - end - end - - describe 'ensure => absent' do - let :params do { - :ensure => 'absent', - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'absent', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :keyserver => nil, - }) - end - it 'contains the apt_key absent anchor' do - is_expected.to contain_anchor("apt_key #{title} absent") - end - end - - describe 'set a bunch of things!' do - let :params do { - :content => 'GPG key content', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :server => 'pgp.mit.edu', - :options => 'debug', - } end - - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :server => 'pgp.mit.edu', - :content => params[:content], - :options => 'debug', - }) - end - it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") - end - end - - context "domain with dash" do - let(:params) do{ - :server => 'p-gp.m-it.edu', - } end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'p-gp.m-it.edu', - }) - end - end - - context "url" do - let :params do - { - :server => 'hkp://pgp.mit.edu', - } - end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'hkp://pgp.mit.edu', - }) - end - end - context "url with port number" do - let :params do - { - :server => 'hkp://pgp.mit.edu:80', - } - end - it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with({ - :id => title, - :server => 'hkp://pgp.mit.edu:80', - }) - end - end - end - - describe 'validation' do - context "domain begin with dash" do - let(:params) do{ - :server => '-pgp.mit.edu', - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - - context "domain begin with dot" do - let(:params) do{ - :server => '.pgp.mit.edu', - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - - context "domain end with dot" do - let(:params) do{ - :server => "pgp.mit.edu.", - } end - it 'fails' do - expect { subject.call } .to raise_error(/does not match/) - end - end - context "exceed character url" do - let :params do - { - :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "incorrect port number url" do - let :params do - { - :server => 'hkp://pgp.mit.edu:8008080' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "incorrect protocol for url" do - let :params do - { - :server => 'abc://pgp.mit.edu:80' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "missing port number url" do - let :params do - { - :server => 'hkp://pgp.mit.edu:' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "url ending with a dot" do - let :params do - { - :server => 'hkp://pgp.mit.edu.' - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context "url begin with a dash" do - let(:params) do{ - :server => "hkp://-pgp.mit.edu", - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - context 'invalid key' do - let :title do - 'Out of rum. Why? Why are we out of rum?' - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid source' do - let :params do { - :source => 'afp://puppetlabs.com/key.gpg', - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid content' do - let :params do { - :content => [], - } end - it 'fails' do - expect { subject.call }.to raise_error(/is not a string/) - end - end - - context 'invalid server' do - let :params do { - :server => 'two bottles of rum', - } end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - - context 'invalid options' do - let :params do { - :options => {}, - } end - it 'fails' do - expect { subject.call }.to raise_error(/is not a string/) - end - end - - context 'invalid ensure' do - %w(foo aabsent absenta apresent presenta).each do |param| - let :params do - { - :ensure => param, - } - end - it 'fails' do - expect { subject.call }.to raise_error(/does not match/) - end - end - end - - describe 'duplication' do - context 'two apt::key resources for same key, different titles' do - let :pre_condition do - "class { 'apt': } - apt::key { 'duplicate': id => '#{title}', }" - end - - it 'contains two apt::key resources' do - is_expected.to contain_apt__key('duplicate').with({ - :id => title, - :ensure => 'present', - }) - is_expected.to contain_apt__key(title).with({ - :id => title, - :ensure => 'present', - }) - end - - it 'contains only a single apt_key' do - is_expected.to contain_apt_key('duplicate').with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => 'keyserver.ubuntu.com', - :content => nil, - :options => nil, - }) - is_expected.not_to contain_apt_key(title) - end - end - - context 'two apt::key resources, different ensure' do - let :pre_condition do - "class { 'apt': } - apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" - end - it 'informs the user of the impossibility' do - expect { subject.call }.to raise_error(/already ensured as absent/) - end - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/pin_spec.rb b/vagrant/puppet/modules/apt/spec/defines/pin_spec.rb deleted file mode 100644 index 9fb28c665..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/pin_spec.rb +++ /dev/null @@ -1,145 +0,0 @@ -require 'spec_helper' -describe 'apt::pin', :type => :define do - let :pre_condition do - 'class { "apt": }' - end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let(:title) { 'my_pin' } - - context 'defaults' do - it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin") } - end - - context 'set version' do - let :params do - { - 'packages' => 'vim', - 'version' => '1', - } - end - it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin") } - end - - context 'set origin' do - let :params do - { - 'packages' => 'vim', - 'origin' => 'test', - } - end - it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin") } - end - - context 'not defaults' do - let :params do - { - 'explanation' => 'foo', - 'order' => 99, - 'release' => '1', - 'codename' => 'bar', - 'release_version' => '2', - 'component' => 'baz', - 'originator' => 'foobar', - 'label' => 'foobaz', - 'priority' => 10, - } - end - it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } - it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'priority' => 99, - }) - } - end - - context 'ensure absent' do - let :params do - { - 'ensure' => 'absent' - } - end - it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'ensure' => 'absent', - }) - } - end - - context 'bad characters' do - let(:title) { 'such bad && wow!' } - it { is_expected.to contain_apt__setting("pref-such__bad____wow_") } - end - - describe 'validation' do - context 'invalid order' do - let :params do - { - 'order' => 'foo', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /Only integers are allowed/) - end - end - - context 'packages == * and version' do - let :params do - { - 'version' => '1', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/) - end - end - - context 'packages == * and release and origin' do - let :params do - { - 'origin' => 'test', - 'release' => 'foo', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/) - end - end - - context 'specific form with release and origin' do - let :params do - { - 'release' => 'foo', - 'origin' => 'test', - 'packages' => 'vim', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) - end - end - - context 'specific form with version and origin' do - let :params do - { - 'version' => '1', - 'origin' => 'test', - 'packages' => 'vim', - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/ppa_spec.rb b/vagrant/puppet/modules/apt/spec/defines/ppa_spec.rb deleted file mode 100644 index a4c30142e..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/ppa_spec.rb +++ /dev/null @@ -1,378 +0,0 @@ -require 'spec_helper' -describe 'apt::ppa' do - let :pre_condition do - 'class { "apt": }' - end - - describe 'defaults' do - let :facts do - { - :lsbdistrelease => '11.04', - :lsbdistcodename => 'natty', - :operatingsystem => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :puppetversion => Puppet.version, - } - end - - let(:title) { 'ppa:needs/such.substitution/wow+type' } - it { is_expected.to_not contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with({ - :environment => [], - :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'Ubuntu 15.10 sources.list filename' do - let :facts do - { - :lsbdistrelease => '15.10', - :lsbdistcodename => 'wily', - :operatingsystem => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :puppetversion => Puppet.version, - } - end - - let(:title) { 'ppa:user/foo' } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ - :environment => [], - :command => '/usr/bin/add-apt-repository -y ppa:user/foo', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'ppa depending on ppa, MODULES-1156' do - let :pre_condition do - 'class { "apt": }' - end - end - - describe 'package_name => software-properties-common' do - let :pre_condition do - 'class { "apt": }' - end - let :params do - { - :package_name => 'software-properties-common', - :package_manage => true, - } - end - let :facts do - { - :lsbdistrelease => '11.04', - :lsbdistcodename => 'natty', - :operatingsystem => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :puppetversion => Puppet.version, - } - end - - let(:title) { 'ppa:needs/such.substitution/wow' } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ - 'environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ - 'ensure' => 'file', - }) - } - end - - describe 'package_manage => true, multiple ppas, MODULES-2873' do - let :pre_condition do - 'class { "apt": } - apt::ppa {"ppa:user/foo": - package_manage => true - }' - end - let :facts do - { - :lsbdistrelease => '11.04', - :lsbdistcodename => 'natty', - :operatingsystem => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :puppetversion => Puppet.version, - } - end - let :params do - { - :package_manage => true, - } - end - - let(:title) { 'ppa:user/bar' } - it { is_expected.to contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/bar').that_notifies('Class[Apt::Update]').with({ - 'environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:user/bar', - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/user-bar-natty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/user-bar-natty.list').that_requires('Exec[add-apt-repository-ppa:user/bar]').with({ - 'ensure' => 'file', - }) - } - end - - describe 'package_manage => false' do - let :pre_condition do - 'class { "apt": }' - end - let :facts do - { - :lsbdistrelease => '11.04', - :lsbdistcodename => 'natty', - :operatingsystem => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :puppetversion => Puppet.version, - } - end - let :params do - { - :package_manage => false, - } - end - - let(:title) { 'ppa:needs/such.substitution/wow' } - it { is_expected.to_not contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ - 'environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ - 'ensure' => 'file', - }) - } - end - - describe 'apt included, no proxy' do - let :pre_condition do - 'class { "apt": } - apt::ppa { "ppa:user/foo2": } - ' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :options => '', - :package_manage => true, - :require => 'Apt::Ppa[ppa:user/foo2]', - } - end - let(:title) { 'ppa:user/foo' } - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ - :environment => [], - :command => '/usr/bin/add-apt-repository ppa:user/foo', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'apt included, proxy host' do - let :pre_condition do - 'class { "apt": - proxy => { "host" => "localhost" }, - }' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - 'options' => '', - 'package_manage' => true, - } - end - let(:title) { 'ppa:user/foo' } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ - :environment => ['http_proxy=http://localhost:8080'], - :command => '/usr/bin/add-apt-repository ppa:user/foo', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'apt included, proxy host and port' do - let :pre_condition do - 'class { "apt": - proxy => { "host" => "localhost", "port" => 8180 }, - }' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :options => '', - :package_manage => true, - } - end - let(:title) { 'ppa:user/foo' } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ - :environment => ['http_proxy=http://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:user/foo', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'apt included, proxy host and port and https' do - let :pre_condition do - 'class { "apt": - proxy => { "host" => "localhost", "port" => 8180, "https" => true }, - }' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :options => '', - :package_manage => true, - } - end - let(:title) { 'ppa:user/foo' } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ - :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:user/foo', - :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', - :user => 'root', - :logoutput => 'on_failure', - }) - } - end - - describe 'ensure absent' do - let :pre_condition do - 'class { "apt": }' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:title) { 'ppa:user/foo' } - let :params do - { - :ensure => 'absent' - } - end - it { is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with({ - :ensure => 'absent', - }) - } - end - - context 'validation' do - describe 'no release' do - let :facts do - { - :lsbdistrelease => '14.04', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - :lsbdistcodeanme => nil, - :puppetversion => Puppet.version, - } - end - let(:title) { 'ppa:user/foo' } - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) - end - end - - describe 'not ubuntu' do - let :facts do - { - :lsbdistrelease => '6.0.7', - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :lsbdistid => 'debian', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:title) { 'ppa:user/foo' } - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /not currently supported on Debian/) - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/setting_spec.rb b/vagrant/puppet/modules/apt/spec/defines/setting_spec.rb deleted file mode 100644 index a326bdbdd..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/setting_spec.rb +++ /dev/null @@ -1,115 +0,0 @@ -require 'spec_helper' - -describe 'apt::setting' do - let(:pre_condition) { 'class { "apt": }' } - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let(:title) { 'conf-teddybear' } - - let(:default_params) { { :content => 'di' } } - - describe 'when using the defaults' do - context 'without source or content' do - it do - expect { subject.call }.to raise_error(Puppet::Error, /needs either of /) - end - end - - context 'with title=conf-teddybear ' do - let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') } - end - - context 'with title=pref-teddybear' do - let(:title) { 'pref-teddybear' } - let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') } - end - - context 'with title=list-teddybear' do - let(:title) { 'list-teddybear' } - let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') } - end - - context 'with source' do - let(:params) { { :source => 'puppet:///la/die/dah' } } - it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ - :ensure => 'file', - :owner => 'root', - :group => 'root', - :mode => '0644', - :source => "#{params[:source]}", - })} - end - - context 'with content' do - let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ - :ensure => 'file', - :owner => 'root', - :group => 'root', - :mode => '0644', - :content => "#{params[:content]}", - })} - end - end - - describe 'settings requiring settings, MODULES-769' do - let(:pre_condition) do - 'class { "apt": } - apt::setting { "list-teddybear": content => "foo" } - ' - end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } - let(:title) { 'conf-teddybear' } - let(:default_params) { { :content => 'di' } } - - let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) } - - it { is_expected.to compile.with_all_deps } - end - - describe 'when trying to pull one over' do - context 'with source and content' do - let(:params) { default_params.merge({ :source => 'la' }) } - it do - expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /) - end - end - - context 'with title=ext-teddybear' do - let(:title) { 'ext-teddybear' } - let(:params) { default_params } - it do - expect { subject.call }.to raise_error(Puppet::Error, /must start with /) - end - end - - context 'with ensure=banana' do - let(:params) { default_params.merge({ :ensure => 'banana' }) } - it do - expect { subject.call }.to raise_error(Puppet::Error, /"banana" does not /) - end - end - - context 'with priority=1.2' do - let(:params) { default_params.merge({ :priority => 1.2 }) } - it do - expect { subject.call }.to raise_error(Puppet::Error, /be an integer /) - end - end - end - - describe 'with priority=100' do - let(:params) { default_params.merge({ :priority => 100 }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') } - end - - describe 'with ensure=absent' do - let(:params) { default_params.merge({ :ensure => 'absent' }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ - :ensure => 'absent', - })} - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/source_compat_spec.rb b/vagrant/puppet/modules/apt/spec/defines/source_compat_spec.rb deleted file mode 100644 index 26309d9dc..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/source_compat_spec.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'spec_helper' - -describe 'apt::source', :type => :define do - GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - - let :title do - 'my_source' - end - - context 'mostly defaults' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - - let :params do - { - 'include_deb' => false, - 'include_src' => true, - 'location' => 'http://debian.mirror.iweb.ca/debian/', - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) - } - end - - context 'no defaults' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - 'comment' => 'foo', - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'sid', - 'repos' => 'testing', - 'include_src' => false, - 'required_packages' => 'vim', - 'key' => GPG_KEY_ID, - 'key_server' => 'pgp.mit.edu', - 'key_content' => 'GPG key content', - 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', - 'pin' => '10', - 'architecture' => 'x86_64', - 'trusted_source' => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) - } - - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - 'ensure' => 'present', - 'priority' => '10', - 'origin' => 'debian.mirror.iweb.ca', - }) - } - - it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - 'command' => '/usr/bin/apt-get -y install vim', - 'logoutput' => 'on_failure', - 'refreshonly' => true, - 'tries' => '3', - 'try_sleep' => '1', - }) - } - - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - 'ensure' => 'present', - 'id' => GPG_KEY_ID, - 'key_server' => 'pgp.mit.edu', - 'key_content' => 'GPG key content', - 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', - }) - } - end - - context 'trusted_source true' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - 'include_src' => false, - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'trusted_source' => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } - end - - context 'architecture equals x86_64' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'architecture' => 'x86_64', - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) - } - end - - context 'ensure => absent' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - 'ensure' => 'absent', - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'absent' - }) - } - end - - describe 'validation' do - context 'no release' do - let :facts do - { - :lsbdistid => 'Debian', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - - it do - expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) - end - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/defines/source_spec.rb b/vagrant/puppet/modules/apt/spec/defines/source_spec.rb deleted file mode 100644 index 4c3321af9..000000000 --- a/vagrant/puppet/modules/apt/spec/defines/source_spec.rb +++ /dev/null @@ -1,444 +0,0 @@ -require 'spec_helper' - -describe 'apt::source' do - GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - - let :pre_condition do - 'class { "apt": }' - end - - let :title do - 'my_source' - end - - context 'defaults' do - context 'without location' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /source entry without specifying a location/) - end - end - context 'with location' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :location => 'hello.there', } } - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/) - } - end - end - - describe 'no defaults' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - - context 'with complex pin' do - let :params do - { - :location => 'hello.there', - :pin => { 'release' => 'wishwash', - 'explanation' => 'wishwash', - 'priority' => 1001, }, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/hello.there wheezy main\n/) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')} - - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :priority => 1001, - :explanation => 'wishwash', - :release => 'wishwash', - }) - } - end - - context 'with simple key' do - let :params do - { - :comment => 'foo', - :location => 'http://debian.mirror.iweb.ca/debian/', - :release => 'sid', - :repos => 'testing', - :key => GPG_KEY_ID, - :pin => '10', - :architecture => 'x86_64', - :allow_unsigned => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) - } - - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :priority => '10', - :origin => 'debian.mirror.iweb.ca', - }) - } - - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :id => GPG_KEY_ID, - }) - } - end - - context 'with complex key' do - let :params do - { - :comment => 'foo', - :location => 'http://debian.mirror.iweb.ca/debian/', - :release => 'sid', - :repos => 'testing', - :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', - 'content' => 'GPG key content', - 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',}, - :pin => '10', - :architecture => 'x86_64', - :allow_unsigned => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) - } - - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :priority => '10', - :origin => 'debian.mirror.iweb.ca', - }) - } - - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :id => GPG_KEY_ID, - :server => 'pgp.mit.edu', - :content => 'GPG key content', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - }) - } - end - - context 'with simple key' do - let :params do - { - :comment => 'foo', - :location => 'http://debian.mirror.iweb.ca/debian/', - :release => 'sid', - :repos => 'testing', - :key => GPG_KEY_ID, - :pin => '10', - :architecture => 'x86_64', - :allow_unsigned => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) - } - - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :priority => '10', - :origin => 'debian.mirror.iweb.ca', - }) - } - - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - :ensure => 'present', - :id => GPG_KEY_ID, - }) - } - end - end - - context 'allow_unsigned true' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :allow_unsigned => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/) - } - end - - context 'architecture equals x86_64' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :include => {'deb' => false, 'src' => true,}, - :architecture => 'x86_64', - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n/) - } - end - - context 'include_src => true' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :include_src => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/) - } - end - - context 'include_deb => false' do - let :facts do - { - :lsbdistid => 'debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :include_deb => false, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).without_content(/deb-src hello.there wheezy main\n/) - } - it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } - end - - context 'include_src => true and include_deb => false' do - let :facts do - { - :lsbdistid => 'debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :include_deb => false, - :include_src => true, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/deb-src hello.there wheezy main\n/) - } - it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } - end - - context 'include precedence' do - let :facts do - { - :lsbdistid => 'debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :include_deb => true, - :include_src => false, - :include => { 'deb' => false, 'src' => true }, - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/deb-src hello.there wheezy main\n/) - } - it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } - end - - context 'ensure => absent' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :ensure => 'absent', - } - end - - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'absent' - }) - } - end - - describe 'validation' do - context 'no release' do - let :facts do - { - :lsbdistid => 'Debian', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let(:params) { { :location => 'hello.there', } } - - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) - end - end - - context 'invalid pin' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :pin => true, - } - end - - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /invalid value for pin/) - end - end - - context "with notify_update = undef (default)" do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - } - end - it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) } - end - - context "with notify_update = true" do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :notify_update => true, - } - end - it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) } - end - - context "with notify_update = false" do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :puppetversion => Puppet.version, - } - end - let :params do - { - :location => 'hello.there', - :notify_update => false, - } - end - it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) } - end - - end -end diff --git a/vagrant/puppet/modules/apt/spec/spec.opts b/vagrant/puppet/modules/apt/spec/spec.opts deleted file mode 100644 index 91cd6427e..000000000 --- a/vagrant/puppet/modules/apt/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/vagrant/puppet/modules/apt/spec/spec_helper.rb b/vagrant/puppet/modules/apt/spec/spec_helper.rb deleted file mode 100644 index 22d5d689f..000000000 --- a/vagrant/puppet/modules/apt/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -#This file is generated by ModuleSync, do not edit. -require 'puppetlabs_spec_helper/module_spec_helper' - -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError -end diff --git a/vagrant/puppet/modules/apt/spec/spec_helper_acceptance.rb b/vagrant/puppet/modules/apt/spec/spec_helper_acceptance.rb deleted file mode 100644 index 409ce68b2..000000000 --- a/vagrant/puppet/modules/apt/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'beaker-rspec' -require 'beaker/puppet_install_helper' - -run_puppet_install_helper - -UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris'] - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - hosts.each do |host| - copy_module_to(host, :source => proj_root, :module_name => 'apt') - shell("/bin/touch #{default['puppetpath']}/hiera.yaml") - on host, puppet('module install puppetlabs-stdlib --version 4.5.0'), { :acceptable_exit_codes => [0,1] } - end - end -end diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_has_updates_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_has_updates_spec.rb deleted file mode 100644 index bcd6bb554..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_has_updates_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'apt_has_updates fact' do - subject { Facter.fact(:apt_has_updates).value } - after(:each) { Facter.clear } - - describe 'on non-Debian distro' do - before { - Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat' - } - it { is_expected.to be_nil } - end - - describe 'on Debian based distro missing apt-get' do - before { - Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' - File.stubs(:executable?) # Stub all other calls - File.expects(:executable?).with('/usr/bin/apt-get').returns false - } - it { is_expected.to be_nil } - end - - describe 'on Debian based distro' do - before { - Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' - File.stubs(:executable?) # Stub all other calls - Facter::Util::Resolution.stubs(:exec) # Catch all other calls - File.expects(:executable?).with('/usr/bin/apt-get').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+ - "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+ - "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" - } - it { is_expected.to be true } - end -end - diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_package_updates_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_package_updates_spec.rb deleted file mode 100644 index d7587ca99..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_package_updates_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'apt_package_updates fact' do - subject { Facter.fact(:apt_package_updates).value } - after(:each) { Facter.clear } - - describe 'when apt has no updates' do - before { - Facter.fact(:apt_has_updates).stubs(:value).returns false - } - it { is_expected.to be nil } - end - - describe 'when apt has updates' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?) # Stub all other calls - Facter::Util::Resolution.stubs(:exec) # Catch all other calls - File.expects(:executable?).with('/usr/bin/apt-get').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+ - "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+ - "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" - } - it { - if Facter.version < '2.0.0' - is_expected.to eq('tzdata,unhide.rb') - else - is_expected.to eq(['tzdata','unhide.rb']) - end - } - end -end diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_reboot_required_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_reboot_required_spec.rb deleted file mode 100644 index ed6efd075..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_reboot_required_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'apt_reboot_required fact' do - subject { Facter.fact(:apt_reboot_required).value } - after(:each) { Facter.clear } - - describe 'if a reboot is required' do - before { - Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' - File.stubs(:file?).returns true - File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns true - } - it { is_expected.to eq true } - end - - describe 'if a reboot is not required' do - before { - Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' - File.stubs(:file?).returns true - File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns false - } - it { is_expected.to eq false } - end - -end diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_security_updates_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_security_updates_spec.rb deleted file mode 100644 index 174b60d6b..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_security_updates_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'apt_security_updates fact' do - subject { Facter.fact(:apt_security_updates).value } - after(:each) { Facter.clear } - - describe 'when apt has no updates' do - before { - Facter.fact(:apt_has_updates).stubs(:value).returns false - } - it { is_expected.to be nil } - end - - describe 'when apt has security updates' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?) # Stub all other calls - Facter::Util::Resolution.stubs(:exec) # Catch all other calls - File.expects(:executable?).with('/usr/bin/apt-get').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+ - "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+ - "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" - } - it { is_expected.to eq(1) } - end - -end diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_update_last_success_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_update_last_success_spec.rb deleted file mode 100644 index cb32a5ef0..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_update_last_success_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'apt_update_last_success fact' do - subject { Facter.fact(:apt_update_last_success).value } - after(:each) { Facter.clear } - - describe 'on Debian based distro which has not yet created the update-success-stamp file' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:exists?).returns false - } - it 'should have a value of -1' do - is_expected.to eq(-1) - end - end - - describe 'on Debian based distro which has created the update-success-stamp' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:exists?).returns true - File.stubs(:mtime).returns 1407660561 - } - it 'should have the value of the mtime of the file' do - is_expected.to eq(1407660561) - end - end - -end diff --git a/vagrant/puppet/modules/apt/spec/unit/facter/apt_updates_spec.rb b/vagrant/puppet/modules/apt/spec/unit/facter/apt_updates_spec.rb deleted file mode 100644 index 8c726fc34..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/facter/apt_updates_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'apt_updates fact' do - subject { Facter.fact(:apt_updates).value } - after(:each) { Facter.clear } - - describe 'when apt has no updates' do - before { - Facter.fact(:apt_has_updates).stubs(:value).returns false - } - it { is_expected.to be nil } - end - - describe 'when apt has updates' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?) # Stub all other calls - Facter::Util::Resolution.stubs(:exec) # Catch all other calls - File.expects(:executable?).with('/usr/bin/apt-get').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+ - "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+ - "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+ - "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" - } - it { is_expected.to eq(2) } - end - -end diff --git a/vagrant/puppet/modules/apt/spec/unit/puppet/type/apt_key_spec.rb b/vagrant/puppet/modules/apt/spec/unit/puppet/type/apt_key_spec.rb deleted file mode 100644 index e412b5066..000000000 --- a/vagrant/puppet/modules/apt/spec/unit/puppet/type/apt_key_spec.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'spec_helper' -require 'puppet' - -describe Puppet::Type::type(:apt_key) do - context 'only namevar 32bit key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30' - )} - it 'id is set' do - expect(resource[:id]).to eq '4BD6EC30' - end - - it 'name is set to id' do - expect(resource[:name]).to eq '4BD6EC30' - end - - it 'keyserver is default' do - expect(resource[:server]).to eq :'keyserver.ubuntu.com' - end - - it 'source is not set' do - expect(resource[:source]).to eq nil - end - - it 'content is not set' do - expect(resource[:content]).to eq nil - end - end - - context 'with a lowercase 32bit key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '4bd6ec30' - )} - it 'id is set' do - expect(resource[:id]).to eq '4BD6EC30' - end - end - - context 'with a 64bit key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => 'FFFFFFFF4BD6EC30' - )} - it 'id is set' do - expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' - end - end - - context 'with a 0x formatted key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '0x4BD6EC30' - )} - it 'id is set' do - expect(resource[:id]).to eq '4BD6EC30' - end - end - - context 'with a 0x formatted lowercase key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '0x4bd6ec30' - )} - it 'id is set' do - expect(resource[:id]).to eq '4BD6EC30' - end - end - - context 'with a 0x formatted 64bit key id' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '0xFFFFFFFF4BD6EC30' - )} - it 'id is set' do - expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' - end - end - - context 'with source' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'http://apt.puppetlabs.com/pubkey.gpg' - )} - - it 'source is set to the URL' do - expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' - end - end - - context 'with content' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :content => 'http://apt.puppetlabs.com/pubkey.gpg' - )} - - it 'content is set to the string' do - expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' - end - end - - context 'with keyserver' do - let(:resource) { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :server => 'http://keyring.debian.org' - )} - - it 'keyserver is set to Debian' do - expect(resource[:server]).to eq 'http://keyring.debian.org' - end - end - - context 'validation' do - it 'raises an error if content and source are set' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :content => 'Completely invalid as a GPG key' - )}.to raise_error(/content and source are mutually exclusive/) - end - - it 'raises an error if a weird length key is used' do - expect { Puppet::Type.type(:apt_key).new( - :id => 'F4BD6EC30', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :content => 'Completely invalid as a GPG key' - )}.to raise_error(/Valid values match/) - end - - it 'raises an error when an invalid URI scheme is used in source' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'hkp://pgp.mit.edu' - )}.to raise_error(/Valid values match/) - end - - it 'allows the http URI scheme in source' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'http://pgp.mit.edu' - )}.to_not raise_error - end - - it 'allows the https URI scheme in source' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'https://pgp.mit.edu' - )}.to_not raise_error - end - - it 'allows the https URI with username and password' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'https://testme:Password2@pgp.mit.edu' - )}.to_not raise_error - end - - it 'allows the ftp URI scheme in source' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'ftp://pgp.mit.edu' - )}.to_not raise_error - end - - it 'allows an absolute path in source' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => '/path/to/a/file' - )}.to_not raise_error - end - - it 'allows 5-digit ports' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :source => 'http://pgp.mit.edu:12345/key' - )}.to_not raise_error - end - - it 'allows 5-digit ports when using key servers' do - expect { Puppet::Type.type(:apt_key).new( - :id => '4BD6EC30', - :server => 'http://pgp.mit.edu:12345' - )}.to_not raise_error - end - end -end diff --git a/vagrant/puppet/modules/apt/templates/15update-stamp.erb b/vagrant/puppet/modules/apt/templates/15update-stamp.erb deleted file mode 100644 index 14ead8376..000000000 --- a/vagrant/puppet/modules/apt/templates/15update-stamp.erb +++ /dev/null @@ -1 +0,0 @@ -APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";}; diff --git a/vagrant/puppet/modules/apt/templates/_conf_header.erb b/vagrant/puppet/modules/apt/templates/_conf_header.erb deleted file mode 100644 index bfa365e23..000000000 --- a/vagrant/puppet/modules/apt/templates/_conf_header.erb +++ /dev/null @@ -1 +0,0 @@ -// This file is managed by Puppet. DO NOT EDIT. diff --git a/vagrant/puppet/modules/apt/templates/_header.erb b/vagrant/puppet/modules/apt/templates/_header.erb deleted file mode 100644 index 487e581c7..000000000 --- a/vagrant/puppet/modules/apt/templates/_header.erb +++ /dev/null @@ -1 +0,0 @@ -# This file is managed by Puppet. DO NOT EDIT. diff --git a/vagrant/puppet/modules/apt/templates/conf.erb b/vagrant/puppet/modules/apt/templates/conf.erb deleted file mode 100644 index a35d1d4f8..000000000 --- a/vagrant/puppet/modules/apt/templates/conf.erb +++ /dev/null @@ -1 +0,0 @@ -<%= @content -%> diff --git a/vagrant/puppet/modules/apt/templates/pin.pref.erb b/vagrant/puppet/modules/apt/templates/pin.pref.erb deleted file mode 100644 index 76936d7ca..000000000 --- a/vagrant/puppet/modules/apt/templates/pin.pref.erb +++ /dev/null @@ -1,21 +0,0 @@ -<%- -@pin = "release a=#{@name}" # default value -if @pin_release.length > 0 - options = [] - options.push("a=#{@release}") if @release.length > 0 - options.push("n=#{@codename}") if @codename.length > 0 - options.push("v=#{@release_version}") if @release_version.length > 0 - options.push("c=#{@component}") if @component.length > 0 - options.push("o=#{@originator}") if @originator.length > 0 - options.push("l=#{@label}") if @label.length > 0 - @pin = "release #{options.join(', ')}" -elsif @version.length > 0 - @pin = "version #{@version}" -elsif @origin.length > 0 - @pin = "origin #{@origin}" -end --%> -Explanation: <%= @_explanation %> -Package: <%= @packages_string %> -Pin: <%= @pin %> -Pin-Priority: <%= @priority %> diff --git a/vagrant/puppet/modules/apt/templates/proxy.erb b/vagrant/puppet/modules/apt/templates/proxy.erb deleted file mode 100644 index 670e3a7e8..000000000 --- a/vagrant/puppet/modules/apt/templates/proxy.erb +++ /dev/null @@ -1,4 +0,0 @@ -Acquire::http::proxy "http://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; -<%- if @_proxy['https'] %> -Acquire::https::proxy "https://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; -<%- end -%> diff --git a/vagrant/puppet/modules/apt/templates/source.list.erb b/vagrant/puppet/modules/apt/templates/source.list.erb deleted file mode 100644 index 84cd2cf72..000000000 --- a/vagrant/puppet/modules/apt/templates/source.list.erb +++ /dev/null @@ -1,9 +0,0 @@ -# <%= @comment %> -<%- if @_include['deb'] then -%> -deb <%- if @architecture or @_allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %> -<%- end -%> -<%- if @_include['src'] then -%> -deb-src <%- if @architecture or @_allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %> -<%- end -%> diff --git a/vagrant/puppet/modules/concat/CHANGELOG.md b/vagrant/puppet/modules/concat/CHANGELOG.md deleted file mode 100644 index 3987cf6d0..000000000 --- a/vagrant/puppet/modules/concat/CHANGELOG.md +++ /dev/null @@ -1,325 +0,0 @@ -##Supported Release 2.2.0 -###Summary - -This release includes support for Debian 8 and Ubuntu 16.04 in addition to numerous bugfixes. - -####Features -- Adds Debian 8 support -- Adds Ubuntu 16.04 support - -####Bugfixes -- Fixes the stdlib lower dependency. -- (MODULES-3027) Fixes escaping the '*' character in tag creation. -- (MODULES-3097) Fixes fragment sorting by alpha -- Correctly propagates 'validate_cmd' parameter to generated file resource -- Correctly escapes disallowed characters in fragment tag creation -- (MODULES-3332) Correct the target path validation -- (MODULES-3463) Properly passes metaparams to generated resource - -##Supported Release 2.1.0 -###Summary - -This is a re-release of concat as a resource type. This release also includes new features and bugfixes on top of the previously YANKED 2.0.1 release. - -####Features -- Adds the show_diff property. -- Adds the selinux related file params. -- Allows integer UID/GID values to be passed into `$owner` and `$group` - -####Bugfixes -- Adds a workaround to PUP-1963: generated resources never receiving dependency edges. -- Fixes occassional failure to find directory environment. - -##Supported Release 1.2.5 -###Summary - -Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. - -##2015-07-21 - Supported Release 1.2.4 -###Summary - -This release includes some ruby path and lint fixes. - -####Bugfixes -- Use correct ruby path with PE and AIO -- Lint fixes -- Use correct ruby path on FreeBSD -- Test fixes - -##2015-06-02 - Supported Release 2.0.1 [YANKED] -###Summary - -This is a bugfix release. - -####Bugfixes -- Fixes dependency graphing with concurrent modification of the same file. -- Fixes handling fragment target. -- Fixes the defaulted force behavior to handle empty concats correctly. - -##2015-06-02 - Supported Release 1.2.3 -###Summary - -This release includes a README fix to document correct behavior of fragment target parameter. - -####Bugfixes -- README Fix to correctly document how a fragment $target param should work. - -##2015-05-12 - Supported Release 2.0.0 [YANKED] -###Summary - -This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments. - -####Features -- Re-implementation of concat to use native Type and Providers. - -####Bugfixes -- Fixes a bug in alpha ordering of fragments. - -##2015-05-12 - Supported Release 1.2.2 -###Summary - -This release includes a bugfix. - -####Bugfixes -- Fixes a bug introduced by MODULES-1700, in handling default retrieval of fragment backup parameter. - -##2015-04-14 - Supported Release 1.2.1 -###Summary - -This release includes bugfixes, test improvements, and a rewritten README. - -####Bugfixes - -- Verifies existence of $is_pe before using it. -- Adds validation for $order param to not allow restricted characters. -- Sets the group id on Fragments for versions of Facter that contain the $gid fact. -- Sets the script group to 0 if the script is owned by root. -- Explicitly sets script and concat directories to the same owner and group. -- Re-adds support for fragment backup, so that static compiler can work with filebucket (MODULES-1700). - -##2015-02-17 - Supported Release 1.2.0 -###Summary - -This release includes a number of bugfixes and adds support for running a validation command when using puppet >= 3.5.0. - -####Features -- Support running a validation command for Puppet >= 3.5.0 - -####Bugfixes -- Reset poisoned defaults from Exec -- Use concatfragments.rb on AIX since it doesn't support print0 -- Make sure ruby is in the path for PE (MODULES-1456) -- Fix missing method for check_is_owned_by for windows (MODULES-1764) -- Fix sort by numeric - -##2014-10-28 - Supported Release 1.1.2 -###Summary - -This release includes bugfixes and test improvements. The module was tested against SLES10 and SLES12 and found to work against those platforms with no module improvements. Metadata was updated to include those as supported platforms. - -####Bugfixes -- newline didn't work for Windows and Solaris. This has been fixed. -- Install certs on Windows for acceptance tests -- Update tests to work with strict variables (no module updates were required) -- Update tests to work on Windows -- Fix typo in CHANGELOG.md - -##2014-09-10 - Supported Release 1.1.1 -###Summary - -This is a bugfix release, and the first supported release of the 1.1.x series. - -####Bugfixes -- Make the `$order` parameter default to a string and be validated as an integer - or a string -- Use the ruby script on Solaris to not break Sol10 support -- Add quotes to the ruby script location for Windows -- Fix typos in README.md -- Make regex in concat::setup case-insensitive to make it work on Windows -- Make sure concat fragments are always replaced -- Fix validation to allow `$backup` to be a boolean -- Remove dependency on stdlib 4.x -- Fix for lack of idempotency with `ensure => 'absent'` -- Fix tests and spec_helper -- Synchronized files for more consistency across modules via modulesync - -##2014-05-14 - Release 1.1.0 -###Summary - -This release is primarily a bugfix release since 1.1.0-rc1. - -####Features -- Improved testing, with tests moved to beaker - -####Bugfixes -- No longer attempts to set fragment owner and mode on Windows -- Fix numeric sorting -- Fix incorrect quoting -- Fix newlines - -##2014-01-03 - Release 1.1.0-rc1 -###Summary - -This release of concat was 90% written by Joshua Hoblitt, and the module team -would like to thank him for the huge amount of work he put into this release. - -This module deprecates a bunch of old parameters and usage patterns, modernizes -much of the manifest code, simplifies a whole bunch of logic and makes -improvements to almost all parts of the module. - -The other major feature is windows support, courtesy of luisfdez, with an -alternative version of the concat bash script in ruby. We've attempted to -ensure that there are no backwards incompatible changes, all users of 1.0.0 -should be able to use 1.1.0 without any failures, but you may find deprecation -warnings and we'll be aggressively moving for a 2.0 to remove those too. - -For further information on deprecations, please read: -https://github.com/puppetlabs/puppetlabs-concat/blob/master/README.md#api-deprecations - -####Removed -- Puppet 0.24 support. -- Filebucket backup of all file resources except the target concatenated file. -- Default owner/user/group values. -- Purging of long unused /usr/local/bin/concatfragments.sh - -###Features -- Windows support via a ruby version of the concat bash script. -- Huge amount of acceptance testing work added. -- Documentation (README) completely rewritten. -- New parameters in concat: - - `ensure`: Controls if the file should be present/absent at all. - - Remove requirement to include concat::setup in manifests. - - Made `gnu` parameter deprecated. - - Added parameter validation. - -###Bugfixes - - Ensure concat::setup runs before concat::fragment in all cases. - - Pluginsync references updated for modern Puppet. - - Fix incorrect group parameter. - - Use $owner instead of $id to avoid confusion with $::id - - Compatibility fixes for Puppet 2.7/ruby 1.8.7 - - Use LC_ALL=C instead of LANG=C - - Always exec the concatfragments script as root when running as root. - - Syntax and other cleanup changes. - -##2014-06-25 - Supported Release 1.0.4 -###Summary - -This release has test fixes. - -####Features -- Added test support for OSX. - -####Bugfixes - -####Known bugs - -* Not supported on Windows. - -##2014-06-04 - Release 1.0.3 -###Summary - -This release adds compatibility for PE3.3 and fixes tests. - -####Features -- Added test support for Ubuntu Trusty. - -####Bugfixes - -####Known bugs - -*Not supported on Windows. - -##2014-03-04 - Supported Release 1.0.2 -###Summary - -This is a supported release. No functional changes were made from 1.0.1. - -####Features -- Huge amount of tests backported from 1.1. -- Documentation rewrite. - -####Bugfixes - -####Known Bugs - -* Not supported on Windows. - - -##2014-02-12 - 1.0.1 -###Summary - -Minor bugfixes for sorting of fragments and ordering of resources. - -####Bugfixes -- LANG => C replaced with LC_ALL => C to reduce spurious recreation of -fragments. -- Corrected pluginsync documentation. -- Ensure concat::setup always runs before fragments. - - -##2013-08-09 - 1.0.0 -###Summary - -Many new features and bugfixes in this release, and if you're a heavy concat -user you should test carefully before upgrading. The features should all be -backwards compatible but only light testing has been done from our side before -this release. - -####Features -- New parameters in concat: - - `replace`: specify if concat should replace existing files. - - `ensure_newline`: controls if fragments should contain a newline at the end. -- Improved README documentation. -- Add rspec:system tests (rake spec:system to test concat) - -####Bugfixes -- Gracefully handle \n in a fragment resource name. -- Adding more helpful message for 'pluginsync = true' -- Allow passing `source` and `content` directly to file resource, rather than -defining resource defaults. -- Added -r flag to read so that filenames with \ will be read correctly. -- sort always uses LANG=C. -- Allow WARNMSG to contain/start with '#'. -- Replace while-read pattern with for-do in order to support Solaris. - -####CHANGELOG: -- 2010/02/19 - initial release -- 2010/03/12 - add support for 0.24.8 and newer - - make the location of sort configurable - - add the ability to add shell comment based warnings to - top of files - - add the ablity to create empty files -- 2010/04/05 - fix parsing of WARN and change code style to match rest - of the code - - Better and safer boolean handling for warn and force - - Don't use hard coded paths in the shell script, set PATH - top of the script - - Use file{} to copy the result and make all fragments owned - by root. This means we can chnage the ownership/group of the - resulting file at any time. - - You can specify ensure => "/some/other/file" in concat::fragment - to include the contents of a symlink into the final file. -- 2010/04/16 - Add more cleaning of the fragment name - removing / from the $name -- 2010/05/22 - Improve documentation and show the use of ensure => -- 2010/07/14 - Add support for setting the filebucket behavior of files -- 2010/10/04 - Make the warning message configurable -- 2010/12/03 - Add flags to make concat work better on Solaris - thanks Jonathan Boyett -- 2011/02/03 - Make the shell script more portable and add a config option for root group -- 2011/06/21 - Make base dir root readable only for security -- 2011/06/23 - Set base directory using a fact instead of hardcoding it -- 2011/06/23 - Support operating as non privileged user -- 2011/06/23 - Support dash instead of bash or sh -- 2011/07/11 - Better solaris support -- 2011/12/05 - Use fully qualified variables -- 2011/12/13 - Improve Nexenta support -- 2012/04/11 - Do not use any GNU specific extensions in the shell script -- 2012/03/24 - Comply to community style guides -- 2012/05/23 - Better errors when basedir isnt set -- 2012/05/31 - Add spec tests -- 2012/07/11 - Include concat::setup in concat improving UX -- 2012/08/14 - Puppet Lint improvements -- 2012/08/30 - The target path can be different from the $name -- 2012/08/30 - More Puppet Lint cleanup -- 2012/09/04 - RELEASE 0.2.0 -- 2012/12/12 - Added (file) $replace parameter to concat diff --git a/vagrant/puppet/modules/concat/CONTRIBUTING.md b/vagrant/puppet/modules/concat/CONTRIBUTING.md deleted file mode 100644 index bfeaa701c..000000000 --- a/vagrant/puppet/modules/concat/CONTRIBUTING.md +++ /dev/null @@ -1,220 +0,0 @@ -Checklist (and a short version for the impatient) -================================================= - - * Commits: - - - Make commits of logical units. - - - Check for unnecessary whitespace with "git diff --check" before - committing. - - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). - - - Do not check in commented out code or unneeded files. - - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. - - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". - - - The body should provide a meaningful commit message, which: - - - uses the imperative, present tense: "change", not "changed" or - "changes". - - - includes motivation for the change, and contrasts its - implementation with the previous behavior. - - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. - - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - - - When introducing a new feature, make sure it is properly - documented in the README.md - - * Submission: - - * Pre-requisites: - - - Make sure you have a [GitHub account](https://github.com/join) - - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. - - * Preferred method: - - - Fork the repository on GitHub. - - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). - - - Submit a pull request to the repository in the puppetlabs - organization. - -The long version -================ - - 1. Make separate commits for logically separate changes. - - Please break your commits down into logically consistent units - which include new or changed tests relevant to the rest of the - change. The goal of doing this is to make the diff easier to - read for whoever is reviewing your code. In general, the easier - your diff is to read, the more likely someone will be happy to - review it and get it into the code base. - - If you are going to refactor a piece of code, please do so as a - separate commit from your feature or bug fix changes. - - We also really appreciate changes that include tests to make - sure the bug is not re-introduced, and that the feature is not - accidentally broken. - - Describe the technical detail of the change(s). If your - description starts to get too long, that is a good sign that you - probably need to split up your commit into more finely grained - pieces. - - Commits which plainly describe the things which help - reviewers check the patch and future developers understand the - code are much more likely to be merged in with a minimum of - bike-shedding or requested changes. Ideally, the commit message - would include information, and be in a form suitable for - inclusion in the release notes for the version of Puppet that - includes them. - - Please also check that you are not introducing any trailing - whitespace or other "whitespace errors". You can do this by - running "git diff --check" on your changes before you commit. - - 2. Sending your patches - - To submit your changes via a GitHub pull request, we _highly_ - recommend that you have them on a topic branch, instead of - directly on "master". - It makes things much easier to keep track of, especially if - you decide to work on another thing before your first change - is merged in. - - GitHub has some pretty good - [general documentation](http://help.github.com/) on using - their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). - - In general, after pushing your topic branch up to your - repository on GitHub, you can switch to the branch in the - GitHub UI and click "Pull Request" towards the top of the page - in order to open a pull request. - - - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you - submitted, then you should update the ticket to include the - location of your branch, along with any other commentary you - may wish to make. - -Testing -======= - -Getting Started ---------------- - -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, -or Gems, are required to build, develop, and test this software. - -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running - -```shell -% bundle install -Fetching gem metadata from https://rubygems.org/........ -Fetching gem metadata from https://rubygems.org/.. -Using rake (10.1.0) -Using builder (3.2.2) --- 8><-- many more --><8 -- -Using rspec-system-puppet (2.2.0) -Using serverspec (0.6.3) -Using rspec-system-serverspec (1.0.0) -Using bundler (1.3.5) -Your bundle is complete! -Use `bundle show [gemname]` to see where a bundled gem is installed. -``` - -NOTE some systems may require you to run this command with sudo. - -If you already have those gems installed, make sure they are up-to-date: - -```shell -% bundle update -``` - -With all dependencies in place and up-to-date we can now run the tests: - -```shell -% bundle exec rake spec -``` - -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), -rspec tests define them in [.fixtures.yml](./fixtures.yml). - -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. - -You can run them by issuing the following command - -```shell -% bundle exec rake spec_clean -% bundle exec rspec spec/acceptance -``` - -This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) -and then run all the tests under [spec/acceptance](./spec/acceptance). - -Writing Tests -------------- - -XXX getting started writing tests. - -If you have commit access to the repository -=========================================== - -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. - -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. - - -Additional Resources -==================== - -* [Getting additional help](http://puppetlabs.com/community/get-help) - -* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) - -* [Patchwork](https://patchwork.puppetlabs.com) - -* [General GitHub documentation](http://help.github.com/) - -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - diff --git a/vagrant/puppet/modules/concat/Gemfile b/vagrant/puppet/modules/concat/Gemfile deleted file mode 100644 index e490bc9b9..000000000 --- a/vagrant/puppet/modules/concat/Gemfile +++ /dev/null @@ -1,39 +0,0 @@ -#This file is generated by ModuleSync, do not edit. - -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -def location_for(place, version = nil) - if place =~ /^(git[:@][^#]*)#(.*)/ - [version, { :git => $1, :branch => $2, :require => false}].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false}] - else - [place, version, { :require => false}].compact - end -end - -group :development, :unit_tests do - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'puppet_facts', :require => false - gem 'puppet-blacksmith', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '>= 2.3.2', :require => false - gem 'simplecov', :require => false -end -group :system_tests do - gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') - gem 'beaker', *location_for(ENV['BEAKER_VERSION']) - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'master_manipulator', :require => false - gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) -end - -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) - - -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end diff --git a/vagrant/puppet/modules/concat/LICENSE b/vagrant/puppet/modules/concat/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vagrant/puppet/modules/concat/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vagrant/puppet/modules/concat/NOTICE b/vagrant/puppet/modules/concat/NOTICE deleted file mode 100644 index f50e9ecfd..000000000 --- a/vagrant/puppet/modules/concat/NOTICE +++ /dev/null @@ -1,20 +0,0 @@ -concat puppet module - -Copyright (C) 2015-2016 Puppet Labs Inc -Copyright 2012 R.I.Pienaar - -Puppet Labs can be contacted at: info@puppetlabs.com - - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vagrant/puppet/modules/concat/README.md b/vagrant/puppet/modules/concat/README.md deleted file mode 100644 index 9da77af13..000000000 --- a/vagrant/puppet/modules/concat/README.md +++ /dev/null @@ -1,360 +0,0 @@ -#concat - -####Table of Contents - -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with concat](#setup) - * [What concat affects](#what-concat-affects) - * [Beginning with concat](#beginning-with-concat) -4. [Usage - Configuration options and additional functionality](#usage) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Defines](#defines) - * [Parameters](#parameters) - * [Removed functionality](#removed-functionality) -6. [Limitations - OS compatibility, etc.](#limitations) -7. [Development - Guide for contributing to the module](#development) - -##Overview - -The concat module lets you construct files from multiple ordered fragments of text. - -##Module Description - -The concat module lets you gather `concat::fragment` resources from your other modules and order them into a coherent file through a single `concat` resource. - -###Beginning with concat - -To start using concat you need to create: - -* A concat{} resource for the final file. -* One or more concat::fragment{}s. - -A minimal example might be: - -~~~ -concat { '/tmp/file': - ensure => present, -} - -concat::fragment { 'tmpfile': - target => '/tmp/file', - content => 'test contents', - order => '01' -} -~~~ - -##Usage - -###Maintain a list of the major modules on a node - -To maintain an motd file that lists the modules on one of your nodes, first create a class to frame up the file: - -~~~ -class motd { - $motd = '/etc/motd' - - concat { $motd: - owner => 'root', - group => 'root', - mode => '0644' - } - - concat::fragment{ 'motd_header': - target => $motd, - content => "\nPuppet modules on this server:\n\n", - order => '01' - } - - # let local users add to the motd by creating a file called - # /etc/motd.local - concat::fragment{ 'motd_local': - target => $motd, - source => '/etc/motd.local', - order => '15' - } -} - -# let other modules register themselves in the motd -define motd::register($content="", $order='10') { - if $content == "" { - $body = $name - } else { - $body = $content - } - - concat::fragment{ "motd_fragment_$name": - target => '/etc/motd', - order => $order, - content => " -- $body\n" - } -} -~~~ - -Then, in the declarations for each module on the node, add `motd::register{ 'Apache': }` to register the module in the motd. - -~~~ -class apache { - include apache::install, apache::config, apache::service - - motd::register{ 'Apache': } -} -~~~ - -These two steps populate the /etc/motd file with a list of the installed and registered modules, which stays updated even if you just remove the registered modules' `include` lines. System administrators can append text to the list by writing to /etc/motd.local. - -When you're finished, the motd file will look something like this: - -~~~ - Puppet modules on this server: - - -- Apache - -- MySQL - - -~~~ - -##Reference - -###Defines -* `concat`: Manages a file, compiled from one or more text fragments. -* `concat::fragment`: Manages a fragment of text to be compiled into a file. - -###Types -* `concat_file`: Generates a file with content from fragments sharing a common unique tag. -* `concat_fragment`: Manages the fragment. - -###Parameters - -####Define: `concat` - -All the parameters listed below are optional. - -#####`backup` - -Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'. - -#####`backup_fragments` - -Specifies whether to backup concat fragments using the backup setting of the target concat file. Valid options: 'true' and 'false'. Default value: 'false'. - -#####`ensure` - -Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'. - -#####`ensure_newline` - -Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: 'true' and 'false'. Default value: 'false'. - -#####`force` - -Deprecated as of concat v2.0.0. Has no effect. - -#####`group` - -Specifies a permissions group for the destination file. Valid options: a string containing a group name. Default value: undefined. - -#####`mode` - -Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. Default value: '0644'. - -#####`order` - -Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). Default value: 'alpha'. - -You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations. - -#####`owner` - -Specifies the owner of the destination file. Valid options: a string containing a username. Default value: undefined. - -#####`path` - -Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the title of your declared resource. - -#####`replace` - -Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'. - -#####`show_diff` - -Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure reporting methods. Valid options: 'true'. - -#####`validate_cmd` - -Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined. - -#####`warn` - -Specifies whether to add a header message at the top of the destination file. Valid options: the booleans 'true' and 'false', or a string to serve as the header. Default value: 'false'. - -If you set 'warn' to 'true', `concat` adds the following line with an `order` of `0`: - -~~~ -# This file is managed by Puppet. DO NOT EDIT. -~~~ - -Before 2.0.0, this parameter would add a newline at the end of the warn -message. To improve flexibilty, this was removed. Please add it explicitly if -you need it. - -#####`selinux_ignore_defaults` - -See the `file` type's -[`selinux_ignore_defaults`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults) -documentention. - -#####`selrange` - -See the `file` type's -[`selrange`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange) -documentention. - -#####`selrole` - -See the `file` type's -[`selrole`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole) -documentention. - -#####`seltype` - -See the `file` type's -[`seltype`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype) -documentention. - -#####`seluser` - -See the `file` type's -[`seluser`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser) -documentention. - - -####Define: `concat::fragment` - -Except where noted, all the below parameters are optional. - -#####`content` - -Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. Default value: undef. - -#####`ensure` - -Deprecated as of concat v2.0.0. Has no effect. - -#####`order` - -Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. Default value: '10'. - -#####`source` - -Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. Default value: undefined. - -#####`target` - -*Required.* Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent `concat` resource. - - -####Type: `concat_file` - -#####`backup` - -Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'. - -#####`ensure` - -Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'. - -#####`ensure_newline` - -Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: 'true' and 'false'. Default value: 'false'. - -#####`group` - -Specifies a permissions group for the destination file. Valid options: a string containing a group name. Default value: undefined. - -#####`mode` - -Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. Default value: '0644'. - -#####`order` - -Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). Default value: 'numeric'. - -You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations. - -#####`owner` - -Specifies the owner of the destination file. Valid options: a string containing a username. Default value: undefined. - -#####`path` - -Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the title of your declared resource. - -#####`replace` - -Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'. - -####`tag` - -*Required.* Specifies a unique tag reference to collect all concat_fragments with the same tag. - -#####`validate_cmd` - -Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined. - -####Type: `concat_fragment` - -#####`content` - -Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. Default value: undef. - -#####`order` - -Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. Default value: '10'. - -#####`source` - -Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. Default value: undefined. - -#####`tag` - -*Required.* Specifies a unique tag to be used by concat_file to reference and collect content. - -#####`target` - -*Required.* Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent `concat_file` resource. - -###Removed functionality - -The following functionality existed in previous versions of the concat module, but was removed in version 2.0.0: - -Parameters removed from `concat::fragment`: -* `gnu` -* `backup` -* `group` -* `mode` -* `owner` - -The `concat::setup` class has also been removed. - -Prior to concat version 2.0.0, if you set the `warn` parameter to a string value of 'true', 'false', 'yes', 'no', 'on', or 'off', the module translated the string to the corresponding boolean value. In concat version 2.0.0 and newer, the `warn_header` parameter treats those values the same as other strings and uses them as the content of your header message. To avoid that, pass the 'true' and 'false' values as booleans instead of strings. - -##Limitations - -This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified. - -##Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) - -###Contributors - -Richard Pijnenburg ([@Richardp82](http://twitter.com/richardp82)) - -Joshua Hoblitt ([@jhoblitt](http://twitter.com/jhoblitt)) - -[More contributors.](https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors) diff --git a/vagrant/puppet/modules/concat/Rakefile b/vagrant/puppet/modules/concat/Rakefile deleted file mode 100644 index 3b07e4dae..000000000 --- a/vagrant/puppet/modules/concat/Rakefile +++ /dev/null @@ -1,42 +0,0 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppetlabs_spec_helper/rake_tasks' - -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_char_check') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "bundle/**/*", "vendor/**/*"] - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end - - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end - - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) - end - puts nodeset -end diff --git a/vagrant/puppet/modules/concat/checksums.json b/vagrant/puppet/modules/concat/checksums.json deleted file mode 100644 index 9c9e23b87..000000000 --- a/vagrant/puppet/modules/concat/checksums.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "CHANGELOG.md": "b9ce04eb47c1ff9e7a6dc727de739461", - "CONTRIBUTING.md": "ad65d271f183b5adb9fdd58207939f5f", - "Gemfile": "a5493d10f1c1fec87972b13a9fe1afcf", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "NOTICE": "65b87a92e6b572d1a5d20945457ed113", - "README.md": "66071ae9c3f1f866e16e991fd117a107", - "Rakefile": "e7793b5ea262b991f1b11dc378302475", - "lib/puppet/type/concat_file.rb": "238aaff4f2f93d3604b396040dec665c", - "lib/puppet/type/concat_fragment.rb": "3a54716cef8d0a066415b7c4ec7c24a0", - "manifests/fragment.pp": "7fc35ce1c8476f9cc8cb8313a7264697", - "manifests/init.pp": "fe7be4f3cfccd7ea9c0658b099ee0bb0", - "metadata.json": "d8d57c501fb8b2bf9aee19269281b52c", - "spec/acceptance/backup_spec.rb": "242ce4dce1efba5efb21850b9bb2a342", - "spec/acceptance/concat_spec.rb": "80fdb7d63a419b6bb9f9f42bc217171e", - "spec/acceptance/concurrency_spec.rb": "53984b19ec3a34d7084d7796f98f6857", - "spec/acceptance/fragment_source_spec.rb": "85deac6d359ffffd363c0e96bab173b3", - "spec/acceptance/fragments_are_always_replaced_spec.rb": "be39ed9ed30e7bb48aaccda2d7f730ac", - "spec/acceptance/newline_spec.rb": "5aaf65972c4f8ed4fd1592cd863583f5", - "spec/acceptance/nodesets/centos-7-x64.yml": "349128a7cfa9a953fb9af67cad52442a", - "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", - "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808", - "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", - "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", - "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/acceptance/order_spec.rb": "14e739dc02b4a4b48c5ed4d2c9bf1d17", - "spec/acceptance/pup-1963_spec.rb": "71e8a59d674f7a1dafeeba87438a0ca9", - "spec/acceptance/quoted_paths_spec.rb": "9cce52e33e894f10847b986f1d6e56d2", - "spec/acceptance/replace_spec.rb": "f0c42c610e53fc9739581d99a3cd94b0", - "spec/acceptance/specinfra_stubs.rb": "27839261403d8bbccf506552f9d8ef38", - "spec/acceptance/symbolic_name_spec.rb": "b40452adbfebb0ea9d56547d9daee700", - "spec/acceptance/validation_spec.rb": "e54226b10f46cfa9e89e57398eddbbd2", - "spec/acceptance/warn_header_spec.rb": "269e9329646674ec6975c34e0c58e8c1", - "spec/acceptance/warnings_spec.rb": "99fd93c1df5bdf952b37bd8926ad4868", - "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "c1b41c181bd36836658643af1d2a9b2e", - "spec/unit/defines/concat_fragment_spec.rb": "881141d791fe2b19e9c3d52b03def839", - "spec/unit/defines/concat_spec.rb": "c1e998f706ac3840a6f1278caed344fa", - "tests/fragment.pp": "01096a870ef7d1a1425999745f64cc2d", - "tests/init.pp": "356477e6c25394550886bf1c1edb72a4" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/concat/lib/puppet/type/concat_file.rb b/vagrant/puppet/modules/concat/lib/puppet/type/concat_file.rb deleted file mode 100644 index d1c0c9c5f..000000000 --- a/vagrant/puppet/modules/concat/lib/puppet/type/concat_file.rb +++ /dev/null @@ -1,217 +0,0 @@ -require 'puppet/type/file/owner' -require 'puppet/type/file/group' -require 'puppet/type/file/mode' -require 'puppet/util/checksums' - -Puppet::Type.newtype(:concat_file) do - @doc = "Gets all the file fragments and puts these into the target file. - This will mostly be used with exported resources. - - example: - Concat_fragment <<| tag == 'unique_tag' |>> - - concat_file { '/tmp/file': - tag => 'unique_tag', # Mandatory - path => '/tmp/file', # Optional. If given it overrides the resource name - owner => 'root', # Optional. Default to undef - group => 'root', # Optional. Default to undef - mode => '0644' # Optional. Default to undef - order => 'numeric' # Optional, Default to 'numeric' - ensure_newline => false # Optional, Defaults to false - } - " - ensurable do - defaultvalues - - defaultto { :present } - end - - def exists? - self[:ensure] == :present - end - - newparam(:name, :namevar => true) do - desc "Resource name" - end - - newparam(:tag) do - desc "Tag reference to collect all concat_fragment's with the same tag" - end - - newparam(:path) do - desc "The output file" - defaultto do - resource.value(:name) - end - end - - newparam(:owner, :parent => Puppet::Type::File::Owner) do - desc "Desired file owner." - end - - newparam(:group, :parent => Puppet::Type::File::Group) do - desc "Desired file group." - end - - newparam(:mode, :parent => Puppet::Type::File::Mode) do - desc "Desired file mode." - end - - newparam(:order) do - desc "Controls the ordering of fragments. Can be set to alphabetical or numeric." - defaultto 'numeric' - end - - newparam(:backup) do - desc "Controls the filebucketing behavior of the final file and see File type reference for its use." - defaultto 'puppet' - end - - newparam(:replace) do - desc "Whether to replace a file that already exists on the local system." - defaultto true - end - - newparam(:validate_cmd) do - desc "Validates file." - end - - newparam(:ensure_newline) do - desc "Whether to ensure there is a newline after each fragment." - defaultto false - end - - # Inherit File parameters - newparam(:selinux_ignore_defaults) do - end - - newparam(:selrange) do - end - - newparam(:selrole) do - end - - newparam(:seltype) do - end - - newparam(:seluser) do - end - - newparam(:show_diff) do - end - # End file parameters - - autorequire(:concat_fragment) do - catalog.resources.collect do |r| - if r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag] - r.name - end - end.compact - end - - # Autorequire the file we are generating below - autorequire(:file) do - [self[:path]] - end - - def should_content - return @generated_content if @generated_content - @generated_content = "" - content_fragments = [] - - resources = catalog.resources.select do |r| - r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag] - end - - resources.each do |r| - content_fragments << ["#{r[:order]}___#{r[:name]}", fragment_content(r)] - end - - if self[:order] == 'numeric' - sorted = content_fragments.sort do |a, b| - def decompound(d) - d.split('___').map { |v| v =~ /^\d+$/ ? v.to_i : v } - end - - decompound(a[0]) <=> decompound(b[0]) - end - else - sorted = content_fragments.sort_by do |a| - a_order, a_name = a[0].split('__') - [a_order, a_name] - end - end - - @generated_content = sorted.map { |cf| cf[1] }.join - - @generated_content - end - - def fragment_content(r) - if r[:content].nil? == false - fragment_content = r[:content] - elsif r[:source].nil? == false - @source = nil - Array(r[:source]).each do |source| - if Puppet::FileServing::Metadata.indirection.find(source) - @source = source - break - end - end - self.fail "Could not retrieve source(s) #{r[:source].join(", ")}" unless @source - tmp = Puppet::FileServing::Content.indirection.find(@source) - fragment_content = tmp.content unless tmp.nil? - end - - if self[:ensure_newline] - fragment_content<<"\n" unless fragment_content =~ /\n$/ - end - - fragment_content - end - - def generate - file_opts = { - :ensure => self[:ensure] == :absent ? :absent : :file, - } - - [:path, - :owner, - :group, - :mode, - :replace, - :backup, - :selinux_ignore_defaults, - :selrange, - :selrole, - :seltype, - :seluser, - :validate_cmd, - :show_diff].each do |param| - unless self[param].nil? - file_opts[param] = self[param] - end - end - - metaparams = Puppet::Type.metaparams - excluded_metaparams = [ :before, :notify, :require, :subscribe, :tag ] - - metaparams.reject! { |param| excluded_metaparams.include? param } - - metaparams.each do |metaparam| - file_opts[metaparam] = self[metaparam] if self[metaparam] - end - - [Puppet::Type.type(:file).new(file_opts)] - end - - def eval_generate - content = should_content - - if !content.nil? and !content.empty? - catalog.resource("File[#{self[:path]}]")[:content] = content - end - - [ catalog.resource("File[#{self[:path]}]") ] - end -end diff --git a/vagrant/puppet/modules/concat/lib/puppet/type/concat_fragment.rb b/vagrant/puppet/modules/concat/lib/puppet/type/concat_fragment.rb deleted file mode 100644 index 6bbef8b6b..000000000 --- a/vagrant/puppet/modules/concat/lib/puppet/type/concat_fragment.rb +++ /dev/null @@ -1,64 +0,0 @@ -Puppet::Type.newtype(:concat_fragment) do - @doc = "Create a concat fragment to be used by concat. - the `concat_fragment` type creates a file fragment to be collected by concat based on the tag. - The example is based on exported resources. - - Example: - @@concat_fragment { \"uniqe_name_${::fqdn}\": - tag => 'unique_name', - order => 10, # Optional. Default to 10 - content => 'some content' # OR - content => template('template.erb') # OR - source => 'puppet:///path/to/file' - } - " - - newparam(:name, :namevar => true) do - desc "Unique name" - end - - newparam(:target) do - desc "Target" - end - - newparam(:content) do - desc "Content" - end - - newparam(:source) do - desc "Source" - end - - newparam(:order) do - desc "Order" - defaultto '10' - validate do |val| - fail Puppet::ParseError, '$order is not a string or integer.' if !(val.is_a? String or val.is_a? Integer) - fail Puppet::ParseError, "Order cannot contain '/', ':', or '\n'." if val.to_s =~ /[:\n\/]/ - end - end - - newparam(:tag) do - desc "Tag name to be used by concat to collect all concat_fragments by tag name" - end - - autorequire(:file) do - if catalog.resources.select {|x| x.class == Puppet::Type::Concat_file and (x[:path] == self[:target] || x[:name] == self[:target]) }.empty? - warning "Target Concat_file with path of #{self[:target]} not found in the catalog" - end - end - - validate do - # Check if target is set - fail Puppet::ParseError, "Target not set" if self[:target].nil? - - # Check if tag is set - fail Puppet::ParseError, "Tag not set" if self[:tag].nil? - - # Check if either source or content is set. raise error if none is set - fail Puppet::ParseError, "Set either 'source' or 'content'" if self[:source].nil? && self[:content].nil? - - # Check if both are set, if so rais error - fail Puppet::ParseError, "Can't use 'source' and 'content' at the same time" if !self[:source].nil? && !self[:content].nil? - end -end diff --git a/vagrant/puppet/modules/concat/manifests/fragment.pp b/vagrant/puppet/modules/concat/manifests/fragment.pp deleted file mode 100644 index 0c6319a6a..000000000 --- a/vagrant/puppet/modules/concat/manifests/fragment.pp +++ /dev/null @@ -1,56 +0,0 @@ -# == Define: concat::fragment -# -# Creates a concat_fragment in the catalogue -# -# === Options: -# -# [*target*] -# The file that these fragments belong to -# [*content*] -# If present puts the content into the file -# [*source*] -# If content was not specified, use the source -# [*order*] -# By default all files gets a 10_ prefix in the directory you can set it to -# anything else using this to influence the order of the content in the file -# -define concat::fragment( - $target, - $ensure = undef, - $content = undef, - $source = undef, - $order = '10', -) { - validate_string($target) - - if $ensure != undef { - warning('The $ensure parameter to concat::fragment is deprecated and has no effect.') - } - - validate_string($content) - if !(is_string($source) or is_array($source)) { - fail('$source is not a string or an Array.') - } - - if !(is_string($order) or is_integer($order)) { - fail('$order is not a string or integer.') - } elsif (is_string($order) and $order =~ /[:\n\/]/) { - fail("Order cannot contain '/', ':', or '\n'.") - } - - if ! ($content or $source) { - crit('No content, source or symlink specified') - } elsif ($content and $source) { - fail("Can't use 'source' and 'content' at the same time") - } - - $safe_target_name = regsubst($target, '[/:~\n\s\+\*\(\)]', '_', 'GM') - - concat_fragment { $name: - target => $target, - tag => $safe_target_name, - order => $order, - content => $content, - source => $source, - } -} diff --git a/vagrant/puppet/modules/concat/manifests/init.pp b/vagrant/puppet/modules/concat/manifests/init.pp deleted file mode 100644 index 9a1ec5259..000000000 --- a/vagrant/puppet/modules/concat/manifests/init.pp +++ /dev/null @@ -1,158 +0,0 @@ -# == Define: concat -# -# Sets up so that you can use fragments to build a final config file, -# -# === Options: -# -# [*ensure*] -# Present/Absent -# [*path*] -# The path to the final file. Use this in case you want to differentiate -# between the name of a resource and the file path. Note: Use the name you -# provided in the target of your fragments. -# [*owner*] -# Who will own the file -# [*group*] -# Who will own the file -# [*mode*] -# The mode of the final file -# [*show_diff*] -# Use metaparam for files to show/hide diffs for reporting when using eyaml -# secrets. Defaults to true -# [*warn*] -# Adds a normal shell style comment top of the file indicating that it is -# built by puppet. -# Before 2.0.0, this parameter would add a newline at the end of the warn -# message. To improve flexibilty, this was removed. Please add it explicitely -# if you need it. -# [*backup*] -# Controls the filebucketing behavior of the final file and see File type -# reference for its use. Defaults to 'puppet' -# [*replace*] -# Whether to replace a file that already exists on the local system -# [*order*] -# Select whether to order associated fragments by 'alpha' or 'numeric'. -# Defaults to 'alpha'. -# [*ensure_newline*] -# Specifies whether to ensure there's a new line at the end of each fragment. -# Valid options: 'true' and 'false'. Default value: 'false'. -# [*selinux_ignore_defaults*] -# [*selrange*] -# [*selrole*] -# [*seltype*] -# [*validate_cmd*] -# Specifies a validation command to apply to the destination file. -# Requires Puppet version 3.5 or newer. Valid options: a string to be passed -# to a file resource. Default value: undefined. -# - -define concat( - $ensure = 'present', - $path = $name, - $owner = undef, - $group = undef, - $mode = '0644', - $warn = false, - $force = undef, - $show_diff = true, - $backup = 'puppet', - $replace = true, - $order = 'alpha', - $ensure_newline = false, - $validate_cmd = undef, - $selinux_ignore_defaults = undef, - $selrange = undef, - $selrole = undef, - $seltype = undef, - $seluser = undef -) { - validate_re($ensure, '^present$|^absent$') - validate_absolute_path($path) - validate_string($mode) - if ! (is_string($owner) or is_integer($owner)) { - fail("\$owner must be a string or integer, got ${owner}") - } - if ! (is_string($group) or is_integer($group)) { - fail("\$group must be a string or integer, got ${group}") - } - if ! (is_string($warn) or $warn == true or $warn == false) { - fail('$warn is not a string or boolean') - } - validate_bool($show_diff) - if ! is_bool($backup) and ! is_string($backup) { - fail('$backup must be string or bool!') - } - validate_bool($replace) - validate_re($order, '^alpha$|^numeric$') - validate_bool($ensure_newline) - - if $validate_cmd and ! is_string($validate_cmd) { - fail('$validate_cmd must be a string') - } - - if $force != undef { - warning('The $force parameter to concat is deprecated and has no effect.') - } - if $selinux_ignore_defaults { - validate_bool($selinux_ignore_defaults) - } - validate_string($selrange) - validate_string($selrole) - validate_string($seltype) - validate_string($seluser) - - $safe_name = regsubst($name, '[/:~\n\s\+\*\(\)]', '_', 'G') - $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n" - - case $warn { - true: { - $warn_message = $default_warn_message - $_append_header = true - } - false: { - $warn_message = '' - $_append_header = false - } - default: { - $warn_message = $warn - $_append_header = true - } - } - - if $ensure == 'present' { - concat_file { $name: - tag => $safe_name, - path => $path, - owner => $owner, - group => $group, - mode => $mode, - selinux_ignore_defaults => $selinux_ignore_defaults, - selrange => $selrange, - selrole => $selrole, - seltype => $seltype, - seluser => $seluser, - replace => $replace, - backup => $backup, - show_diff => $show_diff, - order => $order, - ensure_newline => $ensure_newline, - validate_cmd => $validate_cmd, - } - - if $_append_header { - concat_fragment { "${name}_header": - target => $name, - tag => $safe_name, - content => $warn_message, - order => '0', - } - } - } else { - concat_file { $name: - ensure => $ensure, - tag => $safe_name, - path => $path, - backup => $backup, - } - } -} diff --git a/vagrant/puppet/modules/concat/metadata.json b/vagrant/puppet/modules/concat/metadata.json deleted file mode 100644 index be3b1c6ed..000000000 --- a/vagrant/puppet/modules/concat/metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "name": "puppetlabs-concat", - "version": "2.2.0", - "author": "Puppet Labs", - "summary": "Construct files from multiple fragments.", - "license": "Apache-2.0", - "source": "https://github.com/puppetlabs/puppetlabs-concat", - "project_page": "https://github.com/puppetlabs/puppetlabs-concat", - "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.2.0 < 5.0.0"} - ], - "data_provider": null, - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "10 SP4", - "11 SP1", - "12" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04", - "16.04" - ] - }, - { - "operatingsystem": "Solaris", - "operatingsystemrelease": [ - "10", - "11" - ] - }, - { - "operatingsystem": "Windows", - "operatingsystemrelease": [ - "Server 2003 R2", - "Server 2008 R2", - "Server 2012", - "Server 2012 R2" - ] - }, - { - "operatingsystem": "AIX", - "operatingsystemrelease": [ - "5.3", - "6.1", - "7.1" - ] - }, - { - "operatingsystem": "OSX", - "operatingsystemrelease": [ - "10.9" - ] - } - ], - "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.7.0 < 2015.4.0" - }, - { - "name": "puppet", - "version_requirement": ">= 3.0.0 < 5.0.0" - } - ] -} diff --git a/vagrant/puppet/modules/concat/spec/acceptance/backup_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/backup_spec.rb deleted file mode 100644 index 0a737a556..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/backup_spec.rb +++ /dev/null @@ -1,115 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat backup parameter' do - basedir = default.tmpdir('concat') - context '=> puppet' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - backup => 'puppet', - } - concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', - } - EOS - - it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) - end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } - end - end - - context '=> .backup' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - backup => '.backup', - } - concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', - } - EOS - - # XXX Puppet doesn't mention anything about filebucketing with a given - # extension like .backup - it 'applies the manifest twice no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } - end - describe file("#{basedir}/file.backup") do - it { should be_file } - its(:content) { should match /old contents/ } - end - end - - # XXX The backup parameter uses validate_string() and thus can't be the - # boolean false value, but the string 'false' has the same effect in Puppet 3 - context "=> 'false'" do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - backup => '.backup', - } - concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', - } - EOS - - it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to_not match(/Filebucketed/) - end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/concat_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/concat_spec.rb deleted file mode 100644 index 3e24a583c..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/concat_spec.rb +++ /dev/null @@ -1,228 +0,0 @@ -require 'spec_helper_acceptance' - -case fact('osfamily') - when 'AIX' - username = 'root' - groupname = 'system' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - when 'Darwin' - username = 'root' - groupname = 'wheel' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - when 'windows' - username = 'Administrator' - groupname = 'Administrators' - scriptname = 'concatfragments.rb' - result = on default, "echo #{default.puppet['vardir']}" - vardir = result.raw_output.chomp - when 'Solaris' - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - else - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end -end - -describe 'basic concat test' do - basedir = default.tmpdir('concat') - safe_basedir = basedir.gsub(/[\/:]/, '_') - - shared_examples 'successfully_applied' do |pp| - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - end - - context 'owner/group root' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - order => '02', - } - EOS - - it_behaves_like 'successfully_applied', pp - - describe file("#{basedir}/file") do - it { should be_file } - it { should be_owned_by username } - it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { - should match '1' - should match '2' - } - end - end - - context 'ensure' do - context 'works when set to present with path set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" - concat { 'file': - ensure => present, - path => '#{basedir}/file', - mode => '0644', - } - concat::fragment { '1': - target => 'file', - content => '1', - order => '01', - } - " - - it_behaves_like 'successfully_applied', pp - - describe file("#{basedir}/file") do - it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { should match '1' } - end - end - context 'works when set to absent with path set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" - concat { 'file': - ensure => absent, - path => '#{basedir}/file', - mode => '0644', - } - concat::fragment { '1': - target => 'file', - content => '1', - order => '01', - } - " - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should_not be_file } - end - end - context 'works when set to present with path that has special characters' do - filename = fact('osfamily') == 'windows' ? 'file(1)' : 'file(1:2)' - - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" - concat { '#{filename}': - ensure => present, - path => '#{basedir}/#{filename}', - mode => '0644', - } - concat::fragment { '1': - target => '#{filename}', - content => '1', - order => '01', - } - " - - it_behaves_like 'successfully_applied', pp - - describe file("#{basedir}/#{filename}") do - it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { should match '1' } - end - end - context 'noop properly' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" - concat { 'file': - ensure => present, - path => '#{basedir}/file', - mode => '0644', - noop => true, - } - concat::fragment { '1': - target => 'file', - content => '1', - order => '01', - } - " - - it_behaves_like 'successfully_applied', pp - - describe file("#{basedir}/file") do - it { should_not be_file } - end - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/concurrency_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/concurrency_spec.rb deleted file mode 100644 index fcffdbd10..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/concurrency_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'with file recursive purge' do - basedir = default.tmpdir('concat') - context 'should still create concat file' do - pp = <<-EOS - file { '#{basedir}/bar': - ensure => directory, - purge => true, - recurse => true, - } - - concat { "foobar": - ensure => 'present', - path => '#{basedir}/bar/foobar', - } - - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/bar/foobar") do - it { should be_file } - its(:content) { - should match 'foo' - } - end - end -end - diff --git a/vagrant/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb deleted file mode 100644 index b208979ac..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb +++ /dev/null @@ -1,156 +0,0 @@ -require 'spec_helper_acceptance' - -case fact('osfamily') - when 'AIX' - username = 'root' - groupname = 'system' - when 'Darwin' - username = 'root' - groupname = 'wheel' - when 'windows' - username = 'Administrator' - groupname = 'Administrators' - else - username = 'root' - groupname = 'root' -end - -describe 'concat::fragment source' do - basedir = default.tmpdir('concat') - context 'should read file fragments from local system' do - pp = <<-EOS - file { '#{basedir}/file1': - content => "file1 contents\n" - } - file { '#{basedir}/file2': - content => "file2 contents\n" - } - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - source => '#{basedir}/file1', - require => File['#{basedir}/file1'], - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string1 contents', - } - concat::fragment { '3': - target => '#{basedir}/foo', - source => '#{basedir}/file2', - require => File['#{basedir}/file2'], - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should match 'string1 contents' - should match 'file2 contents' - } - end - end # should read file fragments from local system - - context 'should create files containing first match only.' do - pp = <<-EOS - file { '#{basedir}/file1': - content => "file1 contents\n" - } - file { '#{basedir}/file2': - content => "file2 contents\n" - } - concat { '#{basedir}/result_file1': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - concat { '#{basedir}/result_file2': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - concat { '#{basedir}/result_file3': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - - concat::fragment { '1': - target => '#{basedir}/result_file1', - source => [ '#{basedir}/file1', '#{basedir}/file2' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - concat::fragment { '2': - target => '#{basedir}/result_file2', - source => [ '#{basedir}/file2', '#{basedir}/file1' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - concat::fragment { '3': - target => '#{basedir}/result_file3', - source => [ '#{basedir}/file1', '#{basedir}/file2' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - describe file("#{basedir}/result_file1") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should_not match 'file2 contents' - } - end - describe file("#{basedir}/result_file2") do - it { should be_file } - its(:content) { - should match 'file2 contents' - should_not match 'file1 contents' - } - end - describe file("#{basedir}/result_file3") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should_not match 'file2 contents' - } - end - end - - context 'should fail if no match on source.' do - pp = <<-EOS - concat { '#{basedir}/fail_no_source': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - - concat::fragment { '1': - target => '#{basedir}/fail_no_source', - source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ], - order => '01', - } - EOS - - it 'applies the manifest with resource failures' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/Failed to generate additional resources using 'eval_generate'/) - end - describe file("#{basedir}/fail_no_source") do - #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. - it { should_not be_directory } - end - end -end - diff --git a/vagrant/puppet/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb deleted file mode 100644 index 70d738288..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat::fragment replace' do - basedir = default.tmpdir('concat') - - context 'should create fragment files' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - pp1 = <<-EOS - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace unset run 1', - } - EOS - pp2 = <<-EOS - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace unset run 2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace unset run 1' - should match 'caller has replace unset run 2' - } - end - end # should create fragment files - - context 'should replace its own fragment files when caller has File { replace=>true } set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - pp1 = <<-EOS - File { replace=>true } - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace true set run 1', - } - EOS - pp2 = <<-EOS - File { replace=>true } - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace true set run 2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace true set run 1' - should match 'caller has replace true set run 2' - } - end - end # should replace its own fragment files when caller has File(replace=>true) set - - context 'should replace its own fragment files even when caller has File { replace=>false } set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - pp1 = <<-EOS - File { replace=>false } - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace false set run 1', - } - EOS - pp2 = <<-EOS - File { replace=>false } - concat { '#{basedir}/foo': } - - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'caller has replace false set run 2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace false set run 1' - should match 'caller has replace false set run 2' - } - end - end # should replace its own fragment files even when caller has File(replace=>false) set - -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/newline_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/newline_spec.rb deleted file mode 100644 index c1fa16a10..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/newline_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat ensure_newline parameter' do - basedir = default.tmpdir('concat') - context '=> false' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory - } - EOS - - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - ensure_newline => false, - } - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match '12' } - end - end - - context '=> true' do - pp = <<-EOS - concat { '#{basedir}/file': - ensure_newline => true, - } - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /1\n2\n/ - } - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/centos-7-x64.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/centos-7-x64.yml deleted file mode 100644 index 1a40c8950..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/centos-7-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-7-x64: - roles: - - agent - - default - platform: redhat-7-x86_64 - hypervisor: vagrant - box: puppetlabs/centos-7.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/debian-8-x64.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/debian-8-x64.yml deleted file mode 100644 index fef6e63ca..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/debian-8-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - debian-8-x64: - roles: - - agent - - default - platform: debian-8-amd64 - hypervisor: vagrant - box: puppetlabs/debian-8.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/default.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/default.yml deleted file mode 100644 index dba339c46..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - roles: - - agent - - default - platform: ubuntu-14.04-amd64 - hypervisor: vagrant - box: puppetlabs/ubuntu-14.04-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/centos-7.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/centos-7.yml deleted file mode 100644 index a3333aac5..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/centos-7.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' - # install various tools required to get the image up to usable levels - docker_image_commands: - - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/debian-8.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/debian-8.yml deleted file mode 100644 index df5c31944..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/debian-8.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/ubuntu-14.04.yml deleted file mode 100644 index b1efa5839..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - # ensure that upstart is booting correctly in the container - - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/concat/spec/acceptance/order_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/order_spec.rb deleted file mode 100644 index b746b1c9c..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/order_spec.rb +++ /dev/null @@ -1,123 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat order' do - basedir = default.tmpdir('concat') - - context '=> ' do - shared_examples 'sortby' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' - } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - order => '1', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - order => '2', - } - concat::fragment { '10': - target => '#{basedir}/foo', - content => 'string10', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end - end - - describe 'alpha' do - it_behaves_like 'sortby', 'alpha', /string1string10string2/ - end - - describe 'numeric' do - it_behaves_like 'sortby', 'numeric', /string1string2string10/ - end - end -end # concat order - -describe 'concat::fragment order' do - basedir = default.tmpdir('concat') - - context '=> reverse order' do - shared_examples 'order_by' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' - } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - order => '15', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - # default order 10 - } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', - order => '1', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end - end - describe 'alpha' do - it_should_behave_like 'order_by', 'alpha', /string3string2string1/ - end - describe 'numeric' do - it_should_behave_like 'order_by', 'numeric', /string3string2string1/ - end - end - - context '=> normal order' do - pp = <<-EOS - concat { '#{basedir}/foo': } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - order => '01', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - order => '02' - } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', - order => '03', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match /string1string2string3/ } - end - end -end # concat::fragment order diff --git a/vagrant/puppet/modules/concat/spec/acceptance/pup-1963_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/pup-1963_spec.rb deleted file mode 100644 index c36fe41cd..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/pup-1963_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper_acceptance' - -case fact('osfamily') - when 'Windows' - command = 'cmd.exe /c echo triggered' - else - command = 'echo triggered' -end - -describe 'with metaparameters' do - describe 'with subscribed resources' do - basedir = default.tmpdir('concat') - - context 'should trigger refresh' do - pp = <<-EOS - concat { "foobar": - ensure => 'present', - path => '#{basedir}/foobar', - } - - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - - exec { 'trigger': - path => $::path, - command => "#{command}", - subscribe => Concat['foobar'], - refreshonly => true, - } - EOS - - it 'applies the manifest twice with stdout regex' do - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/Triggered 'refresh'/) - expect(apply_manifest(pp, :catch_changes => true).stdout).to_not match(/Triggered 'refresh'/) - end - end - end - - describe 'with resources to notify' do - basedir = default.tmpdir('concat') - context 'should notify' do - pp = <<-EOS - exec { 'trigger': - path => $::path, - command => "#{command}", - refreshonly => true, - } - - concat { "foobar": - ensure => 'present', - path => '#{basedir}/foobar', - notify => Exec['trigger'], - } - - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - EOS - - it 'applies the manifest twice with stdout regex' do - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/Triggered 'refresh'/) - expect(apply_manifest(pp, :catch_changes => true).stdout).to_not match(/Triggered 'refresh'/) - end - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb deleted file mode 100644 index 6f9f9fd5f..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'quoted paths' do - basedir = default.tmpdir('concat') - - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/concat test': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - context 'path with blanks' do - pp = <<-EOS - concat { '#{basedir}/concat test/foo': - } - concat::fragment { '1': - target => '#{basedir}/concat test/foo', - content => 'string1', - } - concat::fragment { '2': - target => '#{basedir}/concat test/foo', - content => 'string2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/concat test/foo") do - it { should be_file } - its(:content) { should match /string1string2/ } - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/replace_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/replace_spec.rb deleted file mode 100644 index 68d7383fe..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/replace_spec.rb +++ /dev/null @@ -1,261 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'replacement of' do - basedir = default.tmpdir('concat') - context 'file' do - context 'should not succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "file exists\n" - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - replace => false, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match 'file exists' - should_not match '1' - should_not match '2' - } - end - end - - context 'should succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "file exists\n" - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - replace => true, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should_not match 'file exists' - should match '1' - should match '2' - } - end - end - end # file - - context 'symlink', :unless => (fact("osfamily") == "windows") do - context 'should not succeed' do - # XXX the core puppet file type will replace a symlink with a plain file - # when using ensure => present and source => ... but it will not when using - # ensure => present and content => ...; this is somewhat confusing behavior - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => link, - target => '#{basedir}/dangling', - } - EOS - apply_manifest(pp) - end - - pp = <<-EOS - concat { '#{basedir}/file': - replace => false, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - # XXX specinfra doesn't support be_linked_to on AIX - describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do - it { should be_linked_to "#{basedir}/dangling" } - end - - describe file("#{basedir}/dangling") do - # XXX serverspec does not have a matcher for 'exists' - it { should_not be_file } - it { should_not be_directory } - end - end - - context 'should succeed' do - # XXX the core puppet file type will replace a symlink with a plain file - # when using ensure => present and source => ... but it will not when using - # ensure => present and content => ...; this is somewhat confusing behavior - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => link, - target => '#{basedir}/dangling', - } - EOS - apply_manifest(pp) - end - - pp = <<-EOS - concat { '#{basedir}/file': - replace => true, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match '1' - should match '2' - } - end - end - end # symlink - - context 'directory' do - context 'should not succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with stderr for changing to file' do - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) - end - - describe file("#{basedir}/file") do - it { should be_directory } - end - end - - # XXX - # when there are no fragments, and the replace param will only replace - # files and symlinks, not directories. The semantics either need to be - # changed, extended, or a new param introduced to control directory - # replacement. - context 'should succeed', :pending => 'not yet implemented' do - pp = <<-EOS - concat { '#{basedir}/file': - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match '1' } - end - end - end # directory -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/specinfra_stubs.rb b/vagrant/puppet/modules/concat/spec/acceptance/specinfra_stubs.rb deleted file mode 100644 index bae85eff0..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/specinfra_stubs.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Base - class << self - def check_is_owned_by(file, owner) - Backend::PowerShell::Command.new do - exec "if((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}' - -or ((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0){ exit 0 } else { exit 1 }" - end - end - end -end - - -class Specinfra::Command::Base::File < Specinfra::Command::Base - class << self - def get_content(file) - "cat '#{file}' 2> /dev/null || echo -n" - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb deleted file mode 100644 index df8d54f52..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'symbolic name' do - basedir = default.tmpdir('concat') - pp = <<-EOS - concat { 'not_abs_path': - path => '#{basedir}/file', - } - - concat::fragment { '1': - target => 'not_abs_path', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => 'not_abs_path', - content => '2', - order => '02', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match '1' - should match '2' - } - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/validation_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/validation_spec.rb deleted file mode 100644 index c35871b9b..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/validation_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat validate_cmd parameter', :unless => (fact('kernel') != 'Linux') do - basedir = default.tmpdir('concat') - context '=> "/usr/bin/test -e %"' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory - } - EOS - - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - validate_cmd => '/usr/bin/test -e %', - } - concat::fragment { 'content': - target => '#{basedir}/file', - content => 'content', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - it { should contain 'content' } - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/warn_header_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/warn_header_spec.rb deleted file mode 100644 index b73414e34..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/warn_header_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat warn =>' do - basedir = default.tmpdir('concat') - context 'true should enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': - warn => true, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - order => '02', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context 'false should not enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': - warn => false, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - order => '02', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should_not match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context '# foo should overide default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': - warn => "# foo\n", - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - order => '02', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# foo/ - should match /1/ - should match /2/ - } - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/acceptance/warnings_spec.rb b/vagrant/puppet/modules/concat/spec/acceptance/warnings_spec.rb deleted file mode 100644 index 4ad7a9763..000000000 --- a/vagrant/puppet/modules/concat/spec/acceptance/warnings_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'warnings' do - basedir = default.tmpdir('concat') - - shared_examples 'has_warning' do |pp, w| - it 'applies the manifest twice with a stderr regex' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) - expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) - end - end - - context 'concat force parameter deprecation' do - pp = <<-EOS - concat { '#{basedir}/file': - force => false, - } - concat::fragment { 'foo': - target => '#{basedir}/file', - content => 'bar', - } - EOS - w = 'The $force parameter to concat is deprecated and has no effect.' - - it_behaves_like 'has_warning', pp, w - end - - context 'concat::fragment ensure parameter deprecation' do - context 'target file exists' do - pp = <<-EOS - concat { '#{basedir}/file': - } - concat::fragment { 'foo': - target => '#{basedir}/file', - ensure => false, - content => 'bar', - } - EOS - w = 'The $ensure parameter to concat::fragment is deprecated and has no effect.' - - it_behaves_like 'has_warning', pp, w - end - end - - context 'concat::fragment target not found' do - context 'target not found' do - pp = <<-EOS - concat { 'file': - path => '#{basedir}/file', - } - concat::fragment { 'foo': - target => '#{basedir}/bar', - content => 'bar', - } - EOS - w = 'not found in the catalog' - - it_behaves_like 'has_warning', pp, w - end - end -end diff --git a/vagrant/puppet/modules/concat/spec/spec.opts b/vagrant/puppet/modules/concat/spec/spec.opts deleted file mode 100644 index 91cd6427e..000000000 --- a/vagrant/puppet/modules/concat/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/vagrant/puppet/modules/concat/spec/spec_helper.rb b/vagrant/puppet/modules/concat/spec/spec_helper.rb deleted file mode 100644 index 22d5d689f..000000000 --- a/vagrant/puppet/modules/concat/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -#This file is generated by ModuleSync, do not edit. -require 'puppetlabs_spec_helper/module_spec_helper' - -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError -end diff --git a/vagrant/puppet/modules/concat/spec/spec_helper_acceptance.rb b/vagrant/puppet/modules/concat/spec/spec_helper_acceptance.rb deleted file mode 100644 index d0b05ea2d..000000000 --- a/vagrant/puppet/modules/concat/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' -require 'acceptance/specinfra_stubs' -require 'beaker/puppet_install_helper' - -run_puppet_install_helper - -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - hosts.each do |host| - if host['platform'] =~ /sles-1/i || host['platform'] =~ /solaris-1/i - get_deps = <<-EOS - package{'wget':} - exec{'download-stdlib': - command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz --no-check-certificate", - path => ['/opt/csw/bin/','/usr/bin/'] - } - EOS - apply_manifest_on(host, get_deps) - # have to use force otherwise it checks ssl cert even though it is a local file - on host, puppet('module install /root/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} - elsif host['platform'] =~ /windows/i - on host, 'curl -k -o c:/puppetlabs-stdlib-4.5.1.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz' - on host, puppet('module install c:/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} - else - on host, puppet('module install puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} - end - end -end - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - hosts.each do |host| - copy_module_to(host, :source => proj_root, :module_name => 'concat') - end - end - - c.before(:all) do - shell('mkdir -p /tmp/concat') - end - c.after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - end - - c.treat_symbols_as_metadata_keys_with_true_values = true -end - diff --git a/vagrant/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb b/vagrant/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb deleted file mode 100644 index a2d4c6c80..000000000 --- a/vagrant/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'spec_helper' - -describe 'concat::fragment', :type => :define do - - shared_examples 'fragment' do |title, params| - params = {} if params.nil? - - p = { - :content => nil, - :source => nil, - :order => 10, - }.merge(params) - - id = 'root' - gid = 'root' - - let(:title) { title } - let(:params) { params } - let(:pre_condition) do - "concat{ '#{p[:target]}': }" - end - - it do - should contain_concat(p[:target]) - should contain_concat_file(p[:target]) - should contain_concat_fragment(title) - end - end - - context 'title' do - ['0', '1', 'a', 'z'].each do |title| - it_behaves_like 'fragment', title, { - :target => '/etc/motd', - :content => "content for #{title}" - } - end - end # title - - context 'target =>' do - ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| - context target do - it_behaves_like 'fragment', target, { - :target => '/etc/motd', - :content => "content for #{target}" - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :target => false }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # target => - - context 'content =>' do - ['', 'ashp is our hero'].each do |content| - context content do - it_behaves_like 'fragment', 'motd_header', { - :content => content, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :content => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # content => - - context 'source =>' do - ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source| - context source do - it_behaves_like 'fragment', 'motd_header', { - :source => source, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :source => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/) - end - end - end # source => - - context 'order =>' do - ['', '42', 'a', 'z'].each do |order| - context '\'\'' do - it_behaves_like 'fragment', 'motd_header', { - :order => order, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :order => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string or integer/) - end - end - - context '123:456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => '123:456', :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - context '123/456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => '123/456', :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - context '123\n456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => "123\n456", :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - end # order => - - context 'more than one content source' do - context 'source and content' do - let(:title) { 'motd_header' } - let(:params) do - { - :target => '/etc/motd', - :source => '/foo', - :content => 'bar', - } - end - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m) - end - end - end # more than one content source -end diff --git a/vagrant/puppet/modules/concat/spec/unit/defines/concat_spec.rb b/vagrant/puppet/modules/concat/spec/unit/defines/concat_spec.rb deleted file mode 100644 index b0840d0a3..000000000 --- a/vagrant/puppet/modules/concat/spec/unit/defines/concat_spec.rb +++ /dev/null @@ -1,362 +0,0 @@ -require 'spec_helper' - -describe 'concat', :type => :define do - - shared_examples 'concat' do |title, params, id| - params = {} if params.nil? - id = 'root' if id.nil? - - # default param values - p = { - :ensure => 'present', - :path => title, - :owner => nil, - :group => nil, - :mode => '0644', - :warn => false, - :backup => 'puppet', - :replace => true, - }.merge(params) - - concat_name = 'fragments.concat.out' - default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n" - - file_defaults = { - :backup => p[:backup], - } - - let(:title) { title } - let(:params) { params } - let(:facts) do - { - :id => id, - :osfamily => 'Debian', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :kernel => 'Linux', - :is_pe => false, - } - end - - if p[:ensure] == 'present' - it do - should contain_concat(title).with(file_defaults.merge({ - :ensure => 'present', - :owner => p[:owner], - :group => p[:group], - :mode => p[:mode], - :path => p[:path], - :backup => p[:backup], - :replace => p[:replace], - :selinux_ignore_defaults => p[:selinux_ignore_defaults], - :selrange => p[:selrange], - :selrole => p[:selrole], - :seltype => p[:seltype], - :seluser => p[:seluser], - })) - end - else - it do - should contain_concat(title).with(file_defaults.merge({ - :ensure => 'absent', - :backup => p[:backup], - })) - end - end - end - - context 'title' do - context 'without path param' do - # title/name is the default value for the path param. therefore, the - # title must be an absolute path unless path is specified - ['/foo', '/foo/bar', '/foo/bar/baz'].each do |title| - context title do - it_behaves_like 'concat', '/etc/foo.bar' - end - end - - ['./foo', 'foo', 'foo/bar'].each do |title| - context title do - let(:title) { title } - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/) - end - end - end - end - - context 'with path param' do - ['/foo', 'foo', 'foo/bar'].each do |title| - context title do - it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } - end - end - end - - context 'with special characters in title' do - ['foo:bar', 'foo*bar', 'foo(bar)'].each do |title| - context title do - it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } - end - end - end - end # title => - - context 'as non-root user' do - it_behaves_like 'concat', '/etc/foo.bar', {}, 'bob' - end - - context 'ensure =>' do - ['present', 'absent'].each do |ens| - context ens do - it_behaves_like 'concat', '/etc/foo.bar', { :ensure => ens } - end - end - - context 'invalid' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :ensure => 'invalid' }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^present$|^absent$"')}/) - end - end - end # ensure => - - context 'path =>' do - context '/foo' do - it_behaves_like 'concat', '/etc/foo.bar', { :path => '/foo' } - end - - ['./foo', 'foo', 'foo/bar', false].each do |path| - context path do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :path => path }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/) - end - end - end - end # path => - - context 'owner =>' do - context 'apenney' do - it_behaves_like 'concat', '/etc/foo.bar', { :owner => 'apenny' } - end - - context '1000' do - it_behaves_like 'concat', '/etc/foo.bar', { :owner => 1000 } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :owner => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /\$owner must be a string or integer/) - end - end - end # owner => - - context 'group =>' do - context 'apenney' do - it_behaves_like 'concat', '/etc/foo.bar', { :group => 'apenny' } - end - - context '1000' do - it_behaves_like 'concat', '/etc/foo.bar', { :group => 1000 } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :group => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /\$group must be a string or integer/) - end - end - end # group => - - context 'mode =>' do - context '1755' do - it_behaves_like 'concat', '/etc/foo.bar', { :mode => '1755' } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :mode => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # mode => - - context 'warn =>' do - [true, false, '# foo'].each do |warn| - context warn do - it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } - end - end - - context '(stringified boolean)' do - ['true', 'yes', 'on', 'false', 'no', 'off'].each do |warn| - context warn do - it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } - - it 'should create a warning' do - skip('rspec-puppet support for testing warning()') - end - end - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :warn => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string or boolean/) - end - end - end # warn => - - context 'show_diff =>' do - [true, false].each do |show_diff| - context show_diff do - it_behaves_like 'concat', '/etc/foo.bar', { :show_diff => show_diff } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :show_diff => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) - end - end - end # show_diff => - - context 'backup =>' do - context 'reverse' do - it_behaves_like 'concat', '/etc/foo.bar', { :backup => 'reverse' } - end - - context 'false' do - it_behaves_like 'concat', '/etc/foo.bar', { :backup => false } - end - - context 'true' do - it_behaves_like 'concat', '/etc/foo.bar', { :backup => true } - end - - context 'true' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :backup => [] }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /backup must be string or bool/) - end - end - end # backup => - - context 'replace =>' do - [true, false].each do |replace| - context replace do - it_behaves_like 'concat', '/etc/foo.bar', { :replace => replace } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :replace => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) - end - end - end # replace => - - context 'order =>' do - ['alpha', 'numeric'].each do |order| - context order do - it_behaves_like 'concat', '/etc/foo.bar', { :order => order } - end - end - - context 'invalid' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :order => 'invalid' }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^alpha$|^numeric$"')}/) - end - end - end # order => - - context 'ensure_newline =>' do - [true, false].each do |ensure_newline| - context 'true' do - it_behaves_like 'concat', '/etc/foo.bar', { :ensure_newline => ensure_newline} - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :ensure_newline => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) - end - end - end # ensure_newline => - - context 'validate_cmd =>' do - if Puppet::Util::Package::versioncmp(Puppet::version, '3.5.0') > 0 - context '/usr/bin/test -e %' do - it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } - end - - [ 1234, true ].each do |cmd| - context cmd do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :validate_cmd => cmd }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) - end - end - end - end - end # validate_cmd => - - context 'selinux_ignore_defaults =>' do - let(:title) { '/etc/foo.bar' } - - [true, false].each do |v| - context v do - it_behaves_like 'concat', '/etc/foo.bar', { :selinux_ignore_defaults => v } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :selinux_ignore_defaults => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) - end - end - end # selinux_ignore_defaults => - - [ - :selrange, - :selrole, - :seltype, - :seluser, - ].each do |p| - context " #{p} =>" do - let(:title) { '/etc/foo.bar' } - - context 'foo' do - it_behaves_like 'concat', '/etc/foo.bar', { p => 'foo' } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ p => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # #{p} => - end -end diff --git a/vagrant/puppet/modules/concat/tests/fragment.pp b/vagrant/puppet/modules/concat/tests/fragment.pp deleted file mode 100644 index 16bf3b6e2..000000000 --- a/vagrant/puppet/modules/concat/tests/fragment.pp +++ /dev/null @@ -1,20 +0,0 @@ -concat { 'testconcat': - ensure => present, - path => '/tmp/concat', - owner => 'root', - group => 'root', - mode => '0664', - show_diff => true, -} - -concat::fragment { '1': - target => 'testconcat', - content => '1', - order => '01', -} - -concat::fragment { '2': - target => 'testconcat', - content => '2', - order => '02', -} diff --git a/vagrant/puppet/modules/concat/tests/init.pp b/vagrant/puppet/modules/concat/tests/init.pp deleted file mode 100644 index c7f193463..000000000 --- a/vagrant/puppet/modules/concat/tests/init.pp +++ /dev/null @@ -1,6 +0,0 @@ -concat { '/tmp/concat': - ensure => present, - owner => 'root', - group => 'root', - mode => '0644', -} diff --git a/vagrant/puppet/modules/epel/Gemfile b/vagrant/puppet/modules/epel/Gemfile deleted file mode 100644 index 4f4151a84..000000000 --- a/vagrant/puppet/modules/epel/Gemfile +++ /dev/null @@ -1,35 +0,0 @@ -source "https://rubygems.org" - -group :test do - gem "rake" - gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0' - gem "rspec", '< 3.2.0' - gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' - gem "puppetlabs_spec_helper" - gem "metadata-json-lint" - gem "rspec-puppet-facts" - gem 'rubocop', '0.33.0' - gem 'simplecov' - gem 'simplecov-console' - - gem "puppet-lint-absolute_classname-check" - gem "puppet-lint-leading_zero-check" - gem "puppet-lint-trailing_comma-check" - gem "puppet-lint-version_comparison-check" - gem "puppet-lint-classes_and_types_beginning_with_digits-check" - gem "puppet-lint-unquoted_string-check" -end - -group :development do - gem "travis" - gem "travis-lint" - gem "puppet-blacksmith" - gem "guard-rake" -end - -group :system_tests do - gem "beaker" - gem "beaker-rspec" - gem "beaker-puppet_install_helper" -end - diff --git a/vagrant/puppet/modules/epel/LICENSE b/vagrant/puppet/modules/epel/LICENSE deleted file mode 100644 index 009b66b6c..000000000 --- a/vagrant/puppet/modules/epel/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2012-2014 Michael Stahnke - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vagrant/puppet/modules/epel/README.md b/vagrant/puppet/modules/epel/README.md deleted file mode 100644 index 4cf670893..000000000 --- a/vagrant/puppet/modules/epel/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# Configure EPEL (Extra Repository for Enterprise Linux) - -# About -This module basically just mimics the epel-release rpm. The same repos are -enabled/disabled and the GPG key is imported. In the end you will end up with -the EPEL repos configured. - -The following Repos will be setup and enabled by default: - - * epel - -Other repositories that will setup but disabled (as per the epel-release setup) - - * epel-debuginfo - * epel-source - * epel-testing - * epel-testing-debuginfo - * epel-testing-source - -# Usage - -In nearly all cases, you can simply _include epel_ or classify your nodes with -the epel class. There are quite a few paramters available if you need to modify -the default settings for the epel repository such having your own mirror, an -http proxy, disable gpg checking. - -You can also use a puppet one-liner to get epel onto a system. - - puppet apply -e 'include epel' - -# Proxy -If you have an http proxy required to access the internet, you can use either -a class parameter in the _epel_ class, or edit the $proxy variable in the -params.pp file. By default no proxy is assumed. - -# Why? -I am a big fan of EPEL. I actually was one of the people who helped get it -going. I am also the owner of the epel-release package, so in general this -module should stay fairly up to date with the official upstream package. - -I just got sick of coding Puppet modules and basically having an assumption -that EPEL was setup or installed. I can now depend on this module instead. - -I realize it is fairly trivial to get EPEL setup. Every now-and-then however -the path to epel-release changes because something changes in the package (mass -rebuild, rpm build macros updates, etc). This module will bypass the changing -URL and just setup the package mirrors. - -This does mean that if you are looking for RPM macros that are normally -included with EPEL release, this will not have them. - -# Futher Information - -* [EPEL Wiki](http://fedoraproject.org/wiki/EPEL) -* [epel-release package information](http://mirrors.servercentral.net/fedora/epel/6/i386/repoview/epel-release.html) - -# ChangeLog - -======= - - - 1.2.2 - * Add dep on stdlib for getvar function call - - 1.2.1 - * Minor fix that lets facter 1.6 still work - * Enforce strict variables - - 1.2.0 - * Rework testing to use TravisCI - * If you specify a baseurl, disable mirrorlist - - 1.1.1 - * Ensure that GPG keys are using short IDs (issue #33) - - 1.1.0 - * Default URLs to be https - * Add ability to include/exclude packages - - 1.0.2 - * Update README with usage section. - * Fix regression when os_maj_version fact was required - * Ready for 1.0 - replace Modulefile with metadata.json - * Replace os_maj_version custom fact with operatingsystemmajrelease - * Works for EPEL7 now as well. - -# Testing - - * This is commonly used on Puppet Enterprise 3.x - * This was tested using Puppet 3.3.0 on Centos5/6 - * This was tested using Puppet 3.1.1 on Amazon's AWS Linux - * This was tested using Puppet 3.8 and Puppet 4 now as well! - * Note Ruby 2.2 and Puppet 3.8 are not yet friends. - * I assume it will work on any RHEL variant (Amazon Linux is debatable as a variant) - * Amazon Linux compatability not promised, as EPEL doesn't always work with it. - -# Lifecycle - - * No functionality has been introduced that should break Puppet 2.6 or 2.7, but I am no longer testing these versions of Puppet as they are end-of-lifed from Puppet Labs. - * This also assumes a facter of greater than 1.7.0 -- at least from a testing perspective. - * I'm not actively fixing bugs for anything in facter < 2 or puppet < 3.8 - -## Unit tests - -Install the necessary gems - - bundle install --path vendor --without system_tests - -Run the RSpec and puppet-lint tests - - bundle exec rake test - -## System tests - -If you have Vagrant >=1.1.0 you can also run system tests: - - RSPEC_SET=centos-64-x64 bundle exec rake spec:system - -Available RSPEC_SET options are in .nodeset.yml - -# License -Apache Software License 2.0 - -# Author/Contributors - * Aaron - * Chad Metcalf - * Ewoud Kohl van Wijngaarden - * Joseph Swick - * Mickaël Canévet - * Matthaus Owens - * Michael Stahnke - * Michael Stahnke - * Nick Le Mouton - * Pro Cabales - * Proletaryo Cabales - * Rob Nelson - * Robert Story - * Stefan Goethals - * Tim Rupp - * Trey Dockendorf - * Troy Bollinger - * Vlastimil Holer - -# Alternatives -If you're on CentOS 7, you can just `yum install epel-release` as it's in centos-extras. diff --git a/vagrant/puppet/modules/epel/Rakefile b/vagrant/puppet/modules/epel/Rakefile deleted file mode 100644 index 2479ec481..000000000 --- a/vagrant/puppet/modules/epel/Rakefile +++ /dev/null @@ -1,59 +0,0 @@ -require 'rubygems' -require 'bundler/setup' - -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet/version' -require 'puppet/vendor/semantic/lib/semantic' unless Puppet.version.to_f < 3.6 -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' -require 'metadata-json-lint/rake_task' -require 'rubocop/rake_task' - -# These gems aren't always present, for instance -# on Travis with --without development -begin - require 'puppet_blacksmith/rake_tasks' -rescue LoadError # rubocop:disable Lint/HandleExceptions -end - -RuboCop::RakeTask.new - -exclude_paths = [ - "bundle/**/*", - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] - -Rake::Task[:lint].clear - -PuppetLint.configuration.relative = true -PuppetLint.configuration.disable_80chars -PuppetLint.configuration.disable_class_inherits_from_params_class -PuppetLint.configuration.disable_class_parameter_defaults -PuppetLint.configuration.fail_on_warnings = true - -PuppetLint::RakeTask.new :lint do |config| - config.ignore_paths = exclude_paths -end - -PuppetSyntax.exclude_paths = exclude_paths - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc "Populate CONTRIBUTORS file" -task :contributors do - system("git log --format='%aN' | sort -u > CONTRIBUTORS") -end - -desc "Run syntax, lint, and spec tests." -task :test => [ - :metadata_lint, - :syntax, - :lint, - :rubocop, - :spec, -] diff --git a/vagrant/puppet/modules/epel/checksums.json b/vagrant/puppet/modules/epel/checksums.json deleted file mode 100644 index 3173c57c2..000000000 --- a/vagrant/puppet/modules/epel/checksums.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Gemfile": "869291f4658771f13435477eeb1a7058", - "Gemfile.lock": "afb9ac0f103ee2a0dd7f18bea393cac5", - "LICENSE": "94f0b1430ad7e59227ccabf8232f81d5", - "README.md": "cdea036cf2ccfb09063fd09c1117816e", - "Rakefile": "da9b01265a5ba19f41d723d376d5864b", - "files/RPM-GPG-KEY-EPEL-5": "0466c259781def56dafe0a2cdc9de0c5", - "files/RPM-GPG-KEY-EPEL-6": "d865e6b948a74cb03bc3401c0b01b785", - "files/RPM-GPG-KEY-EPEL-7": "58fa8ae27c89f37b08429f04fd4a88cc", - "manifests/init.pp": "d46a9aea1cc964487aa74bf7e7eb4431", - "manifests/params.pp": "8e271ea80e3eec73a350bcac809a2014", - "manifests/rpm_gpg_key.pp": "802b10226193de2fb5d8b5aebbd5d436", - "metadata.json": "03a903f192ed4619e51645637e11bbed", - "spec/classes/epel_spec.rb": "7f2fac8720e5e7fe37daa60c231e53f9", - "spec/classes/shared_base.rb": "c25da4905ce3660bafd364af02495e71", - "spec/classes/shared_debuginfo.rb": "dff797c10c17023d8c79af857cd9a301", - "spec/classes/shared_gpgkey.rb": "014db1c9505e7612f0880fd7ba1df912", - "spec/classes/shared_source.rb": "fadf9e25736b4ec6d34a37f5d1e8501c", - "spec/classes/shared_testing.rb": "81304e23484b371b0943880d843fc702", - "spec/classes/shared_testing_debuginfo.rb": "bc603db04c73cb5f4475bcb77d7adf56", - "spec/classes/shared_testing_source.rb": "9d2a6f8b0b6e73267ef1caea4ca2df6b", - "spec/defines/rpm_gpg_key_spec.rb": "c72ff01940d28df26a960eee122bf473", - "spec/spec_helper.rb": "a5ad64bd67aa3fe2512fa7ba505c8e8b", - "spec/spec_helper_system.rb": "d24a7ffdf4b67dbbd3ef5687292f51cf", - "spec/system/basic_spec.rb": "49db07e43f690ac32a841b3125939450", - "spec/system/usage_spec.rb": "68f7bd38e911009d74487c5f86b48555", - "tests/init.pp": "964d2df016bcb1c39760e8b32b6f1a0a" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 b/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 deleted file mode 100644 index 5a13bb4f9..000000000 --- a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.2.6 (GNU/Linux) - -mQGiBEXopTIRBACZDBMOoFOakAjaxw1LXjeSvh/kmE35fU1rXfM7T0AV31NATCLF -l5CQiNDA4oWreDThg2Bf6+LIVTsGQb1V+XXuLak4Em5yTYwMTVB//4/nMxQEbpl/ -QB2XwlJ7EQ0vW+kiPDz/7pHJz1p1jADzd9sQQicMtzysS4qT2i5A23j0VwCg1PB/ -lpYqo0ZhWTrevxKMa1n34FcD/REavj0hSLQFTaKNLHRotRTF8V0BajjSaTkUT4uk -/RTaZ8Kr1mTosVtosqmdIAA2XHxi8ZLiVPPSezJjfElsSqOAxEKPL0djfpp2wrTm -l/1iVnX+PZH5DRKCbjdCMLDJhYap7YUhcPsMGSeUKrwmBCBJUPc6DhjFvyhA9IMl -1T0+A/9SKTv94ToP/JYoCTHTgnG5MoVNafisfe0wojP2mWU4gRk8X4dNGKMj6lic -vM6gne3hESyjcqZSmr7yELPPGhI9MNauJ6Ob8cTR2T12Fmv9w03DD3MnBstR6vhP -QcqZKhc5SJYYY7oVfxlSOfF4xfwcHQKoD5TOKwIAQ6T8jyFpKbQkRmVkb3JhIEVQ -RUwgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iGQEExECACQFAkXopTICGwMFCRLM -AwAGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQEZzANiF1IfabmQCgzvE60MnHSOBa -ZXXF7uU2Vzu8EOkAoKg9h+j0NuNom6WUYZyJQt4zc5seuQINBEXopTYQCADapnR/ -blrJ8FhlgNPl0X9S3JE/kygPbNXIqne4XBVYisVp0uzNCRUxNZq30MpY027JCs2J -nL2fMpwvx33f0phU029vrIZKA3CmnnwVsjcWfMJOVPBmVN7m5bGU68F+PdRIcDsl -PMOWRLkTBZOGolLgIbM4719fqA8etewILrX6uPvRDwywV7/sPCFpRcfNNBUY+Zx3 -5bf4fnkaCKxgXgQS3AT+hGYhlzIqQVTkGNveHTnt4SSzgAqR9sSwQwqvEfVtYNeS -w5rDguLG41HQm1Hojv59HNYjH6F/S1rClZi21bLgZbKpCFX76qPt8CTw+iQLBPPd -yoOGHfzyp7nsfhUrAAMFB/9/H9Gpk822ZpBexQW4y3LGFo9ZSnmu+ueOZPU3SqDA -DW1ovZdYzGuJTGGM9oMl6bL8eZrcUBBOFaWge5wZczIE3hx2exEOkDdvq+MUDVD1 -axmN45q/7h1NYRp5GQL2ZsoV4g9U2gMdzHOFtZCER6PP9ErVlfJpgBUCdSL93V4H -Sgpkk7znmTOklbCM6l/G/A6q4sCRqfzHwVSTiruyTBiU9lfROsAl8fjIq2OzWJ2T -P9sadBe1llUYaow7txYSUxssW+89avct35gIyrBbof5M+CBXyAOUaSWmpM2eub24 -0qbqiSr/Y6Om0t6vSzR8gRk7g+1H6IE0Tt1IJCvCAMimiE8EGBECAA8FAkXopTYC -GwwFCRLMAwAACgkQEZzANiF1IfZQYgCgiZHCv4xb+sTHCn/otc1Ovvi/OgMAnRXY -bbsLFWOfmzAnNIGvFRWy+YHi -=MMNL ------END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 b/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 deleted file mode 100644 index 7a2030489..000000000 --- a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.5 (GNU/Linux) - -mQINBEvSKUIBEADLGnUj24ZVKW7liFN/JA5CgtzlNnKs7sBg7fVbNWryiE3URbn1 -JXvrdwHtkKyY96/ifZ1Ld3lE2gOF61bGZ2CWwJNee76Sp9Z+isP8RQXbG5jwj/4B -M9HK7phktqFVJ8VbY2jfTjcfxRvGM8YBwXF8hx0CDZURAjvf1xRSQJ7iAo58qcHn -XtxOAvQmAbR9z6Q/h/D+Y/PhoIJp1OV4VNHCbCs9M7HUVBpgC53PDcTUQuwcgeY6 -pQgo9eT1eLNSZVrJ5Bctivl1UcD6P6CIGkkeT2gNhqindRPngUXGXW7Qzoefe+fV -QqJSm7Tq2q9oqVZ46J964waCRItRySpuW5dxZO34WM6wsw2BP2MlACbH4l3luqtp -Xo3Bvfnk+HAFH3HcMuwdaulxv7zYKXCfNoSfgrpEfo2Ex4Im/I3WdtwME/Gbnwdq -3VJzgAxLVFhczDHwNkjmIdPAlNJ9/ixRjip4dgZtW8VcBCrNoL+LhDrIfjvnLdRu -vBHy9P3sCF7FZycaHlMWP6RiLtHnEMGcbZ8QpQHi2dReU1wyr9QgguGU+jqSXYar -1yEcsdRGasppNIZ8+Qawbm/a4doT10TEtPArhSoHlwbvqTDYjtfV92lC/2iwgO6g -YgG9XrO4V8dV39Ffm7oLFfvTbg5mv4Q/E6AWo/gkjmtxkculbyAvjFtYAQARAQAB -tCFFUEVMICg2KSA8ZXBlbEBmZWRvcmFwcm9qZWN0Lm9yZz6JAjYEEwECACAFAkvS -KUICGw8GCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRA7Sd8qBgi4lR/GD/wLGPv9 -qO39eyb9NlrwfKdUEo1tHxKdrhNz+XYrO4yVDTBZRPSuvL2yaoeSIhQOKhNPfEgT -9mdsbsgcfmoHxmGVcn+lbheWsSvcgrXuz0gLt8TGGKGGROAoLXpuUsb1HNtKEOwP -Q4z1uQ2nOz5hLRyDOV0I2LwYV8BjGIjBKUMFEUxFTsL7XOZkrAg/WbTH2PW3hrfS -WtcRA7EYonI3B80d39ffws7SmyKbS5PmZjqOPuTvV2F0tMhKIhncBwoojWZPExft -HpKhzKVh8fdDO/3P1y1Fk3Cin8UbCO9MWMFNR27fVzCANlEPljsHA+3Ez4F7uboF -p0OOEov4Yyi4BEbgqZnthTG4ub9nyiupIZ3ckPHr3nVcDUGcL6lQD/nkmNVIeLYP -x1uHPOSlWfuojAYgzRH6LL7Idg4FHHBA0to7FW8dQXFIOyNiJFAOT2j8P5+tVdq8 -wB0PDSH8yRpn4HdJ9RYquau4OkjluxOWf0uRaS//SUcCZh+1/KBEOmcvBHYRZA5J -l/nakCgxGb2paQOzqqpOcHKvlyLuzO5uybMXaipLExTGJXBlXrbbASfXa/yGYSAG -iVrGz9CE6676dMlm8F+s3XXE13QZrXmjloc6jwOljnfAkjTGXjiB7OULESed96MR -XtfLk0W5Ab9pd7tKDR6QHI7rgHXfCopRnZ2VVQ== -=V/6I ------END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 b/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 deleted file mode 100644 index f205ede46..000000000 --- a/vagrant/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.11 (GNU/Linux) - -mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB -OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm -jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP -vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM -jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4lsZ+Y2Er9Yu5 -S/8x0ly+tmmIokaE0wwbdUu740YTZjCesroYWiRg5zuQ2xfKxJoV5E+Eh+tYwGDJ -n6HfWhRgnudRRwvuJ45ztYVtKulKw8QQpd2STWrcQQDJaRWmnMooX/PATTjCBExB -9dkz38Druvk7IkHMtsIqlkAOQMdsX1d3Tov6BE2XDjIG0zFxLduJGbVwc/6rIc95 -T055j36Ez0HrjxdpTGOOHxRqMK5m9flFbaxxtDnS7w77WqzW7HjFrD0VeTx2vnjj -GqchHEQpfDpFOzb8LTFhgYidyRNUflQY35WLOzLNV+pV3eQ3Jg11UFwelSNLqfQf -uFRGc+zcwkNjHh5yPvm9odR1BIfqJ6sKGPGbtPNXo7ERMRypWyRz0zi0twARAQAB -tChGZWRvcmEgRVBFTCAoNykgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iQI4BBMB -AgAiBQJSrmiEAhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBqL66iNSxk -5cfGD/4spqpsTjtDM7qpytKLHKruZtvuWiqt5RfvT9ww9GUUFMZ4ZZGX4nUXg49q -ixDLayWR8ddG/s5kyOi3C0uX/6inzaYyRg+Bh70brqKUK14F1BrrPi29eaKfG+Gu -MFtXdBG2a7OtPmw3yuKmq9Epv6B0mP6E5KSdvSRSqJWtGcA6wRS/wDzXJENHp5re -9Ism3CYydpy0GLRA5wo4fPB5uLdUhLEUDvh2KK//fMjja3o0L+SNz8N0aDZyn5Ax -CU9RB3EHcTecFgoy5umRj99BZrebR1NO+4gBrivIfdvD4fJNfNBHXwhSH9ACGCNv -HnXVjHQF9iHWApKkRIeh8Fr2n5dtfJEF7SEX8GbX7FbsWo29kXMrVgNqHNyDnfAB -VoPubgQdtJZJkVZAkaHrMu8AytwT62Q4eNqmJI1aWbZQNI5jWYqc6RKuCK6/F99q -thFT9gJO17+yRuL6Uv2/vgzVR1RGdwVLKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc -ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4 -vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt -RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw== -=hdPa ------END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/puppet/modules/epel/manifests/init.pp b/vagrant/puppet/modules/epel/manifests/init.pp deleted file mode 100644 index 88796dda2..000000000 --- a/vagrant/puppet/modules/epel/manifests/init.pp +++ /dev/null @@ -1,174 +0,0 @@ -# Class epel -# -# Actions: -# Configure the proper repositories and import GPG keys -# -# Reqiures: -# You should probably be on an Enterprise Linux variant. (Centos, RHEL, -# Scientific, Oracle, Ascendos, et al) -# -# Sample Usage: -# include epel -# -class epel ( - $epel_mirrorlist = $epel::params::epel_mirrorlist, - $epel_baseurl = $epel::params::epel_baseurl, - $epel_failovermethod = $epel::params::epel_failovermethod, - $epel_proxy = $epel::params::epel_proxy, - $epel_enabled = $epel::params::epel_enabled, - $epel_gpgcheck = $epel::params::epel_gpgcheck, - $epel_exclude = undef, - $epel_includepkgs = undef, - $epel_testing_baseurl = $epel::params::epel_testing_baseurl, - $epel_testing_failovermethod = $epel::params::epel_testing_failovermethod, - $epel_testing_proxy = $epel::params::epel_testing_proxy, - $epel_testing_enabled = $epel::params::epel_testing_enabled, - $epel_testing_gpgcheck = $epel::params::epel_testing_gpgcheck, - $epel_testing_exclude = undef, - $epel_testing_includepkgs = undef, - $epel_source_mirrorlist = $epel::params::epel_source_mirrorlist, - $epel_source_baseurl = $epel::params::epel_source_baseurl, - $epel_source_failovermethod = $epel::params::epel_source_failovermethod, - $epel_source_proxy = $epel::params::epel_source_proxy, - $epel_source_enabled = $epel::params::epel_source_enabled, - $epel_source_gpgcheck = $epel::params::epel_source_gpgcheck, - $epel_source_exclude = undef, - $epel_source_includepkgs = undef, - $epel_debuginfo_mirrorlist = $epel::params::epel_debuginfo_mirrorlist, - $epel_debuginfo_baseurl = $epel::params::epel_debuginfo_baseurl, - $epel_debuginfo_failovermethod = $epel::params::epel_debuginfo_failovermethod, - $epel_debuginfo_proxy = $epel::params::epel_debuginfo_proxy, - $epel_debuginfo_enabled = $epel::params::epel_debuginfo_enabled, - $epel_debuginfo_gpgcheck = $epel::params::epel_debuginfo_gpgcheck, - $epel_debuginfo_exclude = undef, - $epel_debuginfo_includepkgs = undef, - $epel_testing_source_baseurl = $epel::params::epel_testing_source_baseurl, - $epel_testing_source_failovermethod = $epel::params::epel_testing_source_failovermethod, - $epel_testing_source_proxy = $epel::params::epel_testing_source_proxy, - $epel_testing_source_enabled = $epel::params::epel_testing_source_enabled, - $epel_testing_source_gpgcheck = $epel::params::epel_testing_source_gpgcheck, - $epel_testing_source_exclude = undef, - $epel_testing_source_includepkgs = undef, - $epel_testing_debuginfo_baseurl = $epel::params::epel_testing_debuginfo_baseurl, - $epel_testing_debuginfo_failovermethod = $epel::params::epel_testing_debuginfo_failovermethod, - $epel_testing_debuginfo_proxy = $epel::params::epel_testing_debuginfo_proxy, - $epel_testing_debuginfo_enabled = $epel::params::epel_testing_debuginfo_enabled, - $epel_testing_debuginfo_gpgcheck = $epel::params::epel_testing_debuginfo_gpgcheck, - $epel_testing_debuginfo_exclude = undef, - $epel_testing_debuginfo_includepkgs = undef, - $os_maj_release = $epel::params::os_maj_release, -) inherits epel::params { - - if "${::osfamily}" == 'RedHat' and "${::operatingsystem}" !~ /Fedora|Amazon/ { # lint:ignore:only_variable_string - yumrepo { 'epel-testing': - baseurl => $epel_testing_baseurl, - failovermethod => $epel_testing_failovermethod, - proxy => $epel_testing_proxy, - enabled => $epel_testing_enabled, - gpgcheck => $epel_testing_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - Testing - \$basearch ", - exclude => $epel_testing_exclude, - includepkgs => $epel_testing_includepkgs, - } - - yumrepo { 'epel-testing-debuginfo': - baseurl => $epel_testing_debuginfo_baseurl, - failovermethod => $epel_testing_debuginfo_failovermethod, - proxy => $epel_testing_debuginfo_proxy, - enabled => $epel_testing_debuginfo_enabled, - gpgcheck => $epel_testing_debuginfo_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - Testing - \$basearch - Debug", - exclude => $epel_testing_debuginfo_exclude, - includepkgs => $epel_testing_debuginfo_includepkgs, - } - - yumrepo { 'epel-testing-source': - baseurl => $epel_testing_source_baseurl, - failovermethod => $epel_testing_source_failovermethod, - proxy => $epel_testing_source_proxy, - enabled => $epel_testing_source_enabled, - gpgcheck => $epel_testing_source_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - Testing - \$basearch - Source", - exclude => $epel_testing_source_exclude, - includepkgs => $epel_testing_source_includepkgs, - } - - yumrepo { 'epel': - # lint:ignore:selector_inside_resource - mirrorlist => $epel_baseurl ? { - 'absent' => $epel_mirrorlist, - default => 'absent', - }, - # lint:endignore - baseurl => $epel_baseurl, - failovermethod => $epel_failovermethod, - proxy => $epel_proxy, - enabled => $epel_enabled, - gpgcheck => $epel_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - \$basearch", - exclude => $epel_exclude, - includepkgs => $epel_includepkgs, - } - - yumrepo { 'epel-debuginfo': - # lint:ignore:selector_inside_resource - mirrorlist => $epel_debuginfo_baseurl ? { - 'absent' => $epel_debuginfo_mirrorlist, - default => 'absent', - }, - # lint:endignore - baseurl => $epel_debuginfo_baseurl, - failovermethod => $epel_debuginfo_failovermethod, - proxy => $epel_debuginfo_proxy, - enabled => $epel_debuginfo_enabled, - gpgcheck => $epel_debuginfo_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - \$basearch - Debug", - exclude => $epel_debuginfo_exclude, - includepkgs => $epel_debuginfo_includepkgs, - } - - yumrepo { 'epel-source': - # lint:ignore:selector_inside_resource - mirrorlist => $epel_source_baseurl ? { - 'absent' => $epel_source_mirrorlist, - default => 'absent', - }, - # lint:endignore - baseurl => $epel_source_baseurl, - failovermethod => $epel_source_failovermethod, - proxy => $epel_source_proxy, - enabled => $epel_source_enabled, - gpgcheck => $epel_source_gpgcheck, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - descr => "Extra Packages for Enterprise Linux ${os_maj_release} - \$basearch - Source", - exclude => $epel_source_exclude, - includepkgs => $epel_source_includepkgs, - } - - file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}": - ensure => present, - owner => 'root', - group => 'root', - mode => '0644', - source => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-${os_maj_release}", - } - - epel::rpm_gpg_key{ "EPEL-${os_maj_release}": - path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${os_maj_release}", - before => Yumrepo['epel','epel-source','epel-debuginfo','epel-testing','epel-testing-source','epel-testing-debuginfo'], - } - - } elsif "${::osfamily}" == 'RedHat' and "${::operatingsystem}" == 'Amazon' { # lint:ignore:only_variable_string - yumrepo { 'epel': - enabled => $epel_enabled, - gpgcheck => $epel_gpgcheck, - } - } else { - notice ("Your operating system ${::operatingsystem} will not have the EPEL repository applied") - } -} diff --git a/vagrant/puppet/modules/epel/manifests/params.pp b/vagrant/puppet/modules/epel/manifests/params.pp deleted file mode 100644 index ffe6127e5..000000000 --- a/vagrant/puppet/modules/epel/manifests/params.pp +++ /dev/null @@ -1,52 +0,0 @@ -# Optional parameters in setting up EPEL -class epel::params { - # Setting to 'absent' will fall back to the yum.conf - # Setting proxy here will be the default for all repos. - # - # If you wish to set a proxy for an individual set of repos, - # you can declare $proxy in that class, and should scope to - # the most specific declaration of proxy. - $proxy = 'absent' - - if getvar('::operatingsystemmajrelease') { - $os_maj_release = $::operatingsystemmajrelease - } else { - $os_versions = split("${::operatingsystemrelease}", '[.]') # lint:ignore:only_variable_string - $os_maj_release = $os_versions[0] - } - - $epel_mirrorlist = "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-${os_maj_release}&arch=\$basearch" - $epel_baseurl = 'absent' - $epel_failovermethod = 'priority' - $epel_proxy = $proxy - $epel_enabled = '1' - $epel_gpgcheck = '1' - $epel_testing_baseurl = "https://download.fedoraproject.org/pub/epel/testing/${os_maj_release}/\$basearch" - $epel_testing_failovermethod = 'priority' - $epel_testing_proxy = $proxy - $epel_testing_enabled = '0' - $epel_testing_gpgcheck = '1' - $epel_source_mirrorlist = "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-${os_maj_release}&arch=\$basearch" - $epel_source_baseurl = 'absent' - $epel_source_failovermethod = 'priority' - $epel_source_proxy = $proxy - $epel_source_enabled = '0' - $epel_source_gpgcheck = '1' - $epel_debuginfo_mirrorlist = "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-${os_maj_release}&arch=\$basearch" - $epel_debuginfo_baseurl = 'absent' - $epel_debuginfo_failovermethod = 'priority' - $epel_debuginfo_proxy = $proxy - $epel_debuginfo_enabled = '0' - $epel_debuginfo_gpgcheck = '1' - $epel_testing_source_baseurl = "https://download.fedoraproject.org/pub/epel/testing/${os_maj_release}/SRPMS" - $epel_testing_source_failovermethod = 'priority' - $epel_testing_source_proxy = $proxy - $epel_testing_source_enabled = '0' - $epel_testing_source_gpgcheck = '1' - $epel_testing_debuginfo_baseurl = "https://download.fedoraproject.org/pub/epel/testing/${os_maj_release}/\$basearch/debug" - $epel_testing_debuginfo_failovermethod = 'priority' - $epel_testing_debuginfo_proxy = $proxy - $epel_testing_debuginfo_enabled = '0' - $epel_testing_debuginfo_gpgcheck = '1' - -} diff --git a/vagrant/puppet/modules/epel/manifests/rpm_gpg_key.pp b/vagrant/puppet/modules/epel/manifests/rpm_gpg_key.pp deleted file mode 100644 index f3ade7abf..000000000 --- a/vagrant/puppet/modules/epel/manifests/rpm_gpg_key.pp +++ /dev/null @@ -1,28 +0,0 @@ -# Define epel::rpm_gpg_key -# -# Actions: -# Import a RPM gpg key -# -# Parameters: -# -# [*path*] -# Path of the RPM GPG key to import -# -# Reqiures: -# You should probably be on an Enterprise Linux variant. (Centos, RHEL, Scientific, Oracle, Ascendos, et al) -# -# Sample Usage: -# epel::rpm_gpg_key{ "EPEL-6": -# path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" -# } -# -define epel::rpm_gpg_key($path) { - # Given the path to a key, see if it is imported, if not, import it - exec { "import-${name}": - path => '/bin:/usr/bin:/sbin:/usr/sbin', - command => "rpm --import ${path}", - unless => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids --keyid-format short < ${path}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", - require => File[$path], - logoutput => 'on_failure', - } -} diff --git a/vagrant/puppet/modules/epel/metadata.json b/vagrant/puppet/modules/epel/metadata.json deleted file mode 100644 index 328d712bb..000000000 --- a/vagrant/puppet/modules/epel/metadata.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "stahnma-epel", - "version": "1.2.2", - "author": "stahnma", - "summary": "Setup the EPEL package repo", - "license": "Apache-2.0", - "source": "http://github.com/stahnma/puppet-module-epel", - "project_page": "http://github.com/stahnma/puppet-module-epel", - "issues_url": "https://github.com/stahnma/puppet-module-epel/issues", - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OEL", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - } - ], - "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.0.0" - }, - { - "name": "puppet", - "version_requirement": ">= 3.0.0" - } - ], - "description": "Setup the EPEL package repo on Centos/RHEL et al", - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 3.0.0"} - ] -} diff --git a/vagrant/puppet/modules/epel/spec/classes/epel_spec.rb b/vagrant/puppet/modules/epel/spec/classes/epel_spec.rb deleted file mode 100644 index 0b915d13b..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/epel_spec.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'spec_helper' -require 'classes/shared_gpgkey' -require 'classes/shared_base' -require 'classes/shared_source' -require 'classes/shared_debuginfo' -require 'classes/shared_testing' -require 'classes/shared_testing_source' -require 'classes/shared_testing_debuginfo' - -describe 'epel' do - it { should create_class('epel') } - it { should contain_class('epel::params') } - - context "operatingsystem => #{default_facts[:operatingsystem]}" do - context 'operatingsystemmajrelease => 7' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '7.0.1406', - :operatingsystemmajrelease => '7', - }) - end - - it_behaves_like :base_7 - it_behaves_like :gpgkey_7 - it_behaves_like :epel_source_7 - it_behaves_like :epel_debuginfo_7 - it_behaves_like :epel_testing_7 - it_behaves_like :epel_testing_source_7 - it_behaves_like :epel_testing_debuginfo_7 - - context 'epel_baseurl => https://example.com/epel/7/x87_74' do - let(:params) {{ :epel_baseurl => "https://example.com/epel/7/x87_74" }} - it { should contain_yumrepo('epel').with('baseurl' => 'https://example.com/epel/7/x87_74') } - it { should contain_yumrepo('epel').with('mirrorlist' => 'absent') } - end - - context 'epel_mirrorlist => absent' do - let(:params) {{ :epel_mirrorlist => 'absent' }} - it { should contain_yumrepo('epel').with('mirrorlist' => 'absent') } - end - - context 'operatingsystemmajrelease undef' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '7.0.1406', - }) - end - - it_behaves_like :base_7 - it_behaves_like :gpgkey_7 - it_behaves_like :epel_source_7 - it_behaves_like :epel_debuginfo_7 - it_behaves_like :epel_testing_7 - it_behaves_like :epel_testing_source_7 - it_behaves_like :epel_testing_debuginfo_7 - end - end - - context 'operatingsystemmajrelease => 6' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '6.4', - :operatingsystemmajrelease => '6', - }) - end - - it_behaves_like :base_6 - it_behaves_like :gpgkey_6 - it_behaves_like :epel_source_6 - it_behaves_like :epel_debuginfo_6 - it_behaves_like :epel_testing_6 - it_behaves_like :epel_testing_source_6 - it_behaves_like :epel_testing_debuginfo_6 - - context 'epel_baseurl => https://example.com/epel/6/x86_64' do - let(:params) {{ :epel_baseurl => "https://example.com/epel/6/x86_64" }} - it { should contain_yumrepo('epel').with('baseurl' => 'https://example.com/epel/6/x86_64') } - it { should contain_yumrepo('epel').with('mirrorlist' => 'absent') } - end - - context 'epel_mirrorlist => absent' do - let(:params) {{ :epel_mirrorlist => 'absent' }} - it { should contain_yumrepo('epel').with('mirrorlist' => 'absent') } - end - - context 'operatingsystemmajrelease undef' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '6.4', - }) - end - - it_behaves_like :base_6 - it_behaves_like :gpgkey_6 - it_behaves_like :epel_source_6 - it_behaves_like :epel_debuginfo_6 - it_behaves_like :epel_testing_6 - it_behaves_like :epel_testing_source_6 - it_behaves_like :epel_testing_debuginfo_6 - end - end - - context 'operatingsystemmajrelease => 5' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '5.9', - :operatingsystemmajrelease => '5', - }) - end - - it_behaves_like :base_5 - it_behaves_like :gpgkey_5 - it_behaves_like :epel_source_5 - it_behaves_like :epel_debuginfo_5 - it_behaves_like :epel_testing_5 - it_behaves_like :epel_testing_source_5 - it_behaves_like :epel_testing_debuginfo_5 - end - end - - context 'operatingsystem => Amazon' do - let :facts do - default_facts.merge({ - :operatingsystem => 'Amazon', - }) - end - - it { should_not contain_yumrepo('epel-testing') } - it { should_not contain_yumrepo('epel-testing-debuginfo') } - it { should_not contain_yumrepo('epel-testing-source') } - it { should_not contain_yumrepo('epel-debuginfo') } - it { should_not contain_yumrepo('epel-source') } - - it do - should contain_yumrepo('epel').with({ - 'enabled' => '1', - 'gpgcheck' => '1', - }) - end - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_base.rb b/vagrant/puppet/modules/epel/spec/classes/shared_base.rb deleted file mode 100644 index 0882f8e88..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_base.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :base do - it do - should contain_yumrepo('epel').with({ - 'failovermethod' => 'priority', - 'proxy' => 'absent', - 'enabled' => '1', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :base_7 do - include_context :base - - it do - should contain_yumrepo('epel').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - $basearch", - }) - end -end - -shared_examples_for :base_6 do - include_context :base - - it do - should contain_yumrepo('epel').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch", - }) - end -end - -shared_examples_for :base_5 do - include_context :base - - it do - should contain_yumrepo('epel').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_debuginfo.rb b/vagrant/puppet/modules/epel/spec/classes/shared_debuginfo.rb deleted file mode 100644 index 7fb5c9c06..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_debuginfo.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :epel_debuginfo do - it do - should contain_yumrepo('epel-debuginfo').with({ - 'proxy' => 'absent', - 'failovermethod' => 'priority', - 'enabled' => '0', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :epel_debuginfo_7 do - include_context :epel_debuginfo - - it do - should contain_yumrepo('epel-debuginfo').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-7&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - $basearch - Debug", - }) - end -end - -shared_examples_for :epel_debuginfo_6 do - include_context :epel_debuginfo - - it do - should contain_yumrepo('epel-debuginfo').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-6&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch - Debug", - }) - end -end - -shared_examples_for :epel_debuginfo_5 do - include_context :epel_debuginfo - - it do - should contain_yumrepo('epel-debuginfo').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch - Debug", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_gpgkey.rb b/vagrant/puppet/modules/epel/spec/classes/shared_gpgkey.rb deleted file mode 100644 index 09945da10..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_gpgkey.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' - -shared_examples_for :gpgkey_7 do - it do - should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7").with({ - 'ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-7", - }) - end - - it do - should contain_epel__rpm_gpg_key("EPEL-7").with({ - 'path' => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7" - }) - end -end - -shared_examples_for :gpgkey_6 do - it do - should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6").with({ - 'ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-6", - }) - end - - it do - should contain_epel__rpm_gpg_key("EPEL-6").with({ - 'path' => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" - }) - end -end - -shared_examples_for :gpgkey_5 do - it do - should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5").with({ - 'ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-5", - }) - end - - it do - should contain_epel__rpm_gpg_key("EPEL-5").with({ - 'path' => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5" - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_source.rb b/vagrant/puppet/modules/epel/spec/classes/shared_source.rb deleted file mode 100644 index 2756283d2..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_source.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :epel_source do - it do - should contain_yumrepo('epel-source').with({ - 'proxy' => 'absent', - 'failovermethod' => 'priority', - 'enabled' => '0', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :epel_source_7 do - include_context :epel_source - - it do - should contain_yumrepo('epel-source').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-7&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - $basearch - Source", - }) - end -end - -shared_examples_for :epel_source_6 do - include_context :epel_source - - it do - should contain_yumrepo('epel-source').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch - Source", - }) - end -end - -shared_examples_for :epel_source_5 do - include_context :epel_source - - it do - should contain_yumrepo('epel-source').with({ - 'mirrorlist' => "https://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch - Source", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_testing.rb b/vagrant/puppet/modules/epel/spec/classes/shared_testing.rb deleted file mode 100644 index d0c6a791c..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_testing.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :epel_testing do - it do - should contain_yumrepo('epel-testing').with({ - 'failovermethod' => 'priority', - 'proxy' => 'absent', - 'enabled' => '0', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :epel_testing_7 do - include_context :epel_testing - - it do - should contain_yumrepo('epel-testing').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/7/$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - Testing - $basearch ", - }) - end -end - -shared_examples_for :epel_testing_6 do - include_context :epel_testing - - it do - should contain_yumrepo('epel-testing').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/6/$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch ", - }) - end -end - -shared_examples_for :epel_testing_5 do - include_context :epel_testing - - it do - should contain_yumrepo('epel-testing').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/5/$basearch", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch ", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb b/vagrant/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb deleted file mode 100644 index e9c4e3ef5..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :epel_testing_debuginfo do - it do - should contain_yumrepo('epel-testing-debuginfo').with({ - 'failovermethod' => 'priority', - 'proxy' => 'absent', - 'enabled' => '0', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :epel_testing_debuginfo_7 do - include_context :epel_testing_debuginfo - - it do - should contain_yumrepo('epel-testing-debuginfo').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/7/$basearch/debug", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug", - }) - end -end - -shared_examples_for :epel_testing_debuginfo_6 do - include_context :epel_testing_debuginfo - - it do - should contain_yumrepo('epel-testing-debuginfo').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/6/$basearch/debug", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch - Debug", - }) - end -end - -shared_examples_for :epel_testing_debuginfo_5 do - include_context :epel_testing_debuginfo - - it do - should contain_yumrepo('epel-testing-debuginfo').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/5/$basearch/debug", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch - Debug", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/classes/shared_testing_source.rb b/vagrant/puppet/modules/epel/spec/classes/shared_testing_source.rb deleted file mode 100644 index 5b8bbc917..000000000 --- a/vagrant/puppet/modules/epel/spec/classes/shared_testing_source.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -shared_context :epel_testing_source do - it do - should contain_yumrepo('epel-testing-source').with({ - 'failovermethod' => 'priority', - 'proxy' => 'absent', - 'enabled' => '0', - 'gpgcheck' => '1', - }) - end -end - -shared_examples_for :epel_testing_source_7 do - include_context :epel_testing_source - - it do - should contain_yumrepo('epel-testing-source').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/7/SRPMS", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7", - 'descr' => "Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source", - }) - end -end - -shared_examples_for :epel_testing_source_6 do - include_context :epel_testing_source - - it do - should contain_yumrepo('epel-testing-source').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/6/SRPMS", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", - 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch - Source", - }) - end -end - -shared_examples_for :epel_testing_source_5 do - include_context :epel_testing_source - - it do - should contain_yumrepo('epel-testing-source').with({ - 'baseurl' => "https://download.fedoraproject.org/pub/epel/testing/5/SRPMS", - 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", - 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch - Source", - }) - end -end diff --git a/vagrant/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb b/vagrant/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb deleted file mode 100644 index 07fe2ef85..000000000 --- a/vagrant/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper' - -describe 'epel::rpm_gpg_key' do - context 'operatingsystemmajrelease => 7' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '7.0.1406', - :operatingsystemmajrelease => '7', - }) - end - - let :title do - 'EPEL-7' - end - - let :params do - { :path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7" } - end - - it do - should contain_exec("import-#{title}").with({ - 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', - 'command' => "rpm --import #{params[:path]}", - 'unless' => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids --keyid-format short < #{params[:path]}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", - 'require' => "File[#{params[:path]}]", - 'logoutput' => 'on_failure', - }) - end - end - - context 'operatingsystemmajrelease => 6' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '6.4', - :operatingsystemmajrelease => '6', - }) - end - - let :title do - 'EPEL-6' - end - - let :params do - { :path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" } - end - - it do - should contain_exec("import-#{title}").with({ - 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', - 'command' => "rpm --import #{params[:path]}", - 'unless' => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids --keyid-format short < #{params[:path]}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", - 'require' => "File[#{params[:path]}]", - 'logoutput' => 'on_failure', - }) - end - end - - context 'operatingsystemmajrelease => 5' do - let :facts do - default_facts.merge({ - :operatingsystemrelease => '5.9', - :operatingsystemmajrelease => '5', - }) - end - - let :title do - 'EPEL-5' - end - - let :params do - { :path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5" } - end - - it do - should contain_exec("import-#{title}").with({ - 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', - 'command' => "rpm --import #{params[:path]}", - 'unless' => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids --keyid-format short < #{params[:path]}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", - 'require' => "File[#{params[:path]}]", - 'logoutput' => 'on_failure', - }) - end - end -end diff --git a/vagrant/puppet/modules/epel/spec/spec_helper.rb b/vagrant/puppet/modules/epel/spec/spec_helper.rb deleted file mode 100644 index eafe6b600..000000000 --- a/vagrant/puppet/modules/epel/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'puppetlabs_spec_helper/module_spec_helper' - -def default_facts - { - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - } -end diff --git a/vagrant/puppet/modules/epel/spec/spec_helper_system.rb b/vagrant/puppet/modules/epel/spec/spec_helper_system.rb deleted file mode 100644 index cf680367b..000000000 --- a/vagrant/puppet/modules/epel/spec/spec_helper_system.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rspec-system/spec_helper' -require 'rspec-system-puppet/helpers' - -include RSpecSystemPuppet::Helpers - -RSpec.configure do |c| - # Project root for the this module's code - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Enable colour in Jenkins - c.tty = true - - c.include RSpecSystemPuppet::Helpers - - # This is where we 'setup' the nodes before running our tests - c.before :suite do - # Install puppet - puppet_install - puppet_master_install - - puppet_module_install(:source => proj_root, :module_name => 'epel') - end -end diff --git a/vagrant/puppet/modules/epel/spec/system/basic_spec.rb b/vagrant/puppet/modules/epel/spec/system/basic_spec.rb deleted file mode 100644 index 9573c4763..000000000 --- a/vagrant/puppet/modules/epel/spec/system/basic_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper_system' - -describe 'epel class:' do - context puppet_agent do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - end - - # Verify the operatingsystemmajrelease fact is working - context shell 'facter --puppet operatingsystemmajrelease' do - its(:stdout) { should_not be_empty } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - pp = "class { 'epel': }" - - context puppet_apply pp do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - context 'test EPEL repo presence' do - facts = node.facts - - # Only test for EPEL's presence if not Fedora - if facts['operatingsystem'] !~ /Fedora/ - context shell '/usr/bin/yum-config-manager epel | grep -q "\[epel\]"' do - its(:exit_code) { should be_zero } - end - end - end -end diff --git a/vagrant/puppet/modules/epel/spec/system/usage_spec.rb b/vagrant/puppet/modules/epel/spec/system/usage_spec.rb deleted file mode 100644 index 115afa16b..000000000 --- a/vagrant/puppet/modules/epel/spec/system/usage_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'spec_helper_system' - -describe 'standage usage tests:' do - context 'test epel baseurl and mirrorlist' do - facts = node.facts - operatingsystemmajrelease = facts['operatingsystemrelease'].split('.')[0] - pp = <<-EOS - class { 'epel': - epel_baseurl => 'http://dl.fedoraproject.org/pub/epel/#{operatingsystemmajrelease}/x86_64/', - epel_mirrorlist => 'absent', - } - EOS - - context puppet_apply pp do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - # Only test for EPEL's presence if not Fedora - if facts['operatingsystem'] !~ /Fedora/ - # Test the yum config to ensure mirrorlist was emptied - context shell '/usr/bin/yum-config-manager epel | egrep "^mirrorlist ="' do - its(:stdout) { should =~ /mirrorlist =\s+/ } - end - - # Test the yum config to ensure baseurl was defined - context shell '/usr/bin/yum-config-manager epel | egrep "^baseurl ="' do - its(:stdout) { should =~ /baseurl = http:\/\/dl.fedoraproject.org\/pub\/epel\/#{operatingsystemmajrelease}\/x86_64\// } - end - end - end - - context 'test epel-testing is enabled' do - facts = node.facts - pp = <<-EOS - class { 'epel': - epel_testing_enabled => '1', - } - EOS - - context puppet_apply pp do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - # Only test for EPEL's presence if not Fedora - if facts['operatingsystem'] !~ /Fedora/ - # Test the yum config to ensure epel-testing was enabled - context shell '/usr/bin/yum-config-manager epel-testing | grep -q "enabled = True"' do - its(:exit_code) { should be_zero } - end - end - end -end diff --git a/vagrant/puppet/modules/epel/tests/init.pp b/vagrant/puppet/modules/epel/tests/init.pp deleted file mode 100644 index bf0041dc7..000000000 --- a/vagrant/puppet/modules/epel/tests/init.pp +++ /dev/null @@ -1,3 +0,0 @@ -# And by test, I mean, run this thing for me using Puppet apply and I'll check -# it out. -include '::epel' diff --git a/vagrant/puppet/modules/postgresql/CHANGELOG.md b/vagrant/puppet/modules/postgresql/CHANGELOG.md deleted file mode 100644 index e5e02991c..000000000 --- a/vagrant/puppet/modules/postgresql/CHANGELOG.md +++ /dev/null @@ -1,864 +0,0 @@ -## Supported Release 4.8.0 -### Summary -This release primarily fixes an issue with `postgresql_conf` values of ipaddresses being considered floats and not getting quoted. - -#### Features -- Add `default_connect_settings` parameter to `postgresql::server` -- Running under strict variables is now supported -- Add timestamps into logs by default - -#### Bugfixes -- Obscure password in postgresql\_psql type -- Fix ip address quoting in postgresql\_conf type -- Fix handling of systemd service on Ubuntu -- Mark log_min_duration_statement setting as requiring a service restart -- Add fixes for Fedora 23, Fedora 24, FreeBSD, OpenBSD -- Fix environment handling to avoid "Overriding environment setting" message -- Work around PUP-6385, using empty arrays instead of undef when specifying resource relationships -- README editorial pass -- Reduce whitespace in templates -- Update build/test infrastructure - -## Supported Release 4.7.1 -### Summary -This release contains some bugfixes and documentation updates. - -#### Bugfixes -- (MODULES-3024) Quote database objects when creating databases. -- Properly escape case where password ends with '$'. -- Fixes password change when postgres is configure to non-standard port. -- Unpins concat dependency to be able to use concat 2.x. -- Workaround to fix installing on Amazon Linux. -- Fixes proper defaulting of `$service_provider` parameter. -- Fixes postgres server init script naming on Amazon Linux. -- Fixes service reload parameter on Arch Linux. -- Adds missing onlyif_function to sequence grant code. -- Fixes to the markdown of the README. - -## Supported Release 4.7.0 -### Summary -A release with a considerable amount of new features, including remote db support and several platform support updates. Various bugfixes including several to address warnings and a sizable README update. - -#### Features -- Remote DB support - Connection-settings allows a hash of options that can be used when connecting to a remote DB. -- Debian 8 support. -- Updated systemd-override to support fedora and CentOS paths. -- Adds the ability to define the extension name separately from the title of the resource, which allows you to add the extension to more than one database. -- Added parameter to disable automatic service restarts on config changes. -- Ubuntu 15.10 compatibility. -- OpenBSD version is now 9.4. -- Added .gitattributes to maintain line endings for .sh and .rb files. -- Adds default postgis version for 9.5. -- Allows float postgresql_conf values. -- Schedule apt update after install of repo. - -#### Bugfixes -- Fixed systemd-override for RedHat systems with unmanaged Yum repos. -- Removed inherits postgresql::params. -- Multi-node tests are now not ran by default. -- Change apt::pin to apt_postgresql_org to prevent error message. -- Removed syntax error near UTF8. -- Removal of extra blanks and backslashes in README. -- Double quotes now used around database name to prevent syntax error. -- Removes ruby 1.8.7 and puppet 2.7 from travis-ci jobs. -- Fixed paths to work on Amazon Linux. -- Fixed quotes around locale options. -- Huge README update. -- Update to use current msync configs. -- Fixes postgresql::server acceptance test descriptions. - -## Supported Release 4.6.1 -###Summary - -Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. - -## 2015-09-01 - Supported Release 4.6.0 -### Summary -This release adds a proxy feature for yum, Postgis improvements, and decoupling pg_hba_rule from postgresql::server. - -#### Features -- Support setting a proxy for yum operations -- Allow for undefined PostGIS version -- Decouple pg_hba_rule from postgresql::server - -#### Bugfixes -- Fix postgis default package name on RedHat - -## 2015-07-27 - Supported Release 4.5.0 -### Summary -This release adds sequence grants, some postgresql 9.4 fixes, and `onlyif` to -the psql resource. - -### Features -- Add `onlyif` parameter to `postgresql_psql` -- Add unsupported compatibility with Ubuntu 15.04 -- Add unsupported compatibility with SLES 11/12 and OpenSuSE 13.2 -- Add `postgresql::server::grant::onlyif_exists` attribute -- Add `postgresql::server::table_grant::onlyif_exists` attribute -- Add granting permissions on sequences - -### Bugfixes -- Added docs for `postgresql::server::grant` -- Fix `pg_hba_conf_defaults => false` to not disable ipv4/ipv6 acls -- Fix 9.4 for `postgresql::server::pg_hba_rule` - -## 2015-07-07 - Supported Release 4.4.2 -### Summary -This release fixes a bug introduced in 4.4.0. - -#### Bugfixes -- Fixes `withenv` execution under Puppet 2.7. (MODULES-2185) - -## 2015-07-01 - Supported Release 4.4.1 -### Summary -This release fixes RHEL 7 & Fedora with manage_package_repo switched on. - -#### Bugfixes -- Ensure manage_package_repo variable is in scope for systemd-override file for RHEL7 - -## 2015-06-30 - Supported Release 4.4.0 -### Summary -This release has several new features, bugfixes, and test improvements. - -#### Features -- Adds a resource to manage recovery.conf. -- Adds a parameter that allows the specification of a validate connection script in `postgresql::client`. -- Adds support for plpython package management. -- Adds support for postgresql-docs management. -- Adds ability to make `postgresql::server::schema` titles unique. (MODULES-2049) -- Updates puppetlabs-apt module dependency to support version 2.1.0. - -#### Bugfixes -- Fix `postgresql_psql` parameter ordering to work on OpenBSD with Future Parser -- Fix setting postgres role password (MODULES-1869) -- Fix execution command with puppet <3.4 (MODULES-1923) -- Fix Puppet.newtype deprecation warning (MODULES-2007) -- Fix systemd override for manage_repo package versions -- Fix Copy snakeoil certificate and key instead of symlinking - -#### Test Improvements -- Allows setting BEAKER and BEAKER_RSPEC versions via environment variables. -- Enables Unit testing on Travis CI with Puppet 4. -- Cleans up spec_helper_acceptance.rb to use new puppet_install_helper gem. - -## 2015-03-24 - Supported Release 4.3.0 -### Summary -This release fixes compatibility with Puppet 4 and removes opportunities for local users to view the postgresql password. It also adds a new custom resource to aid in managing replication. - -#### Features -- Add `postgresql::server::logdir` parameter to manage the logdir -- Add `environment` parameter to `postgresql_psql` -- Add `postgresql_replication_slot` custom resource - -#### Bugfixes -- Fix for Puppet 4 -- Don't print postgresql\_psql password in command -- Allow `postgresql::validate_db_connection` for more than one host+port+database combo -- Fix service command on Debian 8 and up -- Fix `postgresql::server::extension` to work with custom user/group/port -- Fix `postgresql::server::initdb` to work with custom user/group/port -- Fix changing template1 encoding -- Fix default `postgresql::server::grant::object_name` value -- Fix idempotency of granting all tables in schema with `puppet::server::grant` -- Fix lint warnings -- Fix apt key to use 40 character key and bump puppetlabs-apt to >= 1.8.0 < 2.0.0 - - -##2015-03-10 - Supported Release 4.2.0 -###Summary - -This release has several new features including support for server extensions, improved grant support, and a number of bugfixes. - -####Features -- Changes to support OpenBSD -- Add `service_reload` parameter to `postgresql::server` -- Add `comment` parameter to `postgresql::server::database` (MODULES-1153) -- Add `postgresql::server::extension` defined type -- Add postgresql versions for utopic and jessie -- Update `postgresql::server::grant` to support 'GRANT SCHEMA' and 'ALL TABLES IN SCHEMA' - -####Bugfixes -- Lint cleanup -- Remove outdated upgrade info from README -- Use correct TCP port when checking password -- Create role before database -- Fix template1 encoding on Debian -- Require server package before user permissions -- Fix `service_status` default for FreeBSD to allow PostgreSQL to start the first run -- Fix invalid US-ASCII byte sequence in `postgresql::server::grant` comments -- Reverted to default behavior for Debian systems as `pg_config` should not be overwritten (MODULES-1485) - -##2014-11-04 - Supported Release 4.1.0 -###Summary - -This release adds the ability to change the PGDATA directory, and also includes documentation and test updates, future parser support, and a few other new features. - -####Features -- Future parser support -- Documentation updates -- Test updates -- Add a link from `/etc/sysconfig/pgsql/postgresql-${version}` to `/etc/sysconfig/pgsql/postgresql` to support init scripts from the postgresql.org repo -- Add support for changing the PGDATA directory -- Set default versions for Fedora 21 and FreeBSD - -##2014-09-03 - Supported Release 4.0.0 -###Summary - -This release removes the uninstall ability from the module, removes the firewall -management, overhauls all of the acceptance testing, as well as adds better -support for SuSE and Fedora. - -###Backwards Incompatible changes. - -- Uninstall code removal. -- Firewall management for Postgres. -- Set manage_pg_ident_conf to true. - -####Uninstallation removal - -We rely heavily on the ability to uninstall and reinstall postgres throughout -our testing code, testing features like "can I move from the distribution -packages to the upstream packages through the module" and over time we've -learnt that the uninstall code simply doesn't work a lot of the time. It -leaves traces of postgres behind or fails to remove certain packages on Ubuntu, -and generally causes bits to be left on your system that you didn't expect. - -When we then reinstall things fail because it's not a true clean slate, and -this causes us enormous problems during test. We've spent weeks and months -working on these tests and they simply don't hold up well across the full range -of PE platforms. - -Due to all these problems we've decided to take a stance on uninstalling in -general. We feel that in 2014 it's completely reasonable and normal to have a -good provisioning pipeline combined with your configuration management and the -"correct" way to uninstall a fully installed service like postgresql is to -simply reprovision the server without it in the first place. As a general rule -this is how I personally like to work and I think is a good practice. - -####I'm not OK with this! - -We understand that there are environments and situations in which it's not easy -to do that. What if you accidently deployed Postgres on 100,000 nodes? In the -future we're going to take a look at building some example 'profiles' to be -found under examples/ within this module that can uninstall postgres on popular -platforms. These can be modified and used in your specific case to uninstall -postgresql. They will be much more brute force and reliant on deleting entire -directories and require you to do more work up front in specifying where things -are installed but we think it'll prove to be a much cleaner mechanism for this -kind of thing rather than trying to weave it into the main module logic itself. - -####Features -- Removal of uninstall. -- Removal of firewall management. -- Tests ported to rspec3. -- Acceptance tests rewritten. -- Add a defined type for creating database schemas. -- Add a pg_ident_rule defined type. -- Set manage_pg_ident_conf to true. -- Manage pg_ident.conf by default. -- Improve selinux support for tablespace. -- Remove deprecation warnings. -- Support changing PGDATA on RedHat. -- Add SLES 11 support. - -####Bugfixes -- Link pg_config binary into /usr/bin. -- Fix fedora support by using systemd. -- Initdb should create xlogdir if set. - -##2014-08-27 - Supported Release 3.4.3 -###Summary - -This release fixes Ubuntu 10.04 with Facter 2.2. - -####Features -####Bugfixes -- Use a regular expression to match the major OS version on Ubuntu. - -##2014-07-31 - Supported Release 3.4.2 -###Summary - -This release fixes recent Fedora versions. - -####Features -####Bugfixes -- Fix Fedora. - -##2014-07-15 - Supported Release 3.4.1 -###Summary - -This release merely updates metadata.json so the module can be uninstalled and -upgraded via the puppet module command. - -##2014-04-14 - Supported Release 3.4.0 -###Summary - -This feature rolls up several important features, the biggest being PostGIS -handling and allowing `port` to be set on postgresql::server in order to -change the port that Postgres listens on. We've added support for RHEL7 -and Ubuntu 14.04, as well as allowing you to manage the service via -`service_ensure` finally. - -####Features -- Added `perl_package_name` for installing bindings. -- Added `service_ensure` for allowing control of services. -- Added `postgis_version` and postgis class for installing postgis. -- Added `port` for selecting the port Postgres runs on. -- Add support for RHEL7 and Ubuntu 14.04. -- Add `default_db` to postgresql::server::database. -- Widen the selection of unquoted parameters in postgresql_conf{} -- Require the service within postgresql::server::reload for RHEL7. -- Add `inherit` to postgresql::server::role. - -####Bugfixes - -##2014-03-04 - Supported Release 3.3.3 -###Summary - -This is a supported release. This release removes a testing symlink that can -cause trouble on systems where /var is on a seperate filesystem from the -modulepath. - -####Features -####Bugfixes -####Known Bugs -* SLES is not supported. - -##2014-03-04 - Supported Release 3.3.2 -###Summary -This is a supported release. It fixes a problem with updating passwords on postgresql.org distributed versions of PostgreSQL. - -####Bugfixes -- Correct psql path when setting password on custom versions. -- Documentation updates -- Test updates - -####Known Bugs -* SLES is not supported. - - -##2014-02-12 - Version 3.3.1 -####Bugfix: -- Allow dynamic rubygems host - - -##2014-01-28 - Version 3.3.0 - -###Summary - -This release rolls up a bunch of bugfixes our users have found and fixed for -us over the last few months. This improves things for 9.1 users, and makes -this module usable on FreeBSD. - -This release is dedicated to 'bma', who's suffering with Puppet 3.4.1 issues -thanks to Puppet::Util::SUIDManager.run_and_capture. - -####Features - - Add lc_ config entry settings - - Can pass template at database creation. - - Add FreeBSD support. - - Add support for customer `xlogdir` parameter. - - Switch tests from rspec-system to beaker. (This isn't really a feature) - -####Bugfixes - - Properly fix the deprecated Puppet::Util::SUIDManager.run_and_capture errors. - - Fix NOREPLICATION option for Postgres 9.1 - - Wrong parameter name: manage_pg_conf -> manage_pg_hba_conf - - Add $postgresql::server::client_package_name, referred to by install.pp - - Add missing service_provider/service_name descriptions in ::globals. - - Fix several smaller typos/issues throughout. - - Exec['postgresql_initdb'] needs to be done after $datadir exists - - Prevent defined resources from floating in the catalog. - - Fix granting all privileges on a table. - - Add some missing privileges. - - Remove deprecated and unused concat::fragment parameters. - - -##2013-11-05 - Version 3.2.0 - -###Summary - -Add's support for Ubuntu 13.10 (and 14.04) as well as x, y, z. - -####Features -- Add versions for Ubuntu 13.10 and 14.04. -- Use default_database in validate_db_connection instead of a hardcoded -'postgres' -- Add globals/params layering for default_database. -- Allow specification of default database name. - -####Bugs -- Fixes to the README. - - -##2013-10-25 - Version 3.1.0 - -###Summary - -This is a minor feature and bug fix release. - -Firstly, the postgresql_psql type now includes a new parameter `search_path` which is equivalent to using `set search_path` which allows you to change the default schema search path. - -The default version of Fedora 17 has now been added, so that Fedora 17 users can enjoy the module. - -And finally we've extended the capabilities of the defined type postgresql::validate_db_connection so that now it can handle retrying and sleeping between retries. This feature has been monopolized to fix a bug we were seeing with startup race conditions, but it can also be used by remote systems to 'wait' for PostgreSQL to start before their Puppet run continues. - -####Features -- Defined $default_version for Fedora 17 (Bret Comnes) -- add search_path attribute to postgresql_psql resource (Jeremy Kitchen) -- (GH-198) Add wait and retry capability to validate_db_connection (Ken Barber) - -####Bugs -- enabling defined postgres user password without resetting on every puppet run (jonoterc) -- periods are valid in configuration variables also (Jeremy Kitchen) -- Add zero length string to join() function (Jarl Stefansson) -- add require of install to reload class (cdenneen) -- (GH-198) Fix race condition on postgresql startup (Ken Barber) -- Remove concat::setup for include in preparation for the next concat release (Ken Barber) - - -##2013-10-14 - Version 3.0.0 - -Final release of 3.0, enjoy! - - -##2013-10-14 - Version 3.0.0-rc3 - -###Summary - -Add a parameter to unmanage pg_hba.conf to fix a regression from 2.5, as well -as allowing owner to be passed into x. - -####Features -- `manage_pg_hba_conf` parameter added to control pg_hba.conf management. -- `owner` parameter added to server::db. - - -##2013-10-09 - Version 3.0.0-rc2 - -###Summary - -A few bugfixes have been found since -rc1. - -####Fixes -- Special case for $datadir on Amazon -- Fix documentation about username/password for the postgresql_hash function - - -##2013-10-01 - Version 3.0.0-rc1 - -###Summary - -Version 3 was a major rewrite to fix some internal dependency issues, and to -make the new Public API more clear. As a consequence a lot of things have -changed for version 3 and older revisions that we will try to outline here. - -(NOTE: The format of this CHANGELOG differs to normal in an attempt to -explain the scope of changes) - -* Server specific objects now moved under `postgresql::server::` namespace: - -To restructure server specific elements under the `postgresql::server::` -namespaces the following objects were renamed as such: - -`postgresql::database` -> `postgresql::server::database` -`postgresql::database_grant` -> `postgresql::server::database_grant` -`postgresql::db` -> `postgresql::server::db` -`postgresql::grant` -> `postgresql::server::grant` -`postgresql::pg_hba_rule` -> `postgresql::server::pg_hba_rule` -`postgresql::plperl` -> `postgresql::server::plperl` -`postgresql::contrib` -> `postgresql::server::contrib` -`postgresql::role` -> `postgresql::server::role` -`postgresql::table_grant` -> `postgresql::server::table_grant` -`postgresql::tablespace` -> `postgresql::server::tablespace` - -* New `postgresql::server::config_entry` resource for managing configuration: - -Previously we used the `file_line` resource to modify `postgresql.conf`. This -new revision now adds a new resource named `postgresql::server::config_entry` -for managing this file. For example: - -```puppet - postgresql::server::config_entry { 'check_function_bodies': - value => 'off', - } -``` - -If you were using `file_line` for this purpose, you should change to this new -methodology. - -* `postgresql_puppet_extras.conf` has been removed: - -Now that we have a methodology for managing `postgresql.conf`, and due to -concerns over the file management methodology using an `exec { 'touch ...': }` -as a way to create an empty file the existing postgresql\_puppet\_extras.conf -file is no longer managed by this module. - -If you wish to recreate this methodology yourself, use this pattern: - -```puppet - class { 'postgresql::server': } - - $extras = "/tmp/include.conf" - - file { $extras: - content => 'max_connections = 123', - notify => Class['postgresql::server::service'], - }-> - postgresql::server::config_entry { 'include': - value => $extras, - } -``` - -* All uses of the parameter `charset` changed to `encoding`: - -Since PostgreSQL uses the terminology `encoding` not `charset` the parameter -has been made consisent across all classes and resources. - -* The `postgresql` base class is no longer how you set globals: - -The old global override pattern was less then optimal so it has been fixed, -however we decided to demark this properly by specifying these overrides in -the class `postgresql::global`. Consult the documentation for this class now -to see what options are available. - -Also, some parameter elements have been moved between this and the -`postgresql::server` class where it made sense. - -* `config_hash` parameter collapsed for the `postgresql::server` class: - -Because the `config_hash` was really passing data through to what was in -effect an internal class (`postgresql::config`). And since we don't want this -kind of internal exposure the parameters were collapsed up into the -`postgresql::server` class directly. - -* Lots of changes to 'private' or 'undocumented' classes: - -If you were using these before, these have changed names. You should only use -what is documented in this README.md, and if you don't have what you need you -should raise a patch to add that feature to a public API. All internal classes -now have a comment at the top indicating them as private to make sure the -message is clear that they are not supported as Public API. - -* `pg_hba_conf_defaults` parameter included to turn off default pg\_hba rules: - -The defaults should be good enough for most cases (if not raise a bug) but if -you simply need an escape hatch, this setting will turn off the defaults. If -you want to do this, it may affect the rest of the module so make sure you -replace the rules with something that continues operation. - -* `postgresql::database_user` has now been removed: - -Use `postgresql::server::role` instead. - -* `postgresql::psql` resource has now been removed: - -Use `postgresql_psql` instead. In the future we may recreate this as a wrapper -to add extra capability, but it will not match the old behaviour. - -* `postgresql_default_version` fact has now been removed: - -It didn't make sense to have this logic in a fact any more, the logic has been -moved into `postgresql::params`. - -* `ripienaar/concat` is no longer used, instead we use `puppetlabs/concat`: - -The older concat module is now deprecated and moved into the -`puppetlabs/concat` namespace. Functionality is more or less identical, but -you may need to intervene during the installing of this package - as both use -the same `concat` namespace. - ---- -##2013-09-09 Release 2.5.0 - -###Summary - -The focus of this release is primarily to capture the fixes done to the -types and providers to make sure refreshonly works properly and to set -the stage for the large scale refactoring work of 3.0.0. - -####Features - - -####Bugfixes -- Use boolean for refreshonly. -- Fix postgresql::plperl documentation. -- Add two missing parameters to config::beforeservice -- Style fixes - - -##2013-08-01 Release 2.4.1 - -###Summary - -This minor bugfix release solves an idempotency issue when using plain text -passwords for the password_hash parameter for the postgresql::role defined -type. Without this, users would continually see resource changes everytime -your run Puppet. - -####Bugfixes -- Alter role call not idempotent with cleartext passwords (Ken Barber) - - -##2013-07-19 Release 2.4.0 - -###Summary - -This updates adds the ability to change permissions on tables, create template -databases from normal databases, manage PL-Perl's postgres package, and -disable the management of `pg_hba.conf`. - -####Features -- Add `postgresql::table_grant` defined resource -- Add `postgresql::plperl` class -- Add `manage_pg_hba_conf` parameter to the `postgresql::config` class -- Add `istemplate` parameter to the `postgresql::database` define - -####Bugfixes -- Update `postgresql::role` class to be able to update roles when modified -instead of only on creation. -- Update tests -- Fix documentation of `postgresql::database_grant` - - -##2.3.0 - -This feature release includes the following changes: - -* Add a new parameter `owner` to the `database` type. This can be used to - grant ownership of a new database to a specific user. (Bruno Harbulot) -* Add support for operating systems other than Debian/RedHat, as long as the - user supplies custom values for all of the required paths, package names, etc. - (Chris Price) -* Improved integration testing (Ken Barber) - - -##2.2.1 - -This release fixes a bug whereby one of our shell commands (psql) were not ran from a globally accessible directory. This was causing permission denied errors when the command attempted to change user without changing directory. - -Users of previous versions might have seen this error: - - Error: Error executing SQL; psql returned 256: 'could not change directory to "/root" - -This patch should correct that. - -#### Detail Changes - -* Set /tmp as default CWD for postgresql_psql - - -##2.2.0 - -This feature release introduces a number of new features and bug fixes. - -First of all it includes a new class named `postgresql::python` which provides you with a convenient way of install the python Postgresql client libraries. - - class { 'postgresql::python': - } - -You are now able to use `postgresql::database_user` without having to specify a password_hash, useful for different authentication mechanisms that do not need passwords (ie. cert, local etc.). - -We've also provided a lot more advanced custom parameters now for greater control of your Postgresql installation. Consult the class documentation for PuppetDB in the README. - -This release in particular has largely been contributed by the community members below, a big thanks to one and all. - -#### Detailed Changes - -* Add support for psycopg installation (Flaper Fesp and Dan Prince) -* Added default PostgreSQL version for Ubuntu 13.04 (Kamil Szymanski) -* Add ability to create users without a password (Bruno Harbulot) -* Three Puppet 2.6 fixes (Dominic Cleal) -* Add explicit call to concat::setup when creating concat file (Dominic Cleal) -* Fix readme typo (Jordi Boggiano) -* Update postgres_default_version for Ubuntu (Kamil Szymanski) -* Allow to set connection for noew role (Kamil Szymanski) -* Fix pg_hba_rule for postgres local access (Kamil Szymanski) -* Fix versions for travis-ci (Ken Barber) -* Add replication support (Jordi Boggiano) -* Cleaned up and added unit tests (Ken Barber) -* Generalization to provide more flexability in postgresql configuration (Karel Brezina) -* Create dependent directory for sudoers so tests work on Centos 5 (Ken Barber) -* Allow SQL commands to be run against a specific DB (Carlos Villela) -* Drop trailing comma to support Puppet 2.6 (Michael Arnold) - - -##2.1.1 - - -This release provides a bug fix for RHEL 5 and Centos 5 systems, or specifically systems using PostgreSQL 8.1 or older. On those systems one would have received the error: - - Error: Could not start Service[postgresqld]: Execution of ‘/sbin/service postgresql start’ returned 1: - -And the postgresql log entry: - - FATAL: unrecognized configuration parameter "include" - -This bug is due to a new feature we had added in 2.1.0, whereby the `include` directive in `postgresql.conf` was not compatible. As a work-around we have added checks in our code to make sure systems running PostgreSQL 8.1 or older do not have this directive added. - -#### Detailed Changes - -2013-01-21 - Ken Barber -* Only install `include` directive and included file on PostgreSQL >= 8.2 -* Add system tests for Centos 5 - - -##2.1.0 - -This release is primarily a feature release, introducing some new helpful constructs to the module. - -For starters, we've added the line `include 'postgresql_conf_extras.conf'` by default so extra parameters not managed by the module can be added by other tooling or by Puppet itself. This provides a useful escape-hatch for managing settings that are not currently managed by the module today. - -We've added a new defined resource for managing your tablespace, so you can now create new tablespaces using the syntax: - - postgresql::tablespace { 'dbspace': - location => '/srv/dbspace', - } - -We've added a locale parameter to the `postgresql` class, to provide a default. Also the parameter has been added to the `postgresql::database` and `postgresql::db` defined resources for changing the locale per database: - - postgresql::db { 'mydatabase': - user => 'myuser', - password => 'mypassword', - encoding => 'UTF8', - locale => 'en_NG', - } - -There is a new class for installing the necessary packages to provide the PostgreSQL JDBC client jars: - - class { 'postgresql::java': } - -And we have a brand new defined resource for managing fine-grained rule sets within your pg_hba.conf access lists: - - postgresql::pg_hba { 'Open up postgresql for access from 200.1.2.0/24': - type => 'host', - database => 'app', - user => 'app', - address => '200.1.2.0/24', - auth_method => 'md5', - } - -Finally, we've also added Travis-CI support and unit tests to help us iterate faster with tests to reduce regression. The current URL for these tests is here: https://travis-ci.org/puppetlabs/puppet-postgresql. Instructions on how to run the unit tests available are provided in the README for the module. - -A big thanks to all those listed below who made this feature release possible :-). - -#### Detailed Changes - -2013-01-18 - Simão Fontes & Flaper Fesp -* Remove trailing commas from params.pp property definition for Puppet 2.6.0 compatibility - -2013-01-18 - Lauren Rother -* Updated README.md to conform with best practices template - -2013-01-09 - Adrien Thebo -* Update postgresql_default_version to 9.1 for Debian 7.0 - -2013-01-28 - Karel Brezina -* Add support for tablespaces - -2013-01-16 - Chris Price & Karel Brezina -* Provide support for an 'include' config file 'postgresql_conf_extras.conf' that users can modify manually or outside of the module. - -2013-01-31 - jv -* Fix typo in README.pp for postgresql::db example - -2013-02-03 - Ken Barber -* Add unit tests and travis-ci support - -2013-02-02 - Ken Barber -* Add locale parameter support to the 'postgresql' class - -2013-01-21 - Michael Arnold -* Add a class for install the packages containing the PostgreSQL JDBC jar - -2013-02-06 - fhrbek -* Coding style fixes to reduce warnings in puppet-lint and Geppetto - -2013-02-10 - Ken Barber -* Provide new defined resource for managing pg_hba.conf - -2013-02-11 - Ken Barber -* Fix bug with reload of Postgresql on Redhat/Centos - -2013-02-15 - Erik Dalén -* Fix more style issues to reduce warnings in puppet-lint and Geppetto - -2013-02-15 - Erik Dalén -* Fix case whereby we were modifying a hash after creation - - -##2.0.1 - -Minor bugfix release. - -2013-01-16 - Chris Price - * Fix revoke command in database.pp to support postgres 8.1 (43ded42) - -2013-01-15 - Jordi Boggiano - * Add support for ubuntu 12.10 status (3504405) - -##2.0.0 - -Many thanks to the following people who contributed patches to this -release: - -* Adrien Thebo -* Albert Koch -* Andreas Ntaflos -* Brett Porter -* Chris Price -* dharwood -* Etienne Pelletier -* Florin Broasca -* Henrik -* Hunter Haugen -* Jari Bakken -* Jordi Boggiano -* Ken Barber -* nzakaria -* Richard Arends -* Spenser Gilliland -* stormcrow -* William Van Hevelingen - -Notable features: - - * Add support for versions of postgres other than the system default version - (which varies depending on OS distro). This includes optional support for - automatically managing the package repo for the "official" postgres yum/apt - repos. (Major thanks to Etienne Pelletier and - Ken Barber for their tireless efforts and patience on this - feature set!) For example usage see `tests/official-postgresql-repos.pp`. - - * Add some support for Debian Wheezy and Ubuntu Quantal - - * Add new `postgres_psql` type with a Ruby provider, to replace the old - exec-based `psql` type. This gives us much more flexibility around - executing SQL statements and controlling their logging / reports output. - - * Major refactor of the "spec" tests--which are actually more like - acceptance tests. We now support testing against multiple OS distros - via vagrant, and the framework is in place to allow us to very easily add - more distros. Currently testing against Cent6 and Ubuntu 10.04. - - * Fixed a bug that was preventing multiple databases from being owned by the - same user - (9adcd182f820101f5e4891b9f2ff6278dfad495c - Etienne Pelletier ) - - * Add support for ACLs for finer-grained control of user/interface access - (b8389d19ad78b4fb66024897097b4ed7db241930 - dharwood ) - - * Many other bug fixes and improvements! - ---- -##1.0.0 - -2012-09-17 - Version 0.3.0 released - -2012-09-14 - Chris Price - * Add a type for validating a postgres connection (ce4a049) - -2012-08-25 - Jari Bakken - * Remove trailing commas. (e6af5e5) - -2012-08-16 - Version 0.2.0 released diff --git a/vagrant/puppet/modules/postgresql/CONTRIBUTING.md b/vagrant/puppet/modules/postgresql/CONTRIBUTING.md deleted file mode 100644 index 3c3f1e799..000000000 --- a/vagrant/puppet/modules/postgresql/CONTRIBUTING.md +++ /dev/null @@ -1,218 +0,0 @@ -Checklist (and a short version for the impatient) -================================================= - - * Commits: - - - Make commits of logical units. - - - Check for unnecessary whitespace with "git diff --check" before - committing. - - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). - - - Do not check in commented out code or unneeded files. - - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. - - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". - - - The body should provide a meaningful commit message, which: - - - uses the imperative, present tense: "change", not "changed" or - "changes". - - - includes motivation for the change, and contrasts its - implementation with the previous behavior. - - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. - - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - - - When introducing a new feature, make sure it is properly - documented in the README.md - - * Submission: - - * Pre-requisites: - - - Make sure you have a [GitHub account](https://github.com/join) - - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. - - * Preferred method: - - - Fork the repository on GitHub. - - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). - - - Submit a pull request to the repository in the puppetlabs - organization. - -The long version -================ - - 1. Make separate commits for logically separate changes. - - Please break your commits down into logically consistent units - which include new or changed tests relevant to the rest of the - change. The goal of doing this is to make the diff easier to - read for whoever is reviewing your code. In general, the easier - your diff is to read, the more likely someone will be happy to - review it and get it into the code base. - - If you are going to refactor a piece of code, please do so as a - separate commit from your feature or bug fix changes. - - We also really appreciate changes that include tests to make - sure the bug is not re-introduced, and that the feature is not - accidentally broken. - - Describe the technical detail of the change(s). If your - description starts to get too long, that is a good sign that you - probably need to split up your commit into more finely grained - pieces. - - Commits which plainly describe the things which help - reviewers check the patch and future developers understand the - code are much more likely to be merged in with a minimum of - bike-shedding or requested changes. Ideally, the commit message - would include information, and be in a form suitable for - inclusion in the release notes for the version of Puppet that - includes them. - - Please also check that you are not introducing any trailing - whitespace or other "whitespace errors". You can do this by - running "git diff --check" on your changes before you commit. - - 2. Sending your patches - - To submit your changes via a GitHub pull request, we _highly_ - recommend that you have them on a topic branch, instead of - directly on "master". - It makes things much easier to keep track of, especially if - you decide to work on another thing before your first change - is merged in. - - GitHub has some pretty good - [general documentation](http://help.github.com/) on using - their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). - - In general, after pushing your topic branch up to your - repository on GitHub, you can switch to the branch in the - GitHub UI and click "Pull Request" towards the top of the page - in order to open a pull request. - - - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you - submitted, then you should update the ticket to include the - location of your branch, along with any other commentary you - may wish to make. - -Testing -======= - -Getting Started ---------------- - -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, -or Gems, are required to build, develop, and test this software. - -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running - -```shell -% bundle install -Fetching gem metadata from https://rubygems.org/........ -Fetching gem metadata from https://rubygems.org/.. -Using rake (10.1.0) -Using builder (3.2.2) --- 8><-- many more --><8 -- -Using rspec-system-puppet (2.2.0) -Using serverspec (0.6.3) -Using rspec-system-serverspec (1.0.0) -Using bundler (1.3.5) -Your bundle is complete! -Use `bundle show [gemname]` to see where a bundled gem is installed. -``` - -NOTE some systems may require you to run this command with sudo. - -If you already have those gems installed, make sure they are up-to-date: - -```shell -% bundle update -``` - -With all dependencies in place and up-to-date we can now run the tests: - -```shell -% bundle exec rake spec -``` - -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), -rspec tests define them in [.fixtures.yml](./fixtures.yml). - -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. - -You can run them by issuing the following command - -```shell -% bundle exec rake spec_clean -% bundle exec rspec spec/acceptance -``` - -This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) -and then run all the tests under [spec/acceptance](./spec/acceptance). - -Writing Tests -------------- - -XXX getting started writing tests. - -If you have commit access to the repository -=========================================== - -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. - -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. - - -Additional Resources -==================== - -* [Getting additional help](http://puppet.com/community/get-help) - -* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) - -* [General GitHub documentation](http://help.github.com/) - -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - diff --git a/vagrant/puppet/modules/postgresql/Gemfile b/vagrant/puppet/modules/postgresql/Gemfile deleted file mode 100644 index 9b5b2146b..000000000 --- a/vagrant/puppet/modules/postgresql/Gemfile +++ /dev/null @@ -1,40 +0,0 @@ -#This file is generated by ModuleSync, do not edit. - -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -def location_for(place, version = nil) - if place =~ /^(git[:@][^#]*)#(.*)/ - [version, { :git => $1, :branch => $2, :require => false}].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false}] - else - [place, version, { :require => false}].compact - end -end - -group :development, :unit_tests do - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'puppet_facts', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '>= 2.3.2', :require => false - gem 'simplecov', :require => false - gem 'puppet-blacksmith', :require => false - gem 'rest-client', '~> 1.8.0', :require => false -end -group :system_tests do - gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') - gem 'beaker', *location_for(ENV['BEAKER_VERSION']) - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'master_manipulator', :require => false - gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) -end - -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) - - -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end diff --git a/vagrant/puppet/modules/postgresql/LICENSE b/vagrant/puppet/modules/postgresql/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vagrant/puppet/modules/postgresql/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vagrant/puppet/modules/postgresql/NOTICE b/vagrant/puppet/modules/postgresql/NOTICE deleted file mode 100644 index 295ce296d..000000000 --- a/vagrant/puppet/modules/postgresql/NOTICE +++ /dev/null @@ -1,29 +0,0 @@ -postgresql puppet module - -Copyright (C) 2012-2016 Puppet Labs, Inc. -Copyright (C) 2012 Inkling Systems Inc -Copyright (C) 2012-2013 Camptocamp SA. - -This product includes software developed by: - The Puppet Labs Inc (http://www.puppetlabs.com/). - -This product includes also software developed by: - Camptocamp SA (http://www.camptocamp.com/) - -This product includes also software developed by: - Inkling Systems Inc (https://www.inkling.com/) - -Puppet Labs can be contacted at: info@puppetlabs.com - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vagrant/puppet/modules/postgresql/README.md b/vagrant/puppet/modules/postgresql/README.md deleted file mode 100644 index 2cdbd6a9b..000000000 --- a/vagrant/puppet/modules/postgresql/README.md +++ /dev/null @@ -1,1415 +0,0 @@ -# postgresql - -#### Table of Contents - -1. [Module Description - What does the module do?](#module-description) -2. [Setup - The basics of getting started with postgresql module](#setup) - * [What postgresql affects](#what-postgresql-affects) - * [Getting started with postgresql](#getting-started-with-postgresql) -3. [Usage - Configuration options and additional functionality](#usage) - * [Configure a server](#configure-a-server) - * [Create a database](#create-a-database) - * [Manage users, roles, and permissions](#manage-users-roles-and-permissions) - * [Override defaults](#override-defaults) - * [Create an access rule for pg_hba.conf](#create-an-access-rule-for-pg_hbaconf) - * [Create user name maps for pg_ident.conf](#create-user-name-maps-for-pg_identconf) - * [Validate connectivity](#validate-connectivity) -4. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Classes](#classes) - * [Defined Types](#defined-types) - * [Types](#types) - * [Functions](#functions) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) - * [Contributors - List of module contributors](#contributors) -7. [Tests](#tests) -8. [Contributors - List of module contributors](#contributors) - -## Module description - -The postgresql module allows you to manage PostgreSQL databases with Puppet. - -PostgreSQL is a high-performance, free, open-source relational database server. The postgresql module allows you to manage packages, services, databases, users, and common security settings in PostgreSQL. - -## Setup - -### What postgresql affects - -* Package, service, and configuration files for PostgreSQL -* Listened-to ports -* IP and mask (optional) - -### Getting started with postgresql - -To configure a basic default PostgreSQL server, declare the `postgresql::server` class. - -```puppet -class { 'postgresql::server': } -``` - -## Usage - -### Configure a server - -For default settings, declare the `postgresql::server` class as above. To customize PostgreSQL server settings, specify the [parameters](#postgresqlserver) you want to change: - -```puppet -class { 'postgresql::server': - ip_mask_deny_postgres_user => '0.0.0.0/32', - ip_mask_allow_all_users => '0.0.0.0/0', - listen_addresses => '*', - ipv4acls => ['hostssl all johndoe 192.168.0.0/24 cert'], - postgres_password => 'TPSrep0rt!', -} -``` - -After configuration, test your settings from the command line: - -``` -psql -h localhost -U postgres -psql -h my.postgres.server -U -``` - -If you get an error message from these commands, your permission settings restrict access from the location you're trying to connect from. Depending on whether you want to allow connections from that location, you might need to adjust your permissions. - -For more details about server configuration parameters, consult the [PostgreSQL Runtime Configuration documentation](http://www.postgresql.org/docs/current/static/runtime-config.html). - -### Create a database - -You can set up a variety of PostgreSQL databases with the `postgresql::server::db` defined type. For instance, to set up a database for PuppetDB: - -```puppet -class { 'postgresql::server': } - -postgresql::server::db { 'mydatabasename': - user => 'mydatabaseuser', - password => postgresql_password('mydatabaseuser', 'mypassword'), -} -``` - -### Manage users, roles, and permissions - -To manage users, roles, and permissions: - -```puppet -class { 'postgresql::server': } - -postgresql::server::role { 'marmot': -password_hash => postgresql_password('marmot', 'mypasswd'), -} - -postgresql::server::database_grant { 'test1': - privilege => 'ALL', - db => 'test1', - role => 'marmot', -} - -postgresql::server::table_grant { 'my_table of test2': - privilege => 'ALL', - table => 'my_table', - db => 'test2', - role => 'marmot', -} -``` - -This example grants **all** privileges on the test1 database and on the `my_table` table of the test2 database to the specified user or group. After the values are added into the PuppetDB config file, this database would be ready for use. - -### Override defaults - -The `postgresql::globals` class allows you to configure the main settings for this module globally, so that other classes and defined resources can use them. By itself, it does nothing. - -For example, to overwrite the default `locale` and `encoding` for all classes, use the following: - -```puppet -class { 'postgresql::globals': - encoding => 'UTF-8', - locale => 'en_US.UTF-8', -}-> -class { 'postgresql::server': -} -``` - -To use a specific version of the PostgreSQL package: - -```puppet -class { 'postgresql::globals': - manage_package_repo => true, - version => '9.2', -}-> -class { 'postgresql::server': } -``` - -### Manage remote users, roles, and permissions - -Remote SQL objects are managed using the same Puppet resources as local SQL objects, along with a [`connect_settings`](#connect_settings) hash. This provides control over how Puppet connects to the remote Postgres instances and which version is used for generating SQL commands. - -The `connect_settings` hash can contain environment variables to control Postgres client connections, such as 'PGHOST', 'PGPORT', 'PGPASSWORD', and 'PGSSLKEY'. See the [PostgreSQL Environment Variables](http://www.postgresql.org/docs/9.4/static/libpq-envars.html) documentation for a complete list of variables. - -Additionally, you can specify the target database version with the special value of 'DBVERSION'. If the `connect_settings` hash is omitted or empty, then Puppet connects to the local PostgreSQL instance. - -You can provide a `connect_settings` hash for each of the Puppet resources, or you can set a default `connect_settings` hash in `postgresql::globals`. Configuring `connect_settings` per resource allows SQL objects to be created on multiple databases by multiple users. - -```puppet -$connection_settings_super2 = { - 'PGUSER' => "super2", - 'PGPASSWORD' => "foobar2", - 'PGHOST' => "127.0.0.1", - 'PGPORT' => "5432", - 'PGDATABASE' => "postgres", - } - -include postgresql::server - -# Connect with no special settings, i.e domain sockets, user postgres -postgresql::server::role{'super2': - password_hash => "foobar2", - superuser => true, - - connect_settings => {}, - require => [ - Class['postgresql::globals'], - Class['postgresql::server::service'], - ], -} - -# Now using this new user connect via TCP -postgresql::server::database { 'db1': - connect_settings => $connection_settings_super2, - -require => Postgresql::Server::Role['super2'], -} -``` - -### Create an access rule for pg_hba.conf - -To create an access rule for `pg_hba.conf`: - -```puppet -postgresql::server::pg_hba_rule { 'allow application network to access app database': - description => "Open up PostgreSQL for access from 200.1.2.0/24", - type => 'host', - database => 'app', - user => 'app', - address => '200.1.2.0/24', - auth_method => 'md5', -} -``` - -This would create a ruleset in `pg_hba.conf` similar to: - -``` -# Rule Name: allow application network to access app database -# Description: Open up PostgreSQL for access from 200.1.2.0/24 -# Order: 150 -host app app 200.1.2.0/24 md5 -``` - -By default, `pg_hba_rule` requires that you include `postgresql::server`. However, you can override that behavior by setting target and postgresql_version when declaring your rule. That might look like the following: - -```puppet -postgresql::server::pg_hba_rule { 'allow application network to access app database': - description => "Open up postgresql for access from 200.1.2.0/24", - type => 'host', - database => 'app', - user => 'app', - address => '200.1.2.0/24', - auth_method => 'md5', - target => '/path/to/pg_hba.conf', - postgresql_version => '9.4', -} -``` - -### Create user name maps for pg_ident.conf - -To create a user name map for the pg_ident.conf: - -```puppet -postgresql::server::pg_ident_rule{ 'Map the SSL certificate of the backup server as a replication user': - map_name => 'sslrepli', - system_username => 'repli1.example.com', - database_username => 'replication', -} -``` - -This would create a user name map in `pg_ident.conf` similar to: - -``` -#Rule Name: Map the SSL certificate of the backup server as a replication user -#Description: none -#Order: 150 -sslrepli repli1.example.com replication -``` - -### Create recovery configuration - -To create the recovery configuration file (`recovery.conf`): - -```puppet -postgresql::server::recovery{ 'Create a recovery.conf file with the following defined parameters': - restore_command => 'cp /mnt/server/archivedir/%f %p', - archive_cleanup_command => undef, - recovery_end_command => undef, - recovery_target_name => 'daily backup 2015-01-26', - recovery_target_time => '2015-02-08 22:39:00 EST', - recovery_target_xid => undef, - recovery_target_inclusive => true, - recovery_target => 'immediate', - recovery_target_timeline => 'latest', - pause_at_recovery_target => true, - standby_mode => 'on', - primary_conninfo => 'host=localhost port=5432', - primary_slot_name => undef, - trigger_file => undef, - recovery_min_apply_delay => 0, -} -``` - -The above creates this `recovery.conf` config file: - -``` -restore_command = 'cp /mnt/server/archivedir/%f %p' -recovery_target_name = 'daily backup 2015-01-26' -recovery_target_time = '2015-02-08 22:39:00 EST' -recovery_target_inclusive = true -recovery_target = 'immediate' -recovery_target_timeline = 'latest' -pause_at_recovery_target = true -standby_mode = 'on' -primary_conninfo = 'host=localhost port=5432' -recovery_min_apply_delay = 0 -``` - -Only the specified parameters are recognized in the template. The `recovery.conf` is only be created if at least one parameter is set **and** [manage_recovery_conf](#manage_recovery_conf) is set to true. - -### Validate connectivity - -To validate client connections to a remote PostgreSQL database before starting dependent tasks, use the `postgresql::validate_db_connection` resource. You can use this on any node where the PostgreSQL client software is installed. It is often chained to other tasks such as starting an application server or performing a database migration. - -Example usage: - -```puppet -postgresql::validate_db_connection { 'validate my postgres connection': - database_host => 'my.postgres.host', - database_username => 'mydbuser', - database_password => 'mydbpassword', - database_name => 'mydbname', -}-> -exec { 'rake db:migrate': - cwd => '/opt/myrubyapp', -} -``` - -## Reference - -The postgresql module comes with many options for configuring the server. While you are unlikely to use all of the settings below, they provide a decent amount of control over your security settings. - -**Classes:** - -* [postgresql::client](#postgresqlclient) -* [postgresql::globals](#postgresqlglobals) -* [postgresql::lib::devel](#postgresqllibdevel) -* [postgresql::lib::java](#postgresqllibjava) -* [postgresql::lib::perl](#postgresqllibperl) -* [postgresql::lib::python](#postgresqllibpython) -* [postgresql::server](#postgresqlserver) -* [postgresql::server::plperl](#postgresqlserverplperl) -* [postgresql::server::contrib](#postgresqlservercontrib) -* [postgresql::server::postgis](#postgresqlserverpostgis) - -**Defined Types:** - -* [postgresql::server::config_entry](#postgresqlserverconfig_entry) -* [postgresql::server::database](#postgresqlserverdatabase) -* [postgresql::server::database_grant](#postgresqlserverdatabase_grant) -* [postgresql::server::db](#postgresqlserverdb) -* [postgresql::server::extension](#postgresqlserverextension) -* [postgresql::server::pg_hba_rule](#postgresqlserverpg_hba_rule) -* [postgresql::server::pg_ident_rule](#postgresqlserverpg_ident_rule) -* [postgresql::server::recovery](#postgresqlserverrecovery) -* [postgresql::server::role](#postgresqlserverrole) -* [postgresql::server::schema](#postgresqlserverschema) -* [postgresql::server::table_grant](#postgresqlservertable_grant) -* [postgresql::server::tablespace](#postgresqlservertablespace) -* [postgresql::validate_db_connection](#postgresqlvalidate_db_connection) - -**Types:** - -* [postgresql_psql](#custom-resource-postgresql_psql) -* [postgresql_replication_slot](#custom-resource-postgresql_replication_slot) -* [postgresql_conf](#custom-resource-postgresql_conf) - -**Functions:** - -* [postgresql_password](#function-postgresql_password) -* [postgresql_acls_to_resources_hash](#function-postgresql_acls_to_resources_hashacl_array-id-order_offset) - -### Classes - -#### postgresql::client - -Installs PostgreSQL client software. Set the following parameters if you have a custom version you would like to install. - ->**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. - -##### `package_ensure` - -Whether the PostgreSQL client package resource should be present. Valid values: 'present', 'absent'. Default: 'present'. - -##### `package_name` - -Sets the name of the PostgreSQL client package. Default: 'file'. - -##### `validcon_script_path` - -Specifies the path to validate the connection script. Default: '/usr/local/bin/validate_postgresql_connection.sh'. - -#### postgresql::lib::docs - -Installs PostgreSQL bindings for Postgres-Docs. Set the following parameters if you have a custom version you would like to install. - -**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. - -##### `package_name` - -Specifies the name of the PostgreSQL docs package. - -##### `package_ensure` - -Whether the PostgreSQL docs package resource should be present. Valid values: 'present', 'absent'. Default: 'present'. - -#### postgresql::globals - -**Note:** Most server-specific defaults should be overridden in the `postgresql::server` class. This class should be used only if you are using a non-standard OS, or if you are changing elements that can only be changed here, such as `version` or `manage_package_repo`. - -##### `bindir` - -Overrides the default PostgreSQL binaries directory for the target platform. Default: OS dependent. - -##### `client_package_name` - -Overrides the default PostgreSQL client package name. Default: OS dependent. - -##### `confdir` - -Overrides the default PostgreSQL configuration directory for the target platform. Default: OS dependent. - -##### `contrib_package_name` - -Overrides the default PostgreSQL contrib package name. Default: OS dependent. - -##### `createdb_path` - -**Deprecated.** Path to the `createdb` command. Default: "${bindir}/createdb". - -##### `datadir` - -Overrides the default PostgreSQL data directory for the target platform. Default: OS dependent. - -**Note:** Changing the datadir after installation causes the server to come to a full stop before making the change. For Red Hat systems, the data directory must be labeled appropriately for SELinux. On Ubuntu, you must explicitly set `needs_initdb = true` to allow Puppet to initialize the database in the new datadir (`needs_initdb` defaults to true on other systems). - -**Warning:** If datadir is changed from the default, Puppet does not manage purging of the original data directory, which causes it to fail if the data directory is changed back to the original. - -##### `default_database` - -Specifies the name of the default database to connect with. On most systems, this is 'postgres'. - -##### `devel_package_name` - -Overrides the default PostgreSQL devel package name. Default: OS dependent. - -##### `docs_package_name` - -Overrides the default PostgreSQL docs package name. If not specified, the module uses the default for your OS distro. - -##### `encoding` - -Sets the default encoding for all databases created with this module. On certain operating systems, this is also used during the `template1` initialization, so it becomes a default outside of the module as well. Defaults to the operating system's default encoding. - -##### `group` - -Overrides the default postgres user group to be used for related files in the file system. Default: 'postgres'. - -##### `initdb_path` - -Path to the `initdb` command. - -##### `java_package_name` - -Overrides the default PostgreSQL java package name. Default: OS dependent. - -##### `locale` - -Sets the default database locale for all databases created with this module. On certain operating systems, this is also used during the `template1` initialization, so it becomes a default outside of the module as well. Default: undef, which is effectively `C`. **On Debian, you'll need to ensure that the 'locales-all' package is installed for full functionality of PostgreSQL.** - -##### `logdir` - -Overrides the default PostgreSQL log directory. Default: initdb's default path. - -##### `log_line_prefix` - -Set a prefix for the server logs. Default: `'%t '` - -##### `manage_package_repo` - -Sets up official PostgreSQL repositories on your host if set to true. Default: false. - -##### `needs_initdb` - -Explicitly calls the initdb operation after the server package is installed and before the PostgreSQL service is started. Default: OS dependent. - -##### `perl_package_name` - -Overrides the default PostgreSQL Perl package name. Default: OS dependent. - -##### `pg_hba_conf_defaults` - -Disables the defaults supplied with the module for `pg_hba.conf` if set to false. This is useful if you want to override the defaults. Be sure that your changes align with the rest of the module, as some access is required to perform some operations, such as basic `psql` operations. Default: true. - -##### `pg_hba_conf_path` - -Specifies the path to your `pg_hba.conf` file. Default: '${confdir}/pg_hba.conf'. - -##### `pg_ident_conf_path` - -Specifies the path to your `pg_ident.conf` file. Default: "${confdir}/pg_ident.conf". - -##### `plperl_package_name` - -Overrides the default PostgreSQL PL/Perl package name. Default: OS dependent. - -##### `plpython_package_name` - -Overrides the default PostgreSQL PL/Python package name. Default: OS dependent. - -##### `postgis_version` - -Defines the version of PostGIS to install, if you install PostGIS. Defaults to the lowest available with the version of PostgreSQL to be installed. - -##### `postgresql_conf_path` - -Sets the path to your `postgresql.conf` file. Default: "${confdir}/postgresql.conf". - -##### `psql_path` - -Sets the path to the `psql` command. - -##### `python_package_name` - -Overrides the default PostgreSQL Python package name. Default: OS dependent. - -##### `recovery_conf_path` - -Path to your `recovery.conf` file. - -##### `repo_proxy` - -Sets the proxy option for the official PostgreSQL yum-repositories only. Debian is currently not supported. This is useful if your server is behind a corporate firewall and needs to use proxy servers for outside connectivity. - -##### `server_package_name` - -Overrides the default PostgreSQL server package name. Default: OS dependent. - -##### `service_name` - -Overrides the default PostgreSQL service name. Default: OS dependent. - -##### `service_provider` - -Overrides the default PostgreSQL service provider. Default: OS dependent. - -##### `service_status` - -Overrides the default status check command for your PostgreSQL service. Default: OS dependent. - -##### `user` - -Overrides the default PostgreSQL super user and owner of PostgreSQL related files in the file system. Default: 'postgres'. - -##### `version` - -The version of PostgreSQL to install and manage. Default: OS system default. - -##### `xlogdir` - -Overrides the default PostgreSQL xlog directory. Default: initdb's default path. - -####postgresql::lib::devel - -Installs the packages containing the development libraries for PostgreSQL and symlinks `pg_config` into `/usr/bin` (if not in `/usr/bin` or `/usr/local/bin`). - -##### `link_pg_config` - -If the bin directory used by the PostgreSQL page is not `/usr/bin` or `/usr/local/bin`, symlinks `pg_config` from the package's bin dir into `usr/bin` (not applicable to Debian systems). Set to false to disable this behavior. Valid values: true, false. Default: true. - -##### `package_ensure` - -Overrides the `ensure` parameter during package installation. Defaults to `present`. - -##### `package_name` - -Overrides the default package name for the distribution you are installing to. Defaults to `postgresql-devel` or `postgresql-devel` depending on your distro. - -#### postgresql::lib::java - -Installs PostgreSQL bindings for Java (JDBC). Set the following parameters if you have a custom version you would like to install. - -**Note:** Make sure to add any necessary yum or apt repositories if specifying a custom version. - -##### `package_ensure` - -Specifies whether the package is present. Valid values: 'present', 'absent'. Default: 'present'. - -##### `package_name` - -Specifies the name of the PostgreSQL java package. - -#### postgresql::lib::perl - -Installs the PostgreSQL Perl libraries. - -##### `package_ensure` - -Specifies whether the package is present. Valid values: 'present', 'absent'. Default: 'present'. - -##### `package_name` - -Specifies the name of the PostgreSQL perl package to install. - -#### postgresql::server::plpython - -Installs the PL/Python procedural language for PostgreSQL. - -##### `package_name` - -Specifies the name of the postgresql PL/Python package. - -##### `package_ensure` - -Specifies whether the package is present. Valid values: 'present', 'absent'. Default: 'present'. - -#### postgresql::lib::python - -Installs PostgreSQL Python libraries. - -##### `package_ensure` - -Specifies whether the package is present. Valid values: 'present', 'absent'. Default: 'present'. - -##### `package_name` - -The name of the PostgreSQL Python package. - -#### postgresql::server - -##### `createdb_path` - -**Deprecated.** Specifies the path to the `createdb` command. Default: "${bindir}/createdb". - -##### `default_database` - -Specifies the name of the default database to connect with. On most systems this is "postgres". - -##### `default_connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Becomes the default for other defined-types. i.e. `postgresql::server::role` - -##### `encoding` - -Sets the default encoding for all databases created with this module. On certain operating systems this is also used during the `template1` initialization, so it becomes a default outside of the module as well. Default: undef. - -##### `group` - -Overrides the default postgres user group to be used for related files in the file system. Default: OS dependent default. - -##### `initdb_path` - -Specifies the path to the `initdb` command. Default: "${bindir}/initdb". - -##### `ipv4acls` - -Lists strings for access control for connection method, users, databases, IPv4 addresses; see [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html) on `pg_hba.conf` for information. - -##### `ipv6acls` - -Lists strings for access control for connection method, users, databases, IPv6 addresses; see [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html) on `pg_hba.conf` for information. - -##### `ip_mask_allow_all_users` - -Overrides PostgreSQL defaults for remote connections. By default, PostgreSQL does not allow database user accounts to connect via TCP from remote machines. If you'd like to allow this, you can override this setting. - -Set to `0.0.0.0/0` to allow database users to connect from any remote machine, or `192.168.0.0/16` to allow connections from any machine on your local 192.168 subnet. Default: `127.0.0.1/32`. - -##### `ip_mask_deny_postgres_user` - -Specifies the IP mask from which remote connections should be denied for the postgres superuser. Defaults to `0.0.0.0/0`, which denies any remote connection. - -##### `listen_addresses` - -Specifies the addresses the server accepts connections to. Valid values: - * 'localhost': Accept connections from local host only. - * '*': Accept connections from any remote machine. - * Specified comma-separated list of hostnames or IP addresses. - -##### `locale` - -Sets the default database locale for all databases created with this module. On certain operating systems this is used during the `template1` initialization as well, so it becomes a default outside of the module. Default: undef, which is effectively `C`. **On Debian, you must ensure that the 'locales-all' package is installed for full functionality of PostgreSQL.** - -##### `log_line_prefix` - -Set a prefix for the server logs. Default: `'%t '` - -##### `manage_pg_hba_conf` - -Whether to manage the pg_hba.conf. If set to true, Puppet overwrites this file. If set to false, Puppet does not modify the file. Valid values: true, false. Default - -##### `manage_pg_ident_conf` - -Overwrites the pg_ident.conf file. If set to true, Puppet overwrites the file. If set to false, Puppet does not modify the file. Valid values: true, false. Default: true. - -##### `manage_recovery_conf` - -Specifies whether or not manage the recovery.conf. If set to true, Puppet overwrites this file. Valid values: true, false. Default: false. - -##### `needs_initdb` - -Explicitly calls the `initdb` operation after server package is installed, and before the PostgreSQL service is started. Default: OS dependent. - -##### `package_ensure` - -Passes a value through to the `package` resource when creating the server instance. Default: undef. - -##### `package_name` - -Specifies the name of the package to use for installing the server software. Default: OS dependent. - -##### `pg_hba_conf_defaults` - -If false, disables the defaults supplied with the module for `pg_hba.conf`. This is useful if you disagree with the defaults and wish to override them yourself. Be sure that your changes of course align with the rest of the module, as some access is required to perform basic `psql` operations for example. - -##### `pg_hba_conf_path` - -Specifies the path to your `pg_hba.conf` file. - -##### `pg_ident_conf_path` - -Specifies the path to your `pg_ident.conf` file. Default: "${confdir}/pg_ident.conf". - -##### `plperl_package_name` - -Sets the default package name for the PL/Perl extension. Default: OS dependent. - -##### `plpython_package_name` - -Sets the default package name for the PL/Python extension. Default: OS dependent. - -##### `port` - -Specifies the port for the PostgreSQL server to listen on. **Note:** The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems, changing the port causes the server to come to a full stop before being able to make the change. Default: `5432`, meaning the Postgres server listens on TCP port 5432. - -##### `postgres_password` - -Sets the password for the `postgres` user to your specified value. Default: undef, meaning the superuser account in the Postgres database is a user called `postgres` and this account does not have a password. - -##### `postgresql_conf_path` - -Specifies the path to your `postgresql.conf` file. Default: "${confdir}/postgresql.conf". - -##### `psql_path` - -Specifies the path to the `psql` command. Default: OS dependent. - -##### `service_manage` - -Defines whether or not Puppet should manage the service. Default: true. - -##### `service_name` - -Overrides the default PostgreSQL service name. Default: OS dependent. - -##### `service_provider` - -Overrides the default PostgreSQL service provider. Default: undef. - -##### `service_reload` - -Overrides the default reload command for your PostgreSQL service. Default: OS dependent. - -##### `service_restart_on_change` - -Overrides the default behavior to restart your PostgreSQL service when a config entry has been changed that requires a service restart to become active. Default: true. - -##### `service_status` - -Overrides the default status check command for your PostgreSQL service. Default: OS dependent. - -##### `user` - -Overrides the default PostgreSQL super user and owner of PostgreSQL related files in the file system. Default: 'postgres'. - - -#### postgresql::server::contrib - -Installs the PostgreSQL contrib package. - -##### `package_ensure` - -Sets the ensure parameter passed on to PostgreSQL contrib package resource. - -##### `package_name` - -The name of the PostgreSQL contrib package. - -#### postgresql::server::plperl - -Installs the PL/Perl procedural language for postgresql. - -##### `package_ensure` - -The ensure parameter passed on to PostgreSQL PL/Perl package resource. - -##### `package_name` - -The name of the PostgreSQL PL/Perl package. - - -#### postgresql::server::postgis - -Installs the PostgreSQL postgis packages. - -### Defined Types - -#### postgresql::server::config_entry - -Modifies your `postgresql.conf` configuration file. - -Each resource maps to a line inside the file, for example: - -```puppet -postgresql::server::config_entry { 'check_function_bodies': - value => 'off', -} -``` - -##### `ensure` - -Removes an entry if set to 'absent'. Valid values: 'present', 'absent'. - -##### `value` - -Defines the value for the setting. - -#### postgresql::server::db - -Creates a local database, user, and assigns necessary permissions. - -##### `comment` - -Defines a comment to be stored about the database using the PostgreSQL COMMENT command. - -##### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `dbname` - -Sets the name of the database to be created. Defaults to the namevar. - -##### `encoding` - -Overrides the character set during creation of the database. Defaults to the default defined during installation. - -##### `grant` - -Specifies the permissions to grant during creation. Default: `ALL`. - -##### `istemplate` - -Specifies that the database is a template, if set to true. Default: false. - -##### `locale` - -Overrides the locale during creation of the database. Defaults to the default defined during installation. - -##### `owner` - -Sets a user as the owner of the database. Default: $user variable set in `postgresql::server` or `postgresql::globals`. - -##### `password` - -**Required** Sets the password for the created user. - -##### `tablespace` - -Defines the name of the tablespace to allocate the created database to. Default: PostgreSQL default. - -##### `template` - -Specifies the name of the template database from which to build this database. Defaults to `template0`. - -##### `user` - -User to create and assign access to the database upon creation. Mandatory. - -#### postgresql::server::database - -Creates a database with no users and no permissions. - -##### `dbname` - -Sets the name of the database. Defaults to the namevar. - -##### `encoding` - -Overrides the character set during creation of the database. Default: The default defined during installation. - -##### `istemplate` - -Defines the database as a template if set to true. Default: false. - -##### `locale` - -Overrides the locale during creation of the database. The default defined during installation. - -##### `owner` - -Sets name of the database owner. Default: The $user variable set in `postgresql::server` or `postgresql::globals`. - -##### `tablespace` - -Sets tablespace for where to create this database. Default: The defaults defined during PostgreSQL installation. - -##### `template` - -Specifies the name of the template database from which to build this database. Default: `template0`. - -#### postgresql::server::database_grant - -Manages grant-based access privileges for users, wrapping the `postgresql::server::database_grant` for database specific permissions. Consult the [PostgreSQL documentation for `grant`](http://www.postgresql.org/docs/current/static/sql-grant.html) for more information. - -#### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `db` - -Specifies the database to which you are granting access. - -##### `privilege` - -Specifies which privileges to grant. Valid options: `SELECT`, `TEMPORARY`, `TEMP`, `CONNECT`. `ALL` is used as a synonym for `CREATE`, so if you need to add multiple privileges, you can use a space delimited string. - -##### `psql_db` - -Defines the database to execute the grant against. **This should not ordinarily be changed from the default**, which is `postgres`. - -##### `psql_user` - -Specifies the OS user for running `psql`. Default: The default user for the module, usually `postgres`. - -##### `role` - -Specifies the role or user whom you are granting access to. - -#### postgresql::server::extension - -Manages a PostgreSQL extension. - -##### `database` - -Specifies the database on which to activate the extension. - -##### `ensure` - -Specifies whether to activate ('present') or deactivate (absent') the extension. - -#### `extension` - -Specifies the extension to activate. If left blank, uses the name of the resource. - -##### `package_name` - -Specifies a package to install prior to activating the extension. - -##### `package_ensure` - -Overrides default package deletion behavior. By default, the package specified with `package_name` is installed when the extension is activated and removed when the extension is deactivated. To override this behavior, set the `ensure` value for the package. - -#### postgresql::server::grant - -Manages grant-based access privileges for roles. See [PostgreSQL documentation for `grant`](http://www.postgresql.org/docs/current/static/sql-grant.html) for more information. - -##### `db` - -Specifies the database to which you are granting access. - -##### `object_type` - -Specifies the type of object to which you are granting privileges. Valid options: `DATABASE`, `SCHEMA`, `SEQUENCE`, `ALL SEQUENCES IN SCHEMA`, `TABLE` or `ALL TABLES IN SCHEMA`. - -##### `object_name` - -Specifies name of `object_type` to which to grant access. - -##### `port` - -Port to use when connecting. Default: undef, which generally defaults to port 5432 depending on your PostgreSQL packaging. - -##### `privilege` - -Specifies the privilege to grant. Valid options: `ALL`, `ALL PRIVILEGES` or `object_type` dependent string. - -##### `psql_db` - -Specifies the database to execute the grant against. _This should not ordinarily be changed from the default_, which is `postgres`. - -##### `psql_user` - -Sets the OS user to run `psql`. Default: the default user for the module, usually `postgres`. - -##### `role` - -Specifies the role or user whom you are granting access to. - -#### postgresql::server::pg_hba_rule - -Allows you to create an access rule for `pg_hba.conf`. For more details see the [usage example](#create-an-access-rule-for-pghba.conf) and the [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html). - -##### `address` - -Sets a CIDR based address for this rule matching when the type is not 'local'. - -##### `auth_method` - -Provides the method that is used for authentication for the connection that this rule matches. Described further in the PostgreSQL `pg_hba.conf` documentation. - -##### `auth_option` - -For certain `auth_method` settings there are extra options that can be passed. Consult the PostgreSQL `pg_hba.conf` documentation for further details. - -##### `database` - -Sets a comma separated list of databases that this rule matches. - -##### `description` - -Defines a longer description for this rule, if required. This description is placed in the comments above the rule in `pg_hba.conf`. Defaults: `none`. -Specifies a way to uniquely identify this resource, but functionally does nothing. -##### `order` - -Sets an order for placing the rule in `pg_hba.conf`. Default: `150`. - -#### `postgresql_version` - -Manages `pg_hba.conf` without managing the entire PostgreSQL instance. Default: the version set in `postgresql::server`. - -##### `target` - -Provides the target for the rule, and is generally an internal only property. **Use with caution.** - -##### `type` - -Sets the type of rule. Valid options: `local`, `host`, `hostssl` or `hostnossl`. - -##### `user` - -Sets a comma-separated list of users that this rule matches. - - -#### postgresql::server::pg_ident_rule - -Allows you to create user name maps for `pg_ident.conf`. For more details see the [usage example](#create-user-name-maps-for-pgidentconf) above and the [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/auth-username-maps.html). - -##### `database_username` - -Specifies the user name of the database user. The `system_username` is mapped to this user name. - -##### `description` - -Sets a longer description for this rule if required. This description is placed in the comments above the rule in `pg_ident.conf`. Default: `none`. - -##### `map_name` - -Sets the name of the user map that is used to refer to this mapping in `pg_hba.conf`. - -##### `order` - -Defines an order for placing the mapping in `pg_ident.conf`. Default: 150. - -##### `system_username` - -Specifies the operating system user name (the user name used to connect to the database). - -##### `target` - -Provides the target for the rule and is generally an internal only property. **Use with caution.** - -#### postgresql::server::recovery - -Allows you to create the content for `recovery.conf`. For more details see the [usage example](#create-recovery-configuration) and the [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/recovery-config.html). - -Every parameter value is a string set in the template except `recovery_target_inclusive`, `pause_at_recovery_target`, `standby_mode` and `recovery_min_apply_delay`. - -A detailed description of all listed parameters can be found in the [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/recovery-config.html). - -The parameters are grouped into these three sections: - -##### [Archive Recovery Parameters](http://www.postgresql.org/docs/current/static/archive-recovery-settings.html) - -* `restore_command` -* `archive_cleanup_command` -* `recovery_end_command` - -##### [Recovery Target Settings](http://www.postgresql.org/docs/current/static/recovery-target-settings.html) -* `recovery_target_name` -* `recovery_target_time` -* `recovery_target_xid` -* `recovery_target_inclusive` -* `recovery_target` -* `recovery_target_timeline` -* `pause_at_recovery_target` - -##### [Standby Server Settings](http://www.postgresql.org/docs/current/static/standby-settings.html) -* `standby_mode`: Can be specified with the string ('on'/'off'), or by using a Boolean value (true/false). -* `primary_conninfo` -* `primary_slot_name` -* `trigger_file` -* `recovery_min_apply_delay` - -##### `target` -Provides the target for the rule, and is generally an internal only property. **Use with caution.** - -#### postgresql::server::role -Creates a role or user in PostgreSQL. - -##### `connection_limit` -Specifies how many concurrent connections the role can make. Default: `-1`, meaning no limit. - -##### `connect_settings` -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `createdb` -Specifies whether to grant the ability to create new databases with this role. Default: false. - -##### `createrole` -Specifies whether to grant the ability to create new roles with this role. Default: false. - -##### `inherit` -Specifies whether to grant inherit capability for the new role. Default: true. - -##### `login` -Specifies whether to grant login capability for the new role. Default: true. - -##### `password_hash` -Sets the hash to use during password creation. If the password is not already pre-encrypted in a format that PostgreSQL supports, use the `postgresql_password` function to provide an MD5 hash here, for example: - -```puppet -postgresql::server::role { "myusername": -password_hash => postgresql_password('myusername', 'mypassword'), -} -``` - -##### `replication` - -Provides provides replication capabilities for this role if set to true. Default: false. - -##### `superuser` - -Specifies whether to grant super user capability for the new role. Default: false. - -##### `username` - -Defines the username of the role to create. Defaults to the namevar. - -#### postgresql::server::schema - -Creates a schema. - -##### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `db` - -**Required**. Sets the name of the database in which to create this schema. - -##### `owner` - -Sets the default owner of the schema. - -##### `schema` - -Sets the name of the schema. Defaults to the namevar. - -#### postgresql::server::table_grant - -Manages grant-based access privileges for users. Consult the PostgreSQL documentation for `grant` for more information. - -##### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `db` - -Specifies which database the table is in. - -##### `privilege` - -Valid options: `SELECT`, `INSERT`, `UPDATE`, `REFERENCES`. `ALL` is used as a synonym for `CREATE`, so if you need to add multiple privileges, use a space-delimited string. - -##### `psql_db` - -Specifies the database to execute the grant against. This should not ordinarily be changed from the default, which is `postgres`. - -##### `psql_user` - -Specifies the OS user for running `psql`. Defaults to the default user for the module, usually `postgres`. - -##### `role` - -Specifies the role or user to whom you are granting access. - -##### `table` - -Specifies the table to which you are granting access. - - -#### postgresql::server::tablespace - -Creates a tablespace. If necessary, also creates the location and assigns the same permissions as the PostgreSQL server. - -##### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. Default: Connects to the local Postgres instance. - -##### `location` - -Specifies the path to locate this tablespace. - -##### `owner` - -Specifies the default owner of the tablespace. - -##### `spcname` - -Specifies the name of the tablespace. Defaults to the namevar. - -#### postgresql::validate_db_connection - -Validates client connection with a remote PostgreSQL database. - -##### `connect_settings` - -Specifies a hash of environment variables used when connecting to a remote server. This is an alternative to providing individual parameters (database_host, etc.). If provided, the individual parameters take precedence. - -##### `create_db_first` - -Ensures that the database is created before running the test. This only works if your test is local. Default: true. - -##### `database_host` - -Sets the hostname of the database you wish to test. Default: undef, which generally uses the designated local Unix socket. - -##### `database_name` - -Specifies the name of the database you wish to test. Default: 'postgres'. - -##### `database_port` - -Defines the port to use when connecting. Default: undef, which generally defaults to port 5432 depending on your PostgreSQL packaging. - -##### `database_password` - -Specifies the password to connect with. Can be left blank, not recommended. - -##### `database_username` - -Specifies the username to connect with. Default: undef. When using a Unix socket and ident auth, this is the user you are running as. **If the host is remote you must provide a username.** - -##### `run_as` - -Specifies the user to run the `psql` command as. This is important when trying to connect to a database locally using Unix sockets and `ident` authentication. Not needed for remote testing. - -##### `sleep` - -Sets the number of seconds to sleep for before trying again after a failure. - -##### `tries` - -Sets the number of attempts after failure before giving up and failing the resource. - -### Types - -#### postgresql_psql - -Enables Puppet to run psql statements. - -##### `command` - -**Required.** Specifies the SQL command to execute via psql. - -##### `cwd` - -Specifies the working directory under which the psql command should be executed. Default: '/tmp'. - -##### `db` - -Specifies the name of the database to execute the SQL command against. - -##### `environment` - -Specifies any additional environment variables you want to set for a SQL command. Multiple environment variables should be specified as an array. - -##### `name` - -Sets an arbitrary tag for your own reference; the name of the message. This is the -namevar. - -##### `onlyif` - -Sets an optional SQL command to execute prior to the main command. This is generally intended to be used for idempotency, to check for the existence of an object in the database to determine whether or not the main SQL command needs to be executed at all. - -##### `port` - -Specifies the port of the database server to execute the SQL command against. - -##### `psql_group` - -Specifies the system user group account under which the psql command should be executed. Default: 'postgres'. - -##### `psql_path` - -Specifies the path to psql executable. Default: 'psql'. - -##### `psql_user` - -Specifies the system user account under which the psql command should be executed. Default: 'postgres'. - -##### `refreshonly` - -Specifies whether to execute the SQL only if there is a notify or subscribe event. Valid values: true, false. Default: false. - -##### `search_path` - -Defines the schema search path to use when executing the SQL command. - -##### `unless` - -The inverse of `onlyif`. - -#### postgresql_conf - -Allows Puppet to manage `postgresql.conf` parameters. - -##### `name` - -Specifies the PostgreSQL parameter name to manage. This is the namevar. - -##### `target` - -Specifies the path to `postgresql.conf`. Default: '/etc/postgresql.conf'. - -##### `value` - -Specifies the value to set for this parameter. - -#### postgresql_replication_slot - -Allows you to create and destroy replication slots to register warm standby replication on a PostgreSQL master server. - -##### `name` - -Specifies the name of the slot to create. Must be a valid replication slot name. This is the namevar. - -### Functions - -#### postgresql_password - -Generates a PostgreSQL encrypted password, use `postgresql_password`. Call it from the command line and then copy and paste the encrypted password into your manifest: - -```puppet -puppet apply --execute 'notify { "test": message => postgresql_password("username", "password") }' -``` - -Alternatively, you can call this from your production manifests, but the manifests will then contain a clear text version of your passwords. - -#### postgresql_acls_to_resources_hash(acl_array, id, order_offset) - -This internal function converts a list of `pg_hba.conf` based ACLs (passed in as an array of strings) to a format compatible with the `postgresql::pg_hba_rule` resource. - -**This function should only be used internally by the module**. - -## Limitations - -Works with versions of PostgreSQL from 8.1 through 9.5. - -Currently, the postgresql module is tested on the following operating systems: - -* Debian 6.x, 7.x, 8.x. -* CentOS 5.x, 6.x, and 7.x. -* Ubuntu 10.04 and 12.04, 14.04. - -Other systems might be compatible, but are not being actively tested. - -### Apt module support - -While this module supports both 1.x and 2.x versions of the puppetlabs-apt module, it does not support puppetlabs-apt 2.0.0 or 2.0.1. - -### PostGIS support - -PostGIS is currently considered an unsupported feature, as it doesn't work on all platforms correctly. - -### All versions of RHEL/CentOS - -If you have SELinux enabled you must add any custom ports you use to the `postgresql_port_t` context. You can do this as follows: - -``` -semanage port -a -t postgresql_port_t -p tcp $customport -``` - -## Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html). - -### Tests - -There are two types of tests distributed with this module. Unit tests with `rspec-puppet` and system tests using `rspec-system`. - -For unit testing, make sure you have: - -* rake -* bundler - -Install the necessary gems: - -``` -bundle install --path=vendor -``` - -And then run the unit tests: - -``` -bundle exec rake spec -``` - -The unit tests are run in Travis-CI as well. If you want to see the results of your own tests, register the service hook through Travis-CI via the accounts section for your GitHub clone of this project. - -To run the system tests, make sure you also have: - -* Vagrant > 1.2.x -* VirtualBox > 4.2.10 - -Then run the tests using: - -``` -bundle exec rspec spec/acceptance -``` - -To run the tests on different operating systems, see the sets available in `.nodeset.yml` and run the specific set with the following syntax: - -``` -RSPEC_SET=debian-607-x64 bundle exec rspec spec/acceptance -``` - -### Contributors - -View the full list of contributors on [https://github.com/puppetlabs/puppetlabs-postgresql/graphs/contributors](GitHub). diff --git a/vagrant/puppet/modules/postgresql/Rakefile b/vagrant/puppet/modules/postgresql/Rakefile deleted file mode 100644 index 8906d23cd..000000000 --- a/vagrant/puppet/modules/postgresql/Rakefile +++ /dev/null @@ -1,42 +0,0 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppetlabs_spec_helper/rake_tasks' - -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "bundle/**/*", "vendor/**/*"] - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end - - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end - - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) - end - puts nodeset -end diff --git a/vagrant/puppet/modules/postgresql/checksums.json b/vagrant/puppet/modules/postgresql/checksums.json deleted file mode 100644 index 1c88e4ff7..000000000 --- a/vagrant/puppet/modules/postgresql/checksums.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "CHANGELOG.md": "11a5f1a6b8fa1de49830367c6a43294c", - "CONTRIBUTING.md": "b78f71c1104f00538d50ad2775f58e95", - "Gemfile": "413689c7a54fdf220520f2f8e874f70d", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "NOTICE": "7e066b054e0d528cc400e4b1adfb071d", - "README.md": "ff9c158cac82d0484495e940651ef153", - "Rakefile": "3a79b0672ca13fe46284c635227be459", - "files/RPM-GPG-KEY-PGDG": "78b5db170d33f80ad5a47863a7476b22", - "files/validate_postgresql_connection.sh": "625f6b9f027fbae935499443d1bf69f6", - "lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb": "d518a7959b950874820a3b0a7a324488", - "lib/puppet/parser/functions/postgresql_escape.rb": "41a42275ce59d8588f3d4b4918d64392", - "lib/puppet/parser/functions/postgresql_password.rb": "820da02a888ab42357fe9bc2352b1c37", - "lib/puppet/provider/postgresql_conf/parsed.rb": "6d3d15c73db2eb9f632218fa256d024a", - "lib/puppet/provider/postgresql_psql/ruby.rb": "bfb519df4ada462cdb21c5b82d19628f", - "lib/puppet/provider/postgresql_replication_slot/ruby.rb": "dcd93860861c530a12f1233334ea5f17", - "lib/puppet/type/postgresql_conf.rb": "95c73ca169db02aa1128ae3baa2f7399", - "lib/puppet/type/postgresql_psql.rb": "d45a5f688c15b69114996fbe0232664f", - "lib/puppet/type/postgresql_replication_slot.rb": "cd9362cdb569945ca42986d005e88bcb", - "manifests/client.pp": "45131980b230139b39ca168437725f69", - "manifests/globals.pp": "bd191e0503505b768e40b0d2826aa210", - "manifests/lib/devel.pp": "5989d15c43b2543aad8cf872e6a8b2ba", - "manifests/lib/docs.pp": "ec903581401a6629fb29d8dc6fed1a1f", - "manifests/lib/java.pp": "ed639fd6ba8392cf4239cfe02be6ace5", - "manifests/lib/perl.pp": "5213fb4284f041fe28a22d68119f646d", - "manifests/lib/python.pp": "90736f86301c4c6401ec1180c176b616", - "manifests/params.pp": "2f57cc945d8371bc48b1e2e2489602de", - "manifests/repo/apt_postgresql_org.pp": "38ccf7937782621c7af8fa716cee6522", - "manifests/repo/yum_postgresql_org.pp": "999d830dc382be7eca8e4c01b933972c", - "manifests/repo.pp": "7db3bcd168b02373182d9cfbff84279f", - "manifests/server/config.pp": "ea4592687897d5a5f7919264a0ec11ac", - "manifests/server/config_entry.pp": "9ee1ee3c1de2abf12b30e2256fa70c9c", - "manifests/server/contrib.pp": "a0aafd867ca7c932bee14ebf480bfacd", - "manifests/server/database.pp": "4ee718df961ab105a9e7fcddfca2812a", - "manifests/server/database_grant.pp": "ceda31baba15a6189c57c5cff2bf4512", - "manifests/server/db.pp": "ea41e1e51fc00fdb7a9129ecc5279ca3", - "manifests/server/extension.pp": "6d417d3bd69baeb6dec2e3c2b740107f", - "manifests/server/grant.pp": "45a98c1fba114cc23f592ec7e602d133", - "manifests/server/initdb.pp": "5e717e795a471823ed668820678991ca", - "manifests/server/install.pp": "ddd4000b5cee099a3d0ebed79fd458bb", - "manifests/server/passwd.pp": "18f7df76800b37bae8ff7f8c5417fcf9", - "manifests/server/pg_hba_rule.pp": "c2e2130a82f75b75ba409fc33bb70d1a", - "manifests/server/pg_ident_rule.pp": "0fa70e2d42d17c59f41bd3351d5d96fb", - "manifests/server/plperl.pp": "189c47d04158440874dc136ca2b3fd7a", - "manifests/server/plpython.pp": "4a1f44cd2a8019e42cb8e05075a1751c", - "manifests/server/postgis.pp": "6ac7fbd262907bb1303aa29970e908eb", - "manifests/server/recovery.pp": "7d2cc6a96a5a5982dbb375ca7d47ac81", - "manifests/server/reload.pp": "218ac61018f7fab71f250284c4b879d0", - "manifests/server/role.pp": "a1d62e467209c2785ec69b0d9b415294", - "manifests/server/schema.pp": "e76ae47f638d048e8f4e4a3d4663c529", - "manifests/server/service.pp": "86b88df8df316c5305a7024f8b5c83a1", - "manifests/server/table_grant.pp": "e2abea574f7eb295fc56313f4896a9fc", - "manifests/server/tablespace.pp": "6fe5e4ef73f901861dcf031fac654696", - "manifests/server.pp": "d4bfce7d493999972da24b14d834bae7", - "manifests/validate_db_connection.pp": "23d34c9ebc00b6329cca495116c7123b", - "metadata.json": "60d118f14fb392328153281d841c7186", - "spec/acceptance/00-utf8_encoding_spec.rb": "ac20cfbaf4efce7c8b499d32bdec47d7", - "spec/acceptance/alternative_port_spec.rb": "7f883762a8e17941a96371e96d12c06b", - "spec/acceptance/db_spec.rb": "955a6df508d04e06d0be58e3c71a4140", - "spec/acceptance/default_parameters_spec.rb": "82bb1fd9e71f6084b71ca34ba73ff05b", - "spec/acceptance/nodesets/centos-7-x64.yml": "349128a7cfa9a953fb9af67cad52442a", - "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", - "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808", - "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", - "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", - "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/acceptance/postgresql_psql_spec.rb": "5d70b4c3e35f1b5fc89a768498f74987", - "spec/acceptance/remote_access_spec.rb": "4f2261af3b20d3556c50d3af2daef7d1", - "spec/acceptance/server/recovery_spec.rb": "04c87359a23d3ac297ccf49127111ac1", - "spec/acceptance/server/schema_spec.rb": "988aa84ae180a4508897abf6a7fdb39e", - "spec/acceptance/z_alternative_pgdata_spec.rb": "cbff072f96be283ab1607febd7c1b7ef", - "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "411e4c6f836cf8f231f8f76a0f4b46eb", - "spec/spec_helper_local.rb": "3a50ad073f49d04a019212652a67c6ba", - "spec/unit/classes/client_spec.rb": "782d49105bf582bb61364790d55d4080", - "spec/unit/classes/globals_spec.rb": "3f03233518aa7978e511eff739ccf13e", - "spec/unit/classes/lib/devel_spec.rb": "149e26d7cff5198b73de081cc36b2937", - "spec/unit/classes/lib/java_spec.rb": "2d8bd73fe651e9e62d0bba49abef292c", - "spec/unit/classes/lib/perl_spec.rb": "748a923db31aa42b3ee2fa5ac534d0d6", - "spec/unit/classes/lib/pgdocs_spec.rb": "edd7c5b7fee837d8975c6a1b11954095", - "spec/unit/classes/lib/python_spec.rb": "085a1fd6809298d8774b8fd84157908d", - "spec/unit/classes/params_spec.rb": "af9c9224fb32b0e64bf575275167bebf", - "spec/unit/classes/repo_spec.rb": "cd1385198525063f7444fb7ef57b08cc", - "spec/unit/classes/server/config_spec.rb": "9ef18899ce8aa81ac6e0dfb15acf3f25", - "spec/unit/classes/server/contrib_spec.rb": "a0334495869618a6b75858211fec8cc8", - "spec/unit/classes/server/initdb_spec.rb": "f0300d18fc827eea9ea22b3a2e101f3f", - "spec/unit/classes/server/plperl_spec.rb": "5fb32ffacadf95aa84646e32017a30f4", - "spec/unit/classes/server/plpython_spec.rb": "692b8fa96db2dbdf985e11c8d3e187cf", - "spec/unit/classes/server/postgis_spec.rb": "3975f38629148de15fd2cd87385f8e2e", - "spec/unit/classes/server_spec.rb": "9b723eddc6547d289dbe15244422e851", - "spec/unit/defines/server/config_entry_spec.rb": "a666efb4906edaf700010b98a3a3c79b", - "spec/unit/defines/server/database_grant_spec.rb": "52e7ba3370d10b7c23a7b29fffe1ff33", - "spec/unit/defines/server/database_spec.rb": "25d51b2518ce7cd8d28a9683c3e43f85", - "spec/unit/defines/server/db_spec.rb": "33b0f3152a559f701acf1b1ee5485acd", - "spec/unit/defines/server/extension_spec.rb": "7e15125802b820edf7bd2fdb798a81cf", - "spec/unit/defines/server/grant_spec.rb": "b383439d57032d38c63914cff2e6e3d0", - "spec/unit/defines/server/pg_hba_rule_spec.rb": "fd1b947dfe0df3b81f1403928064c22f", - "spec/unit/defines/server/pg_ident_rule_spec.rb": "2e32da6f0f107359fc5ab5727812f853", - "spec/unit/defines/server/recovery_spec.rb": "86fba4b913ebeef06be8e63c52e72044", - "spec/unit/defines/server/role_spec.rb": "c74c095a6b016fda017039ee9226e0a4", - "spec/unit/defines/server/schema_spec.rb": "d42e5fdee9427032df915f599a0f8de2", - "spec/unit/defines/server/table_grant_spec.rb": "21e375467a0635194d0f2e5effdcf22a", - "spec/unit/defines/server/tablespace_spec.rb": "ac4b95389354e2b489547f3a95441b61", - "spec/unit/defines/validate_db_connection_spec.rb": "066c39f36fd5e6af8d36d34c8dd78b51", - "spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb": "ba576b0f385aa44fa352df6d5812f4ae", - "spec/unit/functions/postgresql_escape_spec.rb": "ed7d1a0f8feee7d7147c35b84b27e940", - "spec/unit/functions/postgresql_password_spec.rb": "8ca30e0a155e27dd3c161cea558a97eb", - "spec/unit/provider/postgresql_conf/parsed_spec.rb": "535a7a2f7c31d433e3540da4dd938fde", - "spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb": "f08cded8801a0a3d866515f7ec58a382", - "spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb": "641f5e82f4b92c2de28b361cbd3361f2", - "spec/unit/puppet/type/postgresql_psql_spec.rb": "5ad61a59e91be0035a794842e33bf6f2", - "spec/unit/puppet/type/postgresql_replication_slot_spec.rb": "fcd735f400d0e981213b2ecb7cbcf0b0", - "spec/unit/type/postgresql_conf_spec.rb": "069ce03012044d4864d7e81b60f022e0", - "templates/pg_hba_rule.conf": "13b46eecdfd359eddff71fa485ef2f54", - "templates/pg_ident_rule.conf": "444c85172fd44262344588e83ebb2515", - "templates/recovery.conf": "ea5dc47b65f7b9596244f7e9e48085ba", - "templates/systemd-override.erb": "795a9e83abbb453e44c4e631a7c26ad6" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/postgresql/files/RPM-GPG-KEY-PGDG b/vagrant/puppet/modules/postgresql/files/RPM-GPG-KEY-PGDG deleted file mode 100644 index 065274e0d..000000000 --- a/vagrant/puppet/modules/postgresql/files/RPM-GPG-KEY-PGDG +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.7 (GNU/Linux) - -mQGiBEeD8koRBACC1VBRsUwGr9gxFFRho9kZpdRUjBJoPhkeOTvp9LzkdAQMFngr -BFi6N0ov1kCX7LLwBmDG+JPR7N+XcH9YR1coSHpLVg+JNy2kFDd4zAyWxJafjZ3a -9zFg9Yx+0va1BJ2t4zVcmKS4aOfbgQ5KwIOWUujalQW5Y+Fw39Gn86qjbwCg5dIo -tkM0l19h2sx50D027pV5aPsD/2c9pfcFTbMhB0CcKS836GH1qY+NCAdUwPs646ee -Ex/k9Uy4qMwhl3HuCGGGa+N6Plyon7V0TzZuRGp/1742dE8IO+I/KLy2L1d1Fxrn -XOTBZd8qe6nBwh12OMcKrsPBVBxn+iSkaG3ULsgOtx+HHLfa1/p22L5+GzGdxizr -peBuA/90cCp+lYcEwdYaRoFVR501yDOTmmzBc1DrsyWP79QMEGzMqa393G0VnqXt -L4pGmunq66Agw2EhPcIt3pDYiCmEt/obdVtSJH6BtmSDB/zYhbE8u3vLP3jfFDa9 -KXxgtYj0NvuUVoRmxSKm8jtfmj1L7zoKNz3jl+Ba3L0WxIv4+bRBUG9zdGdyZVNR -TCBSUE0gQnVpbGRpbmcgUHJvamVjdCA8cGdzcWxycG1zLWhhY2tlcnNAcGdmb3Vu -ZHJ5Lm9yZz6IYAQTEQIAIAUCR4PySgIbIwYLCQgHAwIEFQIIAwQWAgMBAh4BAheA -AAoJEB8W0uFELfD4jnkAoMqd6ZwwsgYHZ3hP9vt+DJt1uDW7AKDbRwP8ESKFhwdJ -8m91RPBeJW/tMLkCDQRHg/JKEAgA64+ZXgcERPYfZYo4p+yMTJAAa9aqnE3U4Ni6 -ZMB57GPuEy8NfbNya+HiftO8hoozmJdcI6XFyRBCDUVCdZ8SE+PJdOx2FFqZVIu6 -dKnr8ykhgLpNNEFDG3boK9UfLj/5lYQ3Y550Iym1QKOgyrJYeAp6sZ+Nx2PavsP3 -nMFCSD67BqAbcLCVQN7a2dAUXfEbfXJjPHXTbo1/kxtzE+KCRTLdXEbSEe3nHO04 -K/EgTBjeBUOxnciH5RylJ2oGy/v4xr9ed7R1jJtshsDKMdWApwoLlCBJ63jg/4T/ -z/OtXmu4AvmWaJxaTl7fPf2GqSqqb6jLCrQAH7AIhXr9V0zPZwADBQgAlpptNQHl -u7euIdIujFwwcxyQGfee6BG+3zaNSEHMVQMuc6bxuvYmgM9r7aki/b0YMfjJBk8v -OJ3Eh1vDH/woJi2iJ13vQ21ot+1JP3fMd6NPR8/qEeDnmVXu7QAtlkmSKI9Rdnjz -FFSUJrQPHnKsH4V4uvAM+njwYD+VFiwlBPTKNeL8cdBb4tPN2cdVJzoAp57wkZAN -VA2tKxNsTJKBi8wukaLWX8+yPHiWCNWItvyB4WCEp/rZKG4A868NM5sZQMAabpLd -l4fTiGu68OYgK9qUPZvhEAL2C1jPDVHPkLm+ZsD+90Pe66w9vB00cxXuHLzm8Pad -GaCXCY8h3xi6VIhJBBgRAgAJBQJHg/JKAhsMAAoJEB8W0uFELfD4K4cAoJ4yug8y -1U0cZEiF5W25HDzMTtaDAKCaM1m3Cbd+AZ0NGWNg/VvIX9MsPA== -=au6K ------END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/puppet/modules/postgresql/files/validate_postgresql_connection.sh b/vagrant/puppet/modules/postgresql/files/validate_postgresql_connection.sh deleted file mode 100644 index 2b3d62944..000000000 --- a/vagrant/puppet/modules/postgresql/files/validate_postgresql_connection.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# usage is: validate_db_connection 2 50 psql - -SLEEP=$1 -TRIES=$2 -PSQL=$3 - -STATE=1 - -c=1 - -while [ $c -le $TRIES ] -do - echo $c - if [ $c -gt 1 ] - then - echo 'sleeping' - sleep $SLEEP - fi - - /bin/echo "SELECT 1" | $PSQL - STATE=$? - - if [ $STATE -eq 0 ] - then - exit 0 - fi -$c++ -done - -echo 'Unable to connect to postgresql' - -exit 1 diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb b/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb deleted file mode 100644 index 7fa785486..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_acls_to_resources_hash.rb +++ /dev/null @@ -1,76 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:postgresql_acls_to_resources_hash, :type => :rvalue, :doc => <<-EOS - This internal function translates the ipv(4|6)acls format into a resource - suitable for create_resources. It is not intended to be used outside of the - postgresql internal classes/defined resources. - - This function accepts an array of strings that are pg_hba.conf rules. It - will return a hash that can be fed into create_resources to create multiple - individual pg_hba_rule resources. - - The second parameter is an identifier that will be included in the namevar - to provide uniqueness. It must be a string. - - The third parameter is an order offset, so you can start the order at an - arbitrary starting point. - EOS - ) do |args| - func_name = "postgresql_acls_to_resources_hash()" - - raise(Puppet::ParseError, "#{func_name}: Wrong number of arguments " + - "given (#{args.size} for 3)") if args.size != 3 - - acls = args[0] - raise(Puppet::ParseError, "#{func_name}: first argument must be an array") \ - unless acls.instance_of? Array - - id = args[1] - raise(Puppet::ParseError, "#{func_name}: second argument must be a string") \ - unless id.instance_of? String - - offset = args[2].to_i - raise(Puppet::ParseError, "#{func_name}: third argument must be a number") \ - unless offset.instance_of? Fixnum - - resources = {} - acls.each do |acl| - index = acls.index(acl) - - parts = acl.split - - raise(Puppet::ParseError, "#{func_name}: acl line #{index} does not " + - "have enough parts") unless parts.length >= 4 - - resource = { - 'type' => parts[0], - 'database' => parts[1], - 'user' => parts[2], - 'order' => format('%03d', offset + index), - } - if parts[0] == 'local' then - resource['auth_method'] = parts[3] - if parts.length > 4 then - resource['auth_option'] = parts.last(parts.length - 4).join(" ") - end - else - if parts[4] =~ /^\d/ - resource['address'] = parts[3] + ' ' + parts[4] - resource['auth_method'] = parts[5] - - if parts.length > 6 then - resource['auth_option'] = parts.last(parts.length - 6).join(" ") - end - else - resource['address'] = parts[3] - resource['auth_method'] = parts[4] - - if parts.length > 5 then - resource['auth_option'] = parts.last(parts.length - 5).join(" ") - end - end - end - resources["postgresql class generated rule #{id} #{index}"] = resource - end - resources - end -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_escape.rb b/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_escape.rb deleted file mode 100644 index 1ec11b857..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_escape.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'digest/md5' - -module Puppet::Parser::Functions - newfunction(:postgresql_escape, :type => :rvalue, :doc => <<-EOS - Safely escapes a string using $$ using a random tag which should be consistent - EOS - ) do |args| - - raise(Puppet::ParseError, "postgresql_escape(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - - password = args[0] - - if password !~ /\$\$/ and password[-1] != '$' - retval = "$$#{password}$$" - else - escape = Digest::MD5.hexdigest(password)[0..5].gsub(/\d/,'') - until password !~ /#{escape}/ - escape = Digest::MD5.hexdigest(escape)[0..5].gsub(/\d/,'') - end - retval = "$#{escape}$#{password}$#{escape}$" - end - retval - end -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_password.rb b/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_password.rb deleted file mode 100644 index 0689e0e5b..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/parser/functions/postgresql_password.rb +++ /dev/null @@ -1,18 +0,0 @@ -# hash a string as mysql's "PASSWORD()" function would do it -require 'digest/md5' - -module Puppet::Parser::Functions - newfunction(:postgresql_password, :type => :rvalue, :doc => <<-EOS - Returns the postgresql password hash from the clear text username / password. - EOS - ) do |args| - - raise(Puppet::ParseError, "postgresql_password(): Wrong number of arguments " + - "given (#{args.size} for 2)") if args.size != 2 - - username = args[0] - password = args[1] - - 'md5' + Digest::MD5.hexdigest(password + username) - end -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_conf/parsed.rb b/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_conf/parsed.rb deleted file mode 100644 index 88bd303f3..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_conf/parsed.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'puppet/provider/parsedfile' - -Puppet::Type.type(:postgresql_conf).provide( - :parsed, - :parent => Puppet::Provider::ParsedFile, - :default_target => '/etc/postgresql.conf', - :filetype => :flat -) do - desc "Set key/values in postgresql.conf." - - text_line :comment, :match => /^\s*#/ - text_line :blank, :match => /^\s*$/ - - record_line :parsed, - :fields => %w{name value comment}, - :optional => %w{comment}, - :match => /^\s*([\w\.]+)\s*=?\s*(.*?)(?:\s*#\s*(.*))?\s*$/, - :to_line => proc { |h| - - # simple string and numeric values don't need to be enclosed in quotes - if h[:value].is_a?(Numeric) - val = h[:value].to_s - else - val = h[:value] - end - dontneedquote = val.match(/^(\d+.?\d+|\w+)$/) - dontneedequal = h[:name].match(/^(include|include_if_exists)$/i) - - str = h[:name].downcase # normalize case - str += dontneedequal ? ' ' : ' = ' - str += "'" unless dontneedquote && !dontneedequal - str += val - str += "'" unless dontneedquote && !dontneedequal - str += " # #{h[:comment]}" unless (h[:comment].nil? or h[:comment] == :absent) - str - }, - :post_parse => proc { |h| - h[:name].downcase! # normalize case - h[:value].gsub!(/(^'|'$)/, '') # strip out quotes - } - -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb b/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb deleted file mode 100644 index 166c8bc28..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb +++ /dev/null @@ -1,80 +0,0 @@ -Puppet::Type.type(:postgresql_psql).provide(:ruby) do - - def run_unless_sql_command(sql) - # for the 'unless' queries, we wrap the user's query in a 'SELECT COUNT', - # which makes it easier to parse and process the output. - run_sql_command('SELECT COUNT(*) FROM (' << sql << ') count') - end - - def run_sql_command(sql) - if resource[:search_path] - sql = "set search_path to #{Array(resource[:search_path]).join(',')}; #{sql}" - end - - command = [resource[:psql_path]] - command.push("-d", resource[:db]) if resource[:db] - command.push("-p", resource[:port]) if resource[:port] - command.push("-t", "-c", '"' + sql.gsub('"', '\"') + '"') - - environment = get_environment - - if resource[:cwd] - Dir.chdir resource[:cwd] do - run_command(command, resource[:psql_user], resource[:psql_group], environment) - end - else - run_command(command, resource[:psql_user], resource[:psql_group], environment) - end - end - - private - - def get_environment - environment = (resource[:connect_settings] || {}).dup - if envlist = resource[:environment] - envlist = [envlist] unless envlist.is_a? Array - envlist.each do |setting| - if setting =~ /^(\w+)=((.|\n)+)$/ - env_name = $1 - value = $2 - if environment.include?(env_name) || environment.include?(env_name.to_sym) - if env_name == 'NEWPGPASSWD' - warning "Overriding environment setting '#{env_name}' with '****'" - else - warning "Overriding environment setting '#{env_name}' with '#{value}'" - end - end - environment[env_name] = value - else - warning "Cannot understand environment setting #{setting.inspect}" - end - end - end - return environment - end - - def run_command(command, user, group, environment) - command = command.join ' ' - if Puppet::PUPPETVERSION.to_f < 3.0 - require 'puppet/util/execution' - Puppet::Util::Execution.withenv environment do - Puppet::Util::SUIDManager.run_and_capture(command, user, group) - end - elsif Puppet::PUPPETVERSION.to_f < 3.4 - Puppet::Util.withenv environment do - Puppet::Util::SUIDManager.run_and_capture(command, user, group) - end - else - output = Puppet::Util::Execution.execute(command, { - :uid => user, - :gid => group, - :failonfail => false, - :combine => true, - :override_locale => true, - :custom_environment => environment, - }) - [output, $CHILD_STATUS.dup] - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_replication_slot/ruby.rb b/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_replication_slot/ruby.rb deleted file mode 100644 index cc49f7b4c..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/provider/postgresql_replication_slot/ruby.rb +++ /dev/null @@ -1,68 +0,0 @@ -Puppet::Type.type(:postgresql_replication_slot).provide(:ruby) do - # For confinement - commands :psql => 'psql' - - def self.instances - run_sql_command('SELECT * FROM pg_replication_slots;')[0].split("\n").select { |l| l =~ /\|/ }.map do |l| - name, *others = l.strip.split(/\s+\|\s+/) - new({ - :name => name, - :ensure => :present, - }) - end - end - - def self.prefetch(resources) - instances.each do |i| - if slot = resources[i.name] - slot.provider = i - end - end - end - - def exists? - @property_hash[:ensure] == :present - end - - def create - output = self.class.run_sql_command("SELECT * FROM pg_create_physical_replication_slot('#{resource[:name]}');") - if output[1].success? - @property_hash[:ensure] = :present - else - raise Puppet::Error, "Failed to create replication slot #{resource[:name]}:\n#{output[0]}" - end - end - - def destroy - output = self.class.run_sql_command("SELECT pg_drop_replication_slot('#{resource[:name]}');") - if output[1].success? - @property_hash[:ensure] = :absent - else - raise Puppet::Error, "Failed to destroy replication slot #{resource[:name]}:\n#{output[0]}" - end - end - - private - - def self.run_sql_command(sql) - command = ['psql', '-t', '-c', sql] - - self.run_command(command, 'postgres', 'postgres') - end - - def self.run_command(command, user, group) - if Puppet::PUPPETVERSION.to_f < 3.4 - Puppet::Util::SUIDManager.run_and_capture(command, user, group) - else - output = Puppet::Util::Execution.execute(command, { - :uid => user, - :gid => group, - :failonfail => false, - :combine => true, - :override_locale => true, - :custom_environment => {} - }) - [output, $CHILD_STATUS.dup] - end - end -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_conf.rb b/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_conf.rb deleted file mode 100644 index 6dbaaee36..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_conf.rb +++ /dev/null @@ -1,29 +0,0 @@ -Puppet::Type.newtype(:postgresql_conf) do - - @doc = "This type allows puppet to manage postgresql.conf parameters." - - ensurable - - newparam(:name) do - desc "The postgresql parameter name to manage." - isnamevar - - newvalues(/^[\w\.]+$/) - end - - newproperty(:value) do - desc "The value to set for this parameter." - end - - newproperty(:target) do - desc "The path to postgresql.conf" - defaultto { - if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile) - @resource.class.defaultprovider.default_target - else - nil - end - } - end - -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_psql.rb b/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_psql.rb deleted file mode 100644 index 5b2702c2e..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_psql.rb +++ /dev/null @@ -1,135 +0,0 @@ -Puppet::Type.newtype(:postgresql_psql) do - - newparam(:name) do - desc "An arbitrary tag for your own reference; the name of the message." - isnamevar - end - - newproperty(:command) do - desc 'The SQL command to execute via psql.' - - defaultto { @resource[:name] } - - # If needing to run the SQL command, return a fake value that will trigger - # a sync, else return the expected SQL command so no sync takes place - def retrieve - if @resource.should_run_sql - return :notrun - else - return self.should - end - end - - def sync - output, status = provider.run_sql_command(value) - self.fail("Error executing SQL; psql returned #{status}: '#{output}'") unless status == 0 - end - end - - newparam(:unless) do - desc "An optional SQL command to execute prior to the main :command; " + - "this is generally intended to be used for idempotency, to check " + - "for the existence of an object in the database to determine whether " + - "or not the main SQL command needs to be executed at all." - - # Return true if a matching row is found - def matches(value) - output, status = provider.run_unless_sql_command(value) - self.fail("Error evaluating 'unless' clause, returned #{status}: '#{output}'") unless status == 0 - - result_count = output.strip.to_i - self.debug("Found #{result_count} row(s) executing 'unless' clause") - result_count > 0 - end - end - - newparam(:onlyif) do - desc "An optional SQL command to execute prior to the main :command; " + - "this is generally intended to be used for idempotency, to check " + - "for the existence of an object in the database to determine whether " + - "or not the main SQL command needs to be executed at all." - - # Return true if a matching row is found - def matches(value) - output, status = provider.run_unless_sql_command(value) - status = output.exitcode if status.nil? - - self.fail("Error evaluating 'onlyif' clause, returned #{status}: '#{output}'") unless status == 0 - - result_count = output.strip.to_i - self.debug("Found #{result_count} row(s) executing 'onlyif' clause") - result_count > 0 - end - end - - newparam(:connect_settings) do - desc "Connection settings that will be used when connecting to postgres" - end - - newparam(:db) do - desc "The name of the database to execute the SQL command against, this overrides any PGDATABASE value in connect_settings" - end - - newparam(:port) do - desc "The port of the database server to execute the SQL command against, this overrides any PGPORT value in connect_settings." - end - - newparam(:search_path) do - desc "The schema search path to use when executing the SQL command" - end - - newparam(:psql_path) do - desc "The path to psql executable." - defaultto("psql") - end - - newparam(:psql_user) do - desc "The system user account under which the psql command should be executed." - defaultto("postgres") - end - - newparam(:psql_group) do - desc "The system user group account under which the psql command should be executed." - defaultto("postgres") - end - - newparam(:cwd, :parent => Puppet::Parameter::Path) do - desc "The working directory under which the psql command should be executed." - defaultto("/tmp") - end - - newparam(:environment) do - desc "Any additional environment variables you want to set for a - SQL command. Multiple environment variables should be - specified as an array." - - validate do |values| - Array(values).each do |value| - unless value =~ /\w+=/ - raise ArgumentError, "Invalid environment setting '#{value}'" - end - end - end - end - - newparam(:refreshonly, :boolean => true) do - desc "If 'true', then the SQL will only be executed via a notify/subscribe event." - - defaultto(:false) - newvalues(:true, :false) - end - - def should_run_sql(refreshing = false) - onlyif_param = @parameters[:onlyif] - unless_param = @parameters[:unless] - return false if !onlyif_param.nil? && !onlyif_param.value.nil? && !onlyif_param.matches(onlyif_param.value) - return false if !unless_param.nil? && !unless_param.value.nil? && unless_param.matches(unless_param.value) - return false if !refreshing && @parameters[:refreshonly].value == :true - true - end - - def refresh - self.property(:command).sync if self.should_run_sql(true) - end - -end diff --git a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_replication_slot.rb b/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_replication_slot.rb deleted file mode 100644 index b5b317cd9..000000000 --- a/vagrant/puppet/modules/postgresql/lib/puppet/type/postgresql_replication_slot.rb +++ /dev/null @@ -1,16 +0,0 @@ -Puppet::Type.newtype(:postgresql_replication_slot) do - @doc = "Manages Postgresql replication slots. - -This type allows to create and destroy replication slots -to register warm standby replication on a Postgresql -master server. -" - - ensurable - - newparam(:name) do - desc "The name of the slot to create. Must be a valid replication slot name." - isnamevar - newvalues /^[a-z0-9_]+$/ - end -end diff --git a/vagrant/puppet/modules/postgresql/manifests/client.pp b/vagrant/puppet/modules/postgresql/manifests/client.pp deleted file mode 100644 index 8cc6230ac..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/client.pp +++ /dev/null @@ -1,25 +0,0 @@ -# Install client cli tool. See README.md for more details. -class postgresql::client ( - $file_ensure = 'file', - $validcon_script_path = $postgresql::params::validcon_script_path, - $package_name = $postgresql::params::client_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - validate_absolute_path($validcon_script_path) - validate_string($package_name) - - package { 'postgresql-client': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - file { $validcon_script_path: - ensure => $file_ensure, - source => 'puppet:///modules/postgresql/validate_postgresql_connection.sh', - owner => 0, - group => 0, - mode => '0755', - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/globals.pp b/vagrant/puppet/modules/postgresql/manifests/globals.pp deleted file mode 100644 index a56f95ff0..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/globals.pp +++ /dev/null @@ -1,154 +0,0 @@ -# Class for setting cross-class global overrides. See README.md for more -# details. -class postgresql::globals ( - $client_package_name = undef, - $server_package_name = undef, - $contrib_package_name = undef, - $devel_package_name = undef, - $java_package_name = undef, - $docs_package_name = undef, - $perl_package_name = undef, - $plperl_package_name = undef, - $plpython_package_name = undef, - $python_package_name = undef, - $postgis_package_name = undef, - - $service_name = undef, - $service_provider = undef, - $service_status = undef, - $default_database = undef, - - $validcon_script_path = undef, - - $initdb_path = undef, - $createdb_path = undef, - $psql_path = undef, - $pg_hba_conf_path = undef, - $pg_ident_conf_path = undef, - $postgresql_conf_path = undef, - $recovery_conf_path = undef, - $default_connect_settings = {}, - - $pg_hba_conf_defaults = undef, - - $datadir = undef, - $confdir = undef, - $bindir = undef, - $xlogdir = undef, - $logdir = undef, - $log_line_prefix = undef, - - $user = undef, - $group = undef, - - $version = undef, - $postgis_version = undef, - $repo_proxy = undef, - - $needs_initdb = undef, - - $encoding = undef, - $locale = undef, - - $manage_pg_hba_conf = undef, - $manage_pg_ident_conf = undef, - $manage_recovery_conf = undef, - - $manage_package_repo = undef, -) { - # We are determining this here, because it is needed by the package repo - # class. - $default_version = $::osfamily ? { - /^(RedHat|Linux)/ => $::operatingsystem ? { - 'Fedora' => $::operatingsystemrelease ? { - /^(24)$/ => '9.5', - /^(22|23)$/ => '9.4', - /^(21)$/ => '9.3', - /^(18|19|20)$/ => '9.2', - /^(17)$/ => '9.1', - default => undef, - }, - 'Amazon' => '9.2', - default => $::operatingsystemrelease ? { - /^7\./ => '9.2', - /^6\./ => '8.4', - /^5\./ => '8.1', - default => undef, - }, - default => $::operatingsystemrelease ? { - /^7\./ => '9.2', - /^6\./ => '8.4', - /^5\./ => '8.1', - default => undef, - }, - }, - 'Debian' => $::operatingsystem ? { - 'Debian' => $::operatingsystemrelease ? { - /^6\./ => '8.4', - /^(wheezy|7\.)/ => '9.1', - /^(jessie|8\.)/ => '9.4', - default => undef, - }, - 'Ubuntu' => $::operatingsystemrelease ? { - /^(10.04|10.10|11.04)$/ => '8.4', - /^(11.10|12.04|12.10|13.04|13.10)$/ => '9.1', - /^(14.04)$/ => '9.3', - /^(14.10|15.04|15.10)$/ => '9.4', - /^(16.04)$/ => '9.5', - default => undef, - }, - default => undef, - }, - 'Archlinux' => $::operatingsystem ? { - /Archlinux/ => '9.2', - default => '9.2', - }, - 'FreeBSD' => '93', - 'OpenBSD' => $::operatingsystemrelease ? { - /5\.6/ => '9.3', - /5\.[7-9]/ => '9.4', - /6\.[0-9]/ => '9.5', - }, - 'Suse' => $::operatingsystem ? { - 'SLES' => $::operatingsystemrelease ? { - /11\.[0-4]/ => '91', - default => '93', - }, - 'OpenSuSE' => $::operatingsystemrelease ? { - '13.2' => '93', - }, - default => undef, - }, - default => undef, - } - $globals_version = pick($version, $default_version, 'unknown') - if($globals_version == 'unknown') { - fail('No preferred version defined or automatically detected.') - } - - $default_postgis_version = $globals_version ? { - '8.1' => '1.3.6', - '8.4' => '1.5', - '9.0' => '1.5', - '9.1' => '1.5', - '91' => '1.5', - '9.2' => '2.0', - '9.3' => '2.1', - '93' => '2.1', - '9.4' => '2.1', - '9.5' => '2.2', - default => undef, - } - $globals_postgis_version = $postgis_version ? { - undef => $default_postgis_version, - default => $postgis_version, - } - - # Setup of the repo only makes sense globally, so we are doing this here. - if($manage_package_repo) { - class { 'postgresql::repo': - version => $globals_version, - proxy => $repo_proxy, - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/lib/devel.pp b/vagrant/puppet/modules/postgresql/manifests/lib/devel.pp deleted file mode 100644 index 5f1ad1ccb..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/lib/devel.pp +++ /dev/null @@ -1,26 +0,0 @@ -# This class installs postgresql development libraries. See README.md for more -# details. -class postgresql::lib::devel( - $package_name = $postgresql::params::devel_package_name, - $package_ensure = 'present', - $link_pg_config = $postgresql::params::link_pg_config -) inherits postgresql::params { - - validate_string($package_name) - - package { 'postgresql-devel': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - if $link_pg_config { - if ( $postgresql::params::bindir != '/usr/bin' and $postgresql::params::bindir != '/usr/local/bin') { - file { '/usr/bin/pg_config': - ensure => link, - target => "${postgresql::params::bindir}/pg_config", - } - } - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/lib/docs.pp b/vagrant/puppet/modules/postgresql/manifests/lib/docs.pp deleted file mode 100644 index 55825d157..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/lib/docs.pp +++ /dev/null @@ -1,16 +0,0 @@ -# This class installs the postgresql-docs See README.md for more -# details. -class postgresql::lib::docs ( - $package_name = $postgresql::params::docs_package_name, - $package_ensure = 'present', -) inherits postgresql::params { - - validate_string($package_name) - - package { 'postgresql-docs': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/lib/java.pp b/vagrant/puppet/modules/postgresql/manifests/lib/java.pp deleted file mode 100644 index 0a2d45f79..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/lib/java.pp +++ /dev/null @@ -1,16 +0,0 @@ -# This class installs the postgresql jdbc connector. See README.md for more -# details. -class postgresql::lib::java ( - $package_name = $postgresql::params::java_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - - validate_string($package_name) - - package { 'postgresql-jdbc': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/lib/perl.pp b/vagrant/puppet/modules/postgresql/manifests/lib/perl.pp deleted file mode 100644 index 6ed285312..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/lib/perl.pp +++ /dev/null @@ -1,13 +0,0 @@ -# This class installs the perl libs for postgresql. See README.md for more -# details. -class postgresql::lib::perl( - $package_name = $postgresql::params::perl_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - - package { 'perl-DBD-Pg': - ensure => $package_ensure, - name => $package_name, - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/lib/python.pp b/vagrant/puppet/modules/postgresql/manifests/lib/python.pp deleted file mode 100644 index bfe058548..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/lib/python.pp +++ /dev/null @@ -1,13 +0,0 @@ -# This class installs the python libs for postgresql. See README.md for more -# details. -class postgresql::lib::python( - $package_name = $postgresql::params::python_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - - package { 'python-psycopg2': - ensure => $package_ensure, - name => $package_name, - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/params.pp b/vagrant/puppet/modules/postgresql/manifests/params.pp deleted file mode 100644 index 60331f82d..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/params.pp +++ /dev/null @@ -1,273 +0,0 @@ -# PRIVATE CLASS: do not use directly -class postgresql::params inherits postgresql::globals { - $version = $postgresql::globals::globals_version - $postgis_version = $postgresql::globals::globals_postgis_version - $listen_addresses = 'localhost' - $port = 5432 - $log_line_prefix = '%t ' - $ip_mask_deny_postgres_user = '0.0.0.0/0' - $ip_mask_allow_all_users = '127.0.0.1/32' - $ipv4acls = [] - $ipv6acls = [] - $encoding = $postgresql::globals::encoding - $locale = $postgresql::globals::locale - $service_ensure = 'running' - $service_enable = true - $service_manage = true - $service_restart_on_change = true - $service_provider = $postgresql::globals::service_provider - $manage_pg_hba_conf = pick($manage_pg_hba_conf, true) - $manage_pg_ident_conf = pick($manage_pg_ident_conf, true) - $manage_recovery_conf = pick($manage_recovery_conf, false) - $package_ensure = 'present' - - # Amazon Linux's OS Family is 'Linux', operating system 'Amazon'. - case $::osfamily { - 'RedHat', 'Linux': { - $link_pg_config = true - $user = pick($user, 'postgres') - $group = pick($group, 'postgres') - $needs_initdb = pick($needs_initdb, true) - $version_parts = split($version, '[.]') - $package_version = "${version_parts[0]}${version_parts[1]}" - - if $version == $postgresql::globals::default_version and $::operatingsystem != 'Amazon' { - $client_package_name = pick($client_package_name, 'postgresql') - $server_package_name = pick($server_package_name, 'postgresql-server') - $contrib_package_name = pick($contrib_package_name,'postgresql-contrib') - $devel_package_name = pick($devel_package_name, 'postgresql-devel') - $java_package_name = pick($java_package_name, 'postgresql-jdbc') - $docs_package_name = pick($docs_package_name, 'postgresql-docs') - $plperl_package_name = pick($plperl_package_name, 'postgresql-plperl') - $plpython_package_name = pick($plpython_package_name, 'postgresql-plpython') - $service_name = pick($service_name, 'postgresql') - $bindir = pick($bindir, '/usr/bin') - $datadir = $::operatingsystem ? { - 'Amazon' => pick($datadir, "/var/lib/pgsql${package_version}/data"), - default => pick($datadir, '/var/lib/pgsql/data'), - } - $confdir = pick($confdir, $datadir) - } else { - $client_package_name = pick($client_package_name, "postgresql${package_version}") - $server_package_name = pick($server_package_name, "postgresql${package_version}-server") - $contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib") - $devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel") - $java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc") - $docs_package_name = pick($docs_package_name, "postgresql${package_version}-docs") - $plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl") - $plpython_package_name = pick($plpython_package_name, "postgresql${package_version}-plpython") - $service_name = $::operatingsystem ? { - 'Amazon' => pick($service_name, "postgresql${version_parts[0]}${version_parts[1]}"), - default => pick($service_name, "postgresql-${version}"), - } - $bindir = $::operatingsystem ? { - 'Amazon' => pick($bindir, '/usr/bin'), - default => pick($bindir, "/usr/pgsql-${version}/bin"), - } - $datadir = $::operatingsystem ? { - 'Amazon' => pick($datadir, "/var/lib/pgsql${package_version}/data"), - default => pick($datadir, "/var/lib/pgsql/${version}/data"), - } - $confdir = pick($confdir, $datadir) - } - $psql_path = pick($psql_path, "${bindir}/psql") - - $service_status = $service_status - $service_reload = "service ${service_name} reload" - $perl_package_name = pick($perl_package_name, 'perl-DBD-Pg') - $python_package_name = pick($python_package_name, 'python-psycopg2') - - if $postgresql::globals::postgis_package_name { - $postgis_package_name = $postgresql::globals::postgis_package_name - } elsif $::operatingsystemrelease =~ /^5\./ { - $postgis_package_name = 'postgis' - } elsif $postgis_version and versioncmp($postgis_version, '2') < 0 { - $postgis_package_name = "postgis${package_version}" - } else { - $postgis_package_name = "postgis2_${package_version}" - } - } - - 'Archlinux': { - $link_pg_config = true - $needs_initdb = pick($needs_initdb, true) - $user = pick($user, 'postgres') - $group = pick($group, 'postgres') - - # Archlinux doesn't have a client-package but has a libs package which - # pulls in postgresql server - $client_package_name = pick($client_package_name, 'postgresql') - $server_package_name = pick($server_package_name, 'postgresql-libs') - $java_package_name = pick($java_package_name, 'postgresql-jdbc') - # Archlinux doesn't have develop packages - $devel_package_name = pick($devel_package_name, 'postgresql-devel') - # Archlinux does have postgresql-contrib but it isn't maintained - $contrib_package_name = pick($contrib_package_name,'undef') - # Archlinux postgresql package provides plperl - $plperl_package_name = pick($plperl_package_name, 'undef') - $plpython_package_name = pick($plpython_package_name, 'undef') - $service_name = pick($service_name, 'postgresql') - $bindir = pick($bindir, '/usr/bin') - $datadir = pick($datadir, '/var/lib/postgres/data') - $confdir = pick($confdir, $datadir) - $psql_path = pick($psql_path, "${bindir}/psql") - - $service_status = $service_status - $service_reload = "systemctl reload ${service_name}" - $python_package_name = pick($python_package_name, 'python-psycopg2') - # Archlinux does not have a perl::DBD::Pg package - $perl_package_name = pick($perl_package_name, 'undef') - } - - 'Debian': { - $link_pg_config = false - $user = pick($user, 'postgres') - $group = pick($group, 'postgres') - - if $postgresql::globals::manage_package_repo == true { - $needs_initdb = pick($needs_initdb, true) - $service_name = pick($service_name, 'postgresql') - } else { - $needs_initdb = pick($needs_initdb, false) - $service_name = $::operatingsystem ? { - 'Debian' => pick($service_name, 'postgresql'), - 'Ubuntu' => $::lsbmajdistrelease ? { - /^10/ => pick($service_name, "postgresql-${version}"), - default => pick($service_name, 'postgresql'), - }, - default => undef - } - } - - $client_package_name = pick($client_package_name, "postgresql-client-${version}") - $server_package_name = pick($server_package_name, "postgresql-${version}") - $contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}") - if $postgis_version and versioncmp($postgis_version, '2') < 0 { - $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis") - } else { - $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}") - } - $devel_package_name = pick($devel_package_name, 'libpq-dev') - $java_package_name = pick($java_package_name, 'libpostgresql-jdbc-java') - $perl_package_name = pick($perl_package_name, 'libdbd-pg-perl') - $plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}") - $plpython_package_name = pick($plpython_package_name, "postgresql-plpython-${version}") - $python_package_name = pick($python_package_name, 'python-psycopg2') - - $bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin") - $datadir = pick($datadir, "/var/lib/postgresql/${version}/main") - $confdir = pick($confdir, "/etc/postgresql/${version}/main") - if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') >= 0 { - # Jessie uses systemd - $service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status") - } elsif $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '15.04') >= 0 { - # Ubuntu releases since vivid use systemd - $service_status = pick($service_status, "/usr/sbin/service ${service_name} status") - } else { - $service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'") - } - $service_reload = "service ${service_name} reload" - $psql_path = pick($psql_path, '/usr/bin/psql') - } - - 'FreeBSD': { - $link_pg_config = true - $user = pick($user, 'pgsql') - $group = pick($group, 'pgsql') - - $client_package_name = pick($client_package_name, "databases/postgresql${version}-client") - $server_package_name = pick($server_package_name, "databases/postgresql${version}-server") - $contrib_package_name = pick($contrib_package_name, "databases/postgresql${version}-contrib") - $devel_package_name = pick($devel_package_name, 'databases/postgresql-libpqxx3') - $java_package_name = pick($java_package_name, 'databases/postgresql-jdbc') - $perl_package_name = pick($plperl_package_name, 'databases/p5-DBD-Pg') - $plperl_package_name = pick($plperl_package_name, "databases/postgresql${version}-plperl") - $python_package_name = pick($python_package_name, 'databases/py-psycopg2') - - $service_name = pick($service_name, 'postgresql') - $bindir = pick($bindir, '/usr/local/bin') - $datadir = pick($datadir, '/usr/local/pgsql/data') - $confdir = pick($confdir, $datadir) - $service_status = pick($service_status, "/usr/local/etc/rc.d/${service_name} onestatus") - $service_reload = "service ${service_name} reload" - $psql_path = pick($psql_path, "${bindir}/psql") - - $needs_initdb = pick($needs_initdb, true) - } - - 'OpenBSD': { - $user = pick($user, '_postgresql') - $group = pick($group, '_postgresql') - - $client_package_name = pick($client_package_name, 'postgresql-client') - $server_package_name = pick($server_package_name, 'postgresql-server') - $contrib_package_name = pick($contrib_package_name, 'postgresql-contrib') - $devel_package_name = pick($devel_package_name, 'postgresql-client') - $java_package_name = pick($java_package_name, 'postgresql-jdbc') - $perl_package_name = pick($perl_package_name, 'databases/p5-DBD-Pg') - $plperl_package_name = undef - $python_package_name = pick($python_package_name, 'py-psycopg2') - - $service_name = pick($service_name, 'postgresql') - $bindir = pick($bindir, '/usr/local/bin') - $datadir = pick($datadir, '/var/postgresql/data') - $confdir = pick($confdir, $datadir) - $service_status = pick($service_status, "/etc/rc.d/${service_name} check") - $service_reload = "/etc/rc.d/${service_name} reload" - $psql_path = pick($psql_path, "${bindir}/psql") - - $needs_initdb = pick($needs_initdb, true) - } - - 'Suse': { - $link_pg_config = true - $user = pick($user, 'postgres') - $group = pick($group, 'postgres') - - $client_package_name = pick($client_package_name, "postgresql${version}") - $server_package_name = pick($server_package_name, "postgresql${version}-server") - $contrib_package_name = pick($contrib_package_name, "postgresql${version}-contrib") - $devel_package_name = pick($devel_package_name, "postgresql${version}-devel") - $java_package_name = pick($java_package_name, "postgresql${version}-jdbc") - $perl_package_name = pick($plperl_package_name, 'perl-DBD-Pg') - $plperl_package_name = pick($plperl_package_name, "postgresql${version}-plperl") - $python_package_name = pick($python_package_name, 'python-psycopg2') - - $service_name = pick($service_name, 'postgresql') - $bindir = pick($bindir, "/usr/lib/postgresql${version}/bin") - $datadir = pick($datadir, '/var/lib/pgsql/data') - $confdir = pick($confdir, $datadir) - $service_status = pick($service_status, "/etc/init.d/${service_name} status") - $service_reload = "/etc/init.d/${service_name} reload" - $psql_path = pick($psql_path, "${bindir}/psql") - - $needs_initdb = pick($needs_initdb, true) - } - - default: { - $link_pg_config = true - $psql_path = pick($psql_path, "${bindir}/psql") - - # Since we can't determine defaults on our own, we rely on users setting - # parameters with the postgresql::globals class. Here we are checking - # that the mandatory minimum is set for the module to operate. - $err_prefix = "Module ${module_name} does not provide defaults for osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}; please specify a value for ${module_name}::globals::" - if ($needs_initdb == undef) { fail("${err_prefix}needs_initdb") } - if ($service_name == undef) { fail("${err_prefix}service_name") } - if ($client_package_name == undef) { fail("${err_prefix}client_package_name") } - if ($server_package_name == undef) { fail("${err_prefix}server_package_name") } - if ($bindir == undef) { fail("${err_prefix}bindir") } - if ($datadir == undef) { fail("${err_prefix}datadir") } - if ($confdir == undef) { fail("${err_prefix}confdir") } - } - } - - $validcon_script_path = pick($validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh') - $initdb_path = pick($initdb_path, "${bindir}/initdb") - $pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf") - $pg_hba_conf_defaults = pick($pg_hba_conf_defaults, true) - $pg_ident_conf_path = pick($pg_ident_conf_path, "${confdir}/pg_ident.conf") - $postgresql_conf_path = pick($postgresql_conf_path, "${confdir}/postgresql.conf") - $recovery_conf_path = pick($recovery_conf_path, "${datadir}/recovery.conf") - $default_database = pick($default_database, 'postgres') -} diff --git a/vagrant/puppet/modules/postgresql/manifests/repo.pp b/vagrant/puppet/modules/postgresql/manifests/repo.pp deleted file mode 100644 index 58d859fc9..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/repo.pp +++ /dev/null @@ -1,22 +0,0 @@ -# PRIVATE CLASS: do not use directly -class postgresql::repo ( - $version = undef, - $proxy = undef, -) { - case $::osfamily { - 'RedHat', 'Linux': { - if $version == undef { - fail("The parameter 'version' for 'postgresql::repo' is undefined. You must always define it when osfamily == Redhat or Linux") - } - class { 'postgresql::repo::yum_postgresql_org': } - } - - 'Debian': { - class { 'postgresql::repo::apt_postgresql_org': } - } - - default: { - fail("Unsupported managed repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for osfamily RedHat and Debian") - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/repo/apt_postgresql_org.pp b/vagrant/puppet/modules/postgresql/manifests/repo/apt_postgresql_org.pp deleted file mode 100644 index 60ac2b104..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/repo/apt_postgresql_org.pp +++ /dev/null @@ -1,23 +0,0 @@ -# PRIVATE CLASS: do not use directly -class postgresql::repo::apt_postgresql_org inherits postgresql::repo { -include ::apt - # Here we have tried to replicate the instructions on the PostgreSQL site: - # - # http://www.postgresql.org/download/linux/debian/ - # - apt::pin { 'apt_postgresql_org': - originator => 'apt.postgresql.org', - priority => 500, - }-> - apt::source { 'apt.postgresql.org': - location => 'http://apt.postgresql.org/pub/repos/apt/', - release => "${::lsbdistcodename}-pgdg", - repos => "main ${postgresql::repo::version}", - key => 'B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8', - key_source => 'https://www.postgresql.org/media/keys/ACCC4CF8.asc', - include_src => false, - } - - Apt::Source['apt.postgresql.org']->Package<|tag == 'postgresql'|> - Class['Apt::Update'] -> Package<|tag == 'postgresql'|> -} diff --git a/vagrant/puppet/modules/postgresql/manifests/repo/yum_postgresql_org.pp b/vagrant/puppet/modules/postgresql/manifests/repo/yum_postgresql_org.pp deleted file mode 100644 index 5cfaf4b15..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/repo/yum_postgresql_org.pp +++ /dev/null @@ -1,30 +0,0 @@ -# PRIVATE CLASS: do not use directly -class postgresql::repo::yum_postgresql_org inherits postgresql::repo { - $version_parts = split($postgresql::repo::version, '[.]') - $package_version = "${version_parts[0]}${version_parts[1]}" - $gpg_key_path = "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}" - - file { $gpg_key_path: - source => 'puppet:///modules/postgresql/RPM-GPG-KEY-PGDG', - before => Yumrepo['yum.postgresql.org'] - } - - if($::operatingsystem == 'Fedora') { - $label1 = 'fedora' - $label2 = $label1 - } else { - $label1 = 'redhat' - $label2 = 'rhel' - } - - yumrepo { 'yum.postgresql.org': - descr => "PostgreSQL ${postgresql::repo::version} \$releasever - \$basearch", - baseurl => "http://yum.postgresql.org/${postgresql::repo::version}/${label1}/${label2}-\$releasever-\$basearch", - enabled => 1, - gpgcheck => 1, - gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}", - proxy => $postgresql::repo::proxy, - } - - Yumrepo['yum.postgresql.org'] -> Package<|tag == 'postgresql'|> -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server.pp b/vagrant/puppet/modules/postgresql/manifests/server.pp deleted file mode 100644 index f4fa2f44d..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server.pp +++ /dev/null @@ -1,83 +0,0 @@ -# This installs a PostgreSQL server. See README.md for more details. -class postgresql::server ( - $postgres_password = undef, - - $package_name = $postgresql::params::server_package_name, - $client_package_name = $postgresql::params::client_package_name, - $package_ensure = $postgresql::params::package_ensure, - - $plperl_package_name = $postgresql::params::plperl_package_name, - $plpython_package_name = $postgresql::params::plpython_package_name, - - $service_ensure = $postgresql::params::service_ensure, - $service_enable = $postgresql::params::service_enable, - $service_manage = $postgresql::params::service_manage, - $service_name = $postgresql::params::service_name, - $service_restart_on_change = $postgresql::params::service_restart_on_change, - $service_provider = $postgresql::params::service_provider, - $service_reload = $postgresql::params::service_reload, - $service_status = $postgresql::params::service_status, - $default_database = $postgresql::params::default_database, - $default_connect_settings = $postgresql::globals::default_connect_settings, - $listen_addresses = $postgresql::params::listen_addresses, - $port = $postgresql::params::port, - $ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user, - $ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users, - $ipv4acls = $postgresql::params::ipv4acls, - $ipv6acls = $postgresql::params::ipv6acls, - - $initdb_path = $postgresql::params::initdb_path, - $createdb_path = $postgresql::params::createdb_path, - $psql_path = $postgresql::params::psql_path, - $pg_hba_conf_path = $postgresql::params::pg_hba_conf_path, - $pg_ident_conf_path = $postgresql::params::pg_ident_conf_path, - $postgresql_conf_path = $postgresql::params::postgresql_conf_path, - $recovery_conf_path = $postgresql::params::recovery_conf_path, - - $datadir = $postgresql::params::datadir, - $xlogdir = $postgresql::params::xlogdir, - $logdir = $postgresql::params::logdir, - - $log_line_prefix = $postgresql::params::log_line_prefix, - - $pg_hba_conf_defaults = $postgresql::params::pg_hba_conf_defaults, - - $user = $postgresql::params::user, - $group = $postgresql::params::group, - - $needs_initdb = $postgresql::params::needs_initdb, - - $encoding = $postgresql::params::encoding, - $locale = $postgresql::params::locale, - - $manage_pg_hba_conf = $postgresql::params::manage_pg_hba_conf, - $manage_pg_ident_conf = $postgresql::params::manage_pg_ident_conf, - $manage_recovery_conf = $postgresql::params::manage_recovery_conf, - - #Deprecated - $version = undef, -) inherits postgresql::params { - $pg = 'postgresql::server' - - if $version != undef { - warning('Passing "version" to postgresql::server is deprecated; please use postgresql::globals instead.') - $_version = $version - } else { - $_version = $postgresql::params::version - } - - if $createdb_path != undef{ - warning('Passing "createdb_path" to postgresql::server is deprecated, it can be removed safely for the same behaviour') - } - - # Reload has its own ordering, specified by other defines - class { "${pg}::reload": require => Class["${pg}::install"] } - - anchor { "${pg}::start": }-> - class { "${pg}::install": }-> - class { "${pg}::initdb": }-> - class { "${pg}::config": }-> - class { "${pg}::service": }-> - class { "${pg}::passwd": }-> - anchor { "${pg}::end": } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/config.pp b/vagrant/puppet/modules/postgresql/manifests/server/config.pp deleted file mode 100644 index b00a79b18..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/config.pp +++ /dev/null @@ -1,192 +0,0 @@ -# PRIVATE CLASS: do not call directly -class postgresql::server::config { - $ip_mask_deny_postgres_user = $postgresql::server::ip_mask_deny_postgres_user - $ip_mask_allow_all_users = $postgresql::server::ip_mask_allow_all_users - $listen_addresses = $postgresql::server::listen_addresses - $port = $postgresql::server::port - $ipv4acls = $postgresql::server::ipv4acls - $ipv6acls = $postgresql::server::ipv6acls - $pg_hba_conf_path = $postgresql::server::pg_hba_conf_path - $pg_ident_conf_path = $postgresql::server::pg_ident_conf_path - $postgresql_conf_path = $postgresql::server::postgresql_conf_path - $recovery_conf_path = $postgresql::server::recovery_conf_path - $pg_hba_conf_defaults = $postgresql::server::pg_hba_conf_defaults - $user = $postgresql::server::user - $group = $postgresql::server::group - $version = $postgresql::server::_version - $manage_pg_hba_conf = $postgresql::server::manage_pg_hba_conf - $manage_pg_ident_conf = $postgresql::server::manage_pg_ident_conf - $manage_recovery_conf = $postgresql::server::manage_recovery_conf - $datadir = $postgresql::server::datadir - $logdir = $postgresql::server::logdir - $service_name = $postgresql::server::service_name - $log_line_prefix = $postgresql::server::log_line_prefix - - if ($manage_pg_hba_conf == true) { - # Prepare the main pg_hba file - concat { $pg_hba_conf_path: - owner => $user, - group => $group, - mode => '0640', - warn => true, - notify => Class['postgresql::server::reload'], - } - - if $pg_hba_conf_defaults { - Postgresql::Server::Pg_hba_rule { - database => 'all', - user => 'all', - } - - # Lets setup the base rules - $local_auth_option = $version ? { - '8.1' => 'sameuser', - default => undef, - } - postgresql::server::pg_hba_rule { 'local access as postgres user': - type => 'local', - user => $user, - auth_method => 'ident', - auth_option => $local_auth_option, - order => '001', - } - postgresql::server::pg_hba_rule { 'local access to database with same name': - type => 'local', - auth_method => 'ident', - auth_option => $local_auth_option, - order => '002', - } - postgresql::server::pg_hba_rule { 'allow localhost TCP access to postgresql user': - type => 'host', - user => $user, - address => '127.0.0.1/32', - auth_method => 'md5', - order => '003', - } - postgresql::server::pg_hba_rule { 'deny access to postgresql user': - type => 'host', - user => $user, - address => $ip_mask_deny_postgres_user, - auth_method => 'reject', - order => '004', - } - - postgresql::server::pg_hba_rule { 'allow access to all users': - type => 'host', - address => $ip_mask_allow_all_users, - auth_method => 'md5', - order => '100', - } - postgresql::server::pg_hba_rule { 'allow access to ipv6 localhost': - type => 'host', - address => '::1/128', - auth_method => 'md5', - order => '101', - } - } - - # ipv4acls are passed as an array of rule strings, here we transform - # them into a resources hash, and pass the result to create_resources - $ipv4acl_resources = postgresql_acls_to_resources_hash($ipv4acls, - 'ipv4acls', 10) - create_resources('postgresql::server::pg_hba_rule', $ipv4acl_resources) - - - # ipv6acls are passed as an array of rule strings, here we transform - # them into a resources hash, and pass the result to create_resources - $ipv6acl_resources = postgresql_acls_to_resources_hash($ipv6acls, - 'ipv6acls', 102) - create_resources('postgresql::server::pg_hba_rule', $ipv6acl_resources) - } - - # We must set a "listen_addresses" line in the postgresql.conf if we - # want to allow any connections from remote hosts. - postgresql::server::config_entry { 'listen_addresses': - value => $listen_addresses, - } - postgresql::server::config_entry { 'port': - value => $port, - } - postgresql::server::config_entry { 'data_directory': - value => $datadir, - } - if $logdir { - postgresql::server::config_entry { 'log_directory': - value => $logdir, - } - - } - # Allow timestamps in log by default - if $log_line_prefix { - postgresql::server::config_entry {'log_line_prefix': - value => $log_line_prefix, - } - } - - # RedHat-based systems hardcode some PG* variables in the init script, and need to be overriden - # in /etc/sysconfig/pgsql/postgresql. Create a blank file so we can manage it with augeas later. - if ($::osfamily == 'RedHat') and ($::operatingsystemrelease !~ /^7/) and ($::operatingsystem != 'Fedora') { - file { '/etc/sysconfig/pgsql/postgresql': - ensure => present, - replace => false, - } - - # The init script from the packages of the postgresql.org repository - # sources an alternate sysconfig file. - # I. e. /etc/sysconfig/pgsql/postgresql-9.3 for PostgreSQL 9.3 - # Link to the sysconfig file set by this puppet module - file { "/etc/sysconfig/pgsql/postgresql-${version}": - ensure => link, - target => '/etc/sysconfig/pgsql/postgresql', - require => File[ '/etc/sysconfig/pgsql/postgresql' ], - } - - } - - - if ($manage_pg_ident_conf == true) { - concat { $pg_ident_conf_path: - owner => $user, - group => $group, - force => true, # do not crash if there is no pg_ident_rules - mode => '0640', - warn => true, - notify => Class['postgresql::server::reload'], - } - } - - if ($manage_recovery_conf == true) { - concat { $recovery_conf_path: - owner => $user, - group => $group, - force => true, # do not crash if there is no recovery conf file - mode => '0640', - warn => true, - notify => Class['postgresql::server::reload'], - } - } - - if $::osfamily == 'RedHat' { - if $::operatingsystemrelease =~ /^7/ or $::operatingsystem == 'Fedora' { - # Template uses: - # - $::operatingsystem - # - $service_name - # - $port - # - $datadir - file { 'systemd-override': - ensure => present, - path => "/etc/systemd/system/${service_name}.service", - owner => root, - group => root, - content => template('postgresql/systemd-override.erb'), - notify => [ Exec['restart-systemd'], Class['postgresql::server::service'] ], - before => Class['postgresql::server::reload'], - } - exec { 'restart-systemd': - command => 'systemctl daemon-reload', - refreshonly => true, - path => '/bin:/usr/bin:/usr/local/bin' - } - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/config_entry.pp b/vagrant/puppet/modules/postgresql/manifests/server/config_entry.pp deleted file mode 100644 index 9ac7bfa9f..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/config_entry.pp +++ /dev/null @@ -1,126 +0,0 @@ -# Manage a postgresql.conf entry. See README.md for more details. -define postgresql::server::config_entry ( - $ensure = 'present', - $value = undef, - $path = false -) { - $postgresql_conf_path = $postgresql::server::postgresql_conf_path - - $target = $path ? { - false => $postgresql_conf_path, - default => $path, - } - - Exec { - logoutput => 'on_failure', - } - - case $name { - /data_directory|hba_file|ident_file|include|listen_addresses|port|max_connections|superuser_reserved_connections|unix_socket_directory|unix_socket_group|unix_socket_permissions|bonjour|bonjour_name|ssl|ssl_ciphers|shared_buffers|max_prepared_transactions|max_files_per_process|shared_preload_libraries|wal_level|wal_buffers|archive_mode|max_wal_senders|hot_standby|logging_collector|silent_mode|track_activity_query_size|autovacuum_max_workers|autovacuum_freeze_max_age|max_locks_per_transaction|max_pred_locks_per_transaction|restart_after_crash|lc_messages|lc_monetary|lc_numeric|lc_time|log_min_duration_statement/: { - if $postgresql::server::service_restart_on_change { - Postgresql_conf { - notify => Class['postgresql::server::service'], - before => Class['postgresql::server::reload'], - } - } else { - Postgresql_conf { - before => [ - Class['postgresql::server::service'], - Class['postgresql::server::reload'], - ], - } - } - } - - default: { - Postgresql_conf { - notify => Class['postgresql::server::reload'], - } - } - } - - # We have to handle ports and the data directory in a weird and - # special way. On early Debian and Ubuntu and RHEL we have to ensure - # we stop the service completely. On RHEL 7 we either have to create - # a systemd override for the port or update the sysconfig file, but this - # is managed for us in postgresql::server::config. - if $::operatingsystem == 'Debian' or $::operatingsystem == 'Ubuntu' { - if $name == 'port' and ( $::operatingsystemrelease =~ /^6/ or $::operatingsystemrelease =~ /^10\.04/ ) { - exec { "postgresql_stop_${name}": - command => "service ${::postgresql::server::service_name} stop", - onlyif => "service ${::postgresql::server::service_name} status", - unless => "grep 'port = ${value}' ${::postgresql::server::postgresql_conf_path}", - path => '/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin', - before => Postgresql_conf[$name], - } - } - elsif $name == 'data_directory' { - exec { "postgresql_stop_${name}": - command => "service ${::postgresql::server::service_name} stop", - onlyif => "service ${::postgresql::server::service_name} status", - unless => "grep \"data_directory = '${value}'\" ${::postgresql::server::postgresql_conf_path}", - path => '/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin', - before => Postgresql_conf[$name], - } - } - } - if $::osfamily == 'RedHat' { - if ! ($::operatingsystemrelease =~ /^7/ or $::operatingsystem == 'Fedora') { - if $name == 'port' { - # We need to force postgresql to stop before updating the port - # because puppet becomes confused and is unable to manage the - # service appropriately. - exec { "postgresql_stop_${name}": - command => "service ${::postgresql::server::service_name} stop", - onlyif => "service ${::postgresql::server::service_name} status", - unless => "grep 'PGPORT=${value}' /etc/sysconfig/pgsql/postgresql", - path => '/sbin:/bin:/usr/bin:/usr/local/bin', - require => File['/etc/sysconfig/pgsql/postgresql'], - } -> - augeas { 'override PGPORT in /etc/sysconfig/pgsql/postgresql': - lens => 'Shellvars.lns', - incl => '/etc/sysconfig/pgsql/*', - context => '/files/etc/sysconfig/pgsql/postgresql', - changes => "set PGPORT ${value}", - require => File['/etc/sysconfig/pgsql/postgresql'], - notify => Class['postgresql::server::service'], - before => Class['postgresql::server::reload'], - } - } elsif $name == 'data_directory' { - # We need to force postgresql to stop before updating the data directory - # otherwise init script breaks - exec { "postgresql_${name}": - command => "service ${::postgresql::server::service_name} stop", - onlyif => "service ${::postgresql::server::service_name} status", - unless => "grep 'PGDATA=${value}' /etc/sysconfig/pgsql/postgresql", - path => '/sbin:/bin:/usr/bin:/usr/local/bin', - require => File['/etc/sysconfig/pgsql/postgresql'], - } -> - augeas { 'override PGDATA in /etc/sysconfig/pgsql/postgresql': - lens => 'Shellvars.lns', - incl => '/etc/sysconfig/pgsql/*', - context => '/files/etc/sysconfig/pgsql/postgresql', - changes => "set PGDATA ${value}", - require => File['/etc/sysconfig/pgsql/postgresql'], - notify => Class['postgresql::server::service'], - before => Class['postgresql::server::reload'], - } - } - } - } - - case $ensure { - /present|absent/: { - postgresql_conf { $name: - ensure => $ensure, - target => $target, - value => $value, - require => Class['postgresql::server::initdb'], - } - } - - default: { - fail("Unknown value for ensure '${ensure}'.") - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/contrib.pp b/vagrant/puppet/modules/postgresql/manifests/server/contrib.pp deleted file mode 100644 index e119d9c99..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/contrib.pp +++ /dev/null @@ -1,19 +0,0 @@ -# Install the contrib postgresql packaging. See README.md for more details. -class postgresql::server::contrib ( - $package_name = $postgresql::params::contrib_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - validate_string($package_name) - - package { 'postgresql-contrib': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - anchor { 'postgresql::server::contrib::start': }-> - Class['postgresql::server::install']-> - Package['postgresql-contrib']-> - Class['postgresql::server::service']-> - anchor { 'postgresql::server::contrib::end': } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/database.pp b/vagrant/puppet/modules/postgresql/manifests/server/database.pp deleted file mode 100644 index fab12b53a..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/database.pp +++ /dev/null @@ -1,112 +0,0 @@ -# Define for creating a database. See README.md for more details. -define postgresql::server::database( - $comment = undef, - $dbname = $title, - $owner = $postgresql::server::user, - $tablespace = undef, - $template = 'template0', - $encoding = $postgresql::server::encoding, - $locale = $postgresql::server::locale, - $istemplate = false, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $createdb_path = $postgresql::server::createdb_path - $user = $postgresql::server::user - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - $default_db = $postgresql::server::default_database - - # If possible use the version of the remote database, otherwise - # fallback to our local DB version - if $connect_settings != undef and has_key( $connect_settings, 'DBVERSION') { - $version = $connect_settings['DBVERSION'] - } else { - $version = $postgresql::server::_version - } - - # If the connection settings do not contain a port, then use the local server port - if $connect_settings != undef and has_key( $connect_settings, 'PGPORT') { - $port = undef - } else { - $port = $postgresql::server::port - } - - # Set the defaults for the postgresql_psql resource - Postgresql_psql { - psql_user => $user, - psql_group => $group, - psql_path => $psql_path, - port => $port, - connect_settings => $connect_settings, - } - - # Optionally set the locale switch. Older versions of createdb may not accept - # --locale, so if the parameter is undefined its safer not to pass it. - if ($version != '8.1') { - $locale_option = $locale ? { - undef => '', - default => "LC_COLLATE='${locale}' LC_CTYPE='${locale}'", - } - $public_revoke_privilege = 'CONNECT' - } else { - $locale_option = '' - $public_revoke_privilege = 'ALL' - } - - $template_option = $template ? { - undef => '', - default => "TEMPLATE=\"${template}\"", - } - - $encoding_option = $encoding ? { - undef => '', - default => "ENCODING='${encoding}'", - } - - $tablespace_option = $tablespace ? { - undef => '', - default => "TABLESPACE=\"${tablespace}\"", - } - - if $createdb_path != undef{ - warning('Passing "createdb_path" to postgresql::database is deprecated, it can be removed safely for the same behaviour') - } - - postgresql_psql { "Create db '${dbname}'": - command => "CREATE DATABASE \"${dbname}\" WITH OWNER=\"${owner}\" ${template_option} ${encoding_option} ${locale_option} ${tablespace_option}", - unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'", - db => $default_db, - require => Class['postgresql::server::service'] - }~> - - # This will prevent users from connecting to the database unless they've been - # granted privileges. - postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public": - db => $default_db, - refreshonly => true, - } - - Postgresql_psql[ "Create db '${dbname}'" ]-> - postgresql_psql {"UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'": - unless => "SELECT datname FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}", - db => $default_db, - } - - if $comment { - # The shobj_description function was only introduced with 8.2 - $comment_information_function = $version ? { - '8.1' => 'obj_description', - default => 'shobj_description', - } - Postgresql_psql[ "Create db '${dbname}'" ]-> - postgresql_psql {"COMMENT ON DATABASE \"${dbname}\" IS '${comment}'": - unless => "SELECT pg_catalog.${comment_information_function}(d.oid, 'pg_database') as \"Description\" FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.${comment_information_function}(d.oid, 'pg_database') = '${comment}'", - db => $dbname, - } - } - - # Build up dependencies on tablespace - if($tablespace != undef and defined(Postgresql::Server::Tablespace[$tablespace])) { - Postgresql::Server::Tablespace[$tablespace]->Postgresql_psql[ "Create db '${dbname}'" ] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/database_grant.pp b/vagrant/puppet/modules/postgresql/manifests/server/database_grant.pp deleted file mode 100644 index 6c29b5717..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/database_grant.pp +++ /dev/null @@ -1,20 +0,0 @@ -# Manage a database grant. See README.md for more details. -define postgresql::server::database_grant( - $privilege, - $db, - $role, - $psql_db = undef, - $psql_user = undef, - $connect_settings = undef, -) { - postgresql::server::grant { "database:${name}": - role => $role, - db => $db, - privilege => $privilege, - object_type => 'DATABASE', - object_name => $db, - psql_db => $psql_db, - psql_user => $psql_user, - connect_settings => $connect_settings, - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/db.pp b/vagrant/puppet/modules/postgresql/manifests/server/db.pp deleted file mode 100644 index b4c1232cf..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/db.pp +++ /dev/null @@ -1,47 +0,0 @@ -# Define for conveniently creating a role, database and assigning the correct -# permissions. See README.md for more details. -define postgresql::server::db ( - $user, - $password, - $comment = undef, - $dbname = $title, - $encoding = $postgresql::server::encoding, - $locale = $postgresql::server::locale, - $grant = 'ALL', - $tablespace = undef, - $template = 'template0', - $istemplate = false, - $owner = undef -) { - - if ! defined(Postgresql::Server::Database[$dbname]) { - postgresql::server::database { $dbname: - comment => $comment, - encoding => $encoding, - tablespace => $tablespace, - template => $template, - locale => $locale, - istemplate => $istemplate, - owner => $owner, - } - } - - if ! defined(Postgresql::Server::Role[$user]) { - postgresql::server::role { $user: - password_hash => $password, - before => Postgresql::Server::Database[$dbname], - } - } - - if ! defined(Postgresql::Server::Database_grant["GRANT ${user} - ${grant} - ${dbname}"]) { - postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${dbname}": - privilege => $grant, - db => $dbname, - role => $user, - } -> Postgresql::Validate_db_connection<| database_name == $dbname |> - } - - if($tablespace != undef and defined(Postgresql::Server::Tablespace[$tablespace])) { - Postgresql::Server::Tablespace[$tablespace]->Postgresql::Server::Database[$name] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/extension.pp b/vagrant/puppet/modules/postgresql/manifests/server/extension.pp deleted file mode 100644 index 1c9b684ad..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/extension.pp +++ /dev/null @@ -1,61 +0,0 @@ -# Activate an extension on a postgresql database -define postgresql::server::extension ( - $database, - $extension = $name, - $ensure = 'present', - $package_name = undef, - $package_ensure = undef, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $user = $postgresql::server::user - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - - case $ensure { - 'present': { - $command = "CREATE EXTENSION \"${extension}\"" - $unless_comp = '=' - $package_require = [] - $package_before = Postgresql_psql["Add ${extension} extension to ${database}"] - } - - 'absent': { - $command = "DROP EXTENSION \"${extension}\"" - $unless_comp = '!=' - $package_require = Postgresql_psql["Add ${extension} extension to ${database}"] - $package_before = [] - } - - default: { - fail("Unknown value for ensure '${ensure}'.") - } - } - - - postgresql_psql {"Add ${extension} extension to ${database}": - - psql_user => $user, - psql_group => $group, - psql_path => $psql_path, - connect_settings => $connect_settings, - - db => $database, - command => $command, - unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = '${extension}') as t WHERE t.count ${unless_comp} 1", - require => Postgresql::Server::Database[$database], - } - - if $package_name { - $_package_ensure = $package_ensure ? { - undef => $ensure, - default => $package_ensure, - } - - ensure_packages($package_name, { - ensure => $_package_ensure, - tag => 'postgresql', - require => $package_require, - before => $package_before, - }) - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/grant.pp b/vagrant/puppet/modules/postgresql/manifests/server/grant.pp deleted file mode 100644 index 697313a72..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/grant.pp +++ /dev/null @@ -1,252 +0,0 @@ -# Define for granting permissions to roles. See README.md for more details. -define postgresql::server::grant ( - $role, - $db, - $privilege = undef, - $object_type = 'database', - $object_name = undef, - $psql_db = $postgresql::server::default_database, - $psql_user = $postgresql::server::user, - $port = $postgresql::server::port, - $onlyif_exists = false, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - - if ! $object_name { - $_object_name = $db - } else { - $_object_name = $object_name - } - - validate_bool($onlyif_exists) - # - # Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port - # - if $port != undef { - $port_override = $port - } elsif $connect_settings != undef and has_key( $connect_settings, 'PGPORT') { - $port_override = undef - } else { - $port_override = $postgresql::server::port - } - - ## Munge the input values - $_object_type = upcase($object_type) - $_privilege = upcase($privilege) - - ## Validate that the object type is known - validate_string($_object_type, - #'COLUMN', - 'DATABASE', - #'FOREIGN SERVER', - #'FOREIGN DATA WRAPPER', - #'FUNCTION', - #'PROCEDURAL LANGUAGE', - 'SCHEMA', - 'SEQUENCE', - 'ALL SEQUENCES IN SCHEMA', - 'TABLE', - 'ALL TABLES IN SCHEMA', - #'TABLESPACE', - #'VIEW', - ) - # You can use ALL TABLES IN SCHEMA by passing schema_name to object_name - # You can use ALL SEQUENCES IN SCHEMA by passing schema_name to object_name - - ## Validate that the object type's privilege is acceptable - # TODO: this is a terrible hack; if they pass "ALL" as the desired privilege, - # we need a way to test for it--and has_database_privilege does not - # recognize 'ALL' as a valid privilege name. So we probably need to - # hard-code a mapping between 'ALL' and the list of actual privileges that - # it entails, and loop over them to check them. That sort of thing will - # probably need to wait until we port this over to ruby, so, for now, we're - # just going to assume that if they have "CREATE" privileges on a database, - # then they have "ALL". (I told you that it was terrible!) - case $_object_type { - 'DATABASE': { - $unless_privilege = $_privilege ? { - 'ALL' => 'CREATE', - 'ALL PRIVILEGES' => 'CREATE', - default => $_privilege, - } - validate_string($unless_privilege,'CREATE','CONNECT','TEMPORARY','TEMP', - 'ALL','ALL PRIVILEGES') - $unless_function = 'has_database_privilege' - $on_db = $psql_db - $onlyif_function = undef - } - 'SCHEMA': { - $unless_privilege = $_privilege ? { - 'ALL' => 'CREATE', - 'ALL PRIVILEGES' => 'CREATE', - default => $_privilege, - } - validate_string($_privilege, 'CREATE', 'USAGE', 'ALL', 'ALL PRIVILEGES') - $unless_function = 'has_schema_privilege' - $on_db = $db - $onlyif_function = undef - } - 'SEQUENCE': { - $unless_privilege = $_privilege ? { - 'ALL' => 'USAGE', - default => $_privilege, - } - validate_string($unless_privilege,'USAGE','ALL','ALL PRIVILEGES') - $unless_function = 'has_sequence_privilege' - $on_db = $db - $onlyif_function = undef - } - 'ALL SEQUENCES IN SCHEMA': { - validate_string($_privilege,'USAGE','ALL','ALL PRIVILEGES') - $unless_function = 'custom' - $on_db = $db - $onlyif_function = undef - - $schema = $object_name - - $custom_privilege = $_privilege ? { - 'ALL' => 'USAGE', - 'ALL PRIVILEGES' => 'USAGE', - default => $_privilege, - } - - # This checks if there is a difference between the sequences in the - # specified schema and the sequences for which the role has the specified - # privilege. It uses the EXCEPT clause which computes the set of rows - # that are in the result of the first SELECT statement but not in the - # result of the second one. It then counts the number of rows from this - # operation. If this number is zero then the role has the specified - # privilege for all sequences in the schema and the whole query returns a - # single row, which satisfies the `unless` parameter of Postgresql_psql. - # If this number is not zero then there is at least one sequence for which - # the role does not have the specified privilege, making it necessary to - # execute the GRANT statement. - $custom_unless = "SELECT 1 FROM ( - SELECT sequence_name - FROM information_schema.sequences - WHERE sequence_schema='${schema}' - EXCEPT DISTINCT - SELECT object_name as sequence_name - FROM information_schema.role_usage_grants - WHERE object_type='SEQUENCE' - AND grantee='${role}' - AND object_schema='${schema}' - AND privilege_type='${custom_privilege}' - ) P - HAVING count(P.sequence_name) = 0" - } - 'TABLE': { - $unless_privilege = $_privilege ? { - 'ALL' => 'INSERT', - default => $_privilege, - } - validate_string($unless_privilege,'SELECT','INSERT','UPDATE','DELETE', - 'TRUNCATE','REFERENCES','TRIGGER','ALL','ALL PRIVILEGES') - $unless_function = 'has_table_privilege' - $on_db = $db - $onlyif_function = $onlyif_exists ? { - true => 'table_exists', - default => undef, - } - } - 'ALL TABLES IN SCHEMA': { - validate_string($_privilege,'SELECT','INSERT','UPDATE','DELETE', - 'TRUNCATE','REFERENCES','TRIGGER','ALL','ALL PRIVILEGES') - $unless_function = 'custom' - $on_db = $db - $onlyif_function = undef - - $schema = $object_name - - # Again there seems to be no easy way in plain SQL to check if ALL - # PRIVILEGES are granted on a table. By convention we use INSERT - # here to represent ALL PRIVILEGES (truly terrible). - $custom_privilege = $_privilege ? { - 'ALL' => 'INSERT', - 'ALL PRIVILEGES' => 'INSERT', - default => $_privilege, - } - - # This checks if there is a difference between the tables in the - # specified schema and the tables for which the role has the specified - # privilege. It uses the EXCEPT clause which computes the set of rows - # that are in the result of the first SELECT statement but not in the - # result of the second one. It then counts the number of rows from this - # operation. If this number is zero then the role has the specified - # privilege for all tables in the schema and the whole query returns a - # single row, which satisfies the `unless` parameter of Postgresql_psql. - # If this number is not zero then there is at least one table for which - # the role does not have the specified privilege, making it necessary to - # execute the GRANT statement. - $custom_unless = "SELECT 1 FROM ( - SELECT table_name - FROM information_schema.tables - WHERE table_schema='${schema}' - EXCEPT DISTINCT - SELECT table_name - FROM information_schema.role_table_grants - WHERE grantee='${role}' - AND table_schema='${schema}' - AND privilege_type='${custom_privilege}' - ) P - HAVING count(P.table_name) = 0" - } - default: { - fail("Missing privilege validation for object type ${_object_type}") - } - } - - # This is used to give grant to "schemaname"."tablename" - # If you need such grant, use: - # postgresql::grant { 'table:foo': - # role => 'joe', - # ... - # object_type => 'TABLE', - # object_name => [$schema, $table], - # } - if is_array($_object_name) { - $_togrant_object = join($_object_name, '"."') - # Never put double quotes into has_*_privilege function - $_granted_object = join($_object_name, '.') - } else { - $_granted_object = $_object_name - $_togrant_object = $_object_name - } - - $_unless = $unless_function ? { - false => undef, - 'custom' => $custom_unless, - default => "SELECT 1 WHERE ${unless_function}('${role}', - '${_granted_object}', '${unless_privilege}')", - } - - $_onlyif = $onlyif_function ? { - 'table_exists' => "SELECT true FROM pg_tables WHERE tablename = '${_togrant_object}'", - default => undef, - } - - $grant_cmd = "GRANT ${_privilege} ON ${_object_type} \"${_togrant_object}\" TO - \"${role}\"" - postgresql_psql { "grant:${name}": - command => $grant_cmd, - db => $on_db, - port => $port_override, - connect_settings => $connect_settings, - psql_user => $psql_user, - psql_group => $group, - psql_path => $psql_path, - unless => $_unless, - onlyif => $_onlyif, - require => Class['postgresql::server'] - } - - if($role != undef and defined(Postgresql::Server::Role[$role])) { - Postgresql::Server::Role[$role]->Postgresql_psql["grant:${name}"] - } - - if($db != undef and defined(Postgresql::Server::Database[$db])) { - Postgresql::Server::Database[$db]->Postgresql_psql["grant:${name}"] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/initdb.pp b/vagrant/puppet/modules/postgresql/manifests/server/initdb.pp deleted file mode 100644 index b0df32631..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/initdb.pp +++ /dev/null @@ -1,126 +0,0 @@ -# PRIVATE CLASS: do not call directly -class postgresql::server::initdb { - $needs_initdb = $postgresql::server::needs_initdb - $initdb_path = $postgresql::server::initdb_path - $datadir = $postgresql::server::datadir - $xlogdir = $postgresql::server::xlogdir - $logdir = $postgresql::server::logdir - $encoding = $postgresql::server::encoding - $locale = $postgresql::server::locale - $group = $postgresql::server::group - $user = $postgresql::server::user - $psql_path = $postgresql::server::psql_path - $port = $postgresql::server::port - - # Set the defaults for the postgresql_psql resource - Postgresql_psql { - psql_user => $user, - psql_group => $group, - psql_path => $psql_path, - port => $port, - } - - # Make sure the data directory exists, and has the correct permissions. - file { $datadir: - ensure => directory, - owner => $user, - group => $group, - mode => '0700', - } - - if($xlogdir) { - # Make sure the xlog directory exists, and has the correct permissions. - file { $xlogdir: - ensure => directory, - owner => $user, - group => $group, - mode => '0700', - } - } - - if($logdir) { - # Make sure the log directory exists, and has the correct permissions. - file { $logdir: - ensure => directory, - owner => $user, - group => $group, - } - } - - if($needs_initdb) { - # Build up the initdb command. - # - # We optionally add the locale switch if specified. Older versions of the - # initdb command don't accept this switch. So if the user didn't pass the - # parameter, lets not pass the switch at all. - $ic_base = "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'" - $ic_xlog = $xlogdir ? { - undef => $ic_base, - default => "${ic_base} --xlogdir '${xlogdir}'" - } - - # The xlogdir need to be present before initdb runs. - # If xlogdir is default it's created by package installer - if($xlogdir) { - $require_before_initdb = [$datadir, $xlogdir] - } else { - $require_before_initdb = [$datadir] - } - - $initdb_command = $locale ? { - undef => $ic_xlog, - default => "${ic_xlog} --locale '${locale}'" - } - - # This runs the initdb command, we use the existance of the PG_VERSION - # file to ensure we don't keep running this command. - exec { 'postgresql_initdb': - command => $initdb_command, - creates => "${datadir}/PG_VERSION", - user => $user, - group => $group, - logoutput => on_failure, - require => File[$require_before_initdb], - } - # The package will take care of this for us the first time, but if we - # ever need to init a new db we need to copy these files explicitly - if $::operatingsystem == 'Debian' or $::operatingsystem == 'Ubuntu' { - if $::operatingsystemrelease =~ /^6/ or $::operatingsystemrelease =~ /^7/ or $::operatingsystemrelease =~ /^10\.04/ or $::operatingsystemrelease =~ /^12\.04/ { - file { 'server.crt': - ensure => file, - path => "${datadir}/server.crt", - source => 'file:///etc/ssl/certs/ssl-cert-snakeoil.pem', - owner => $::postgresql::server::user, - group => $::postgresql::server::group, - mode => '0644', - require => Exec['postgresql_initdb'], - } - file { 'server.key': - ensure => file, - path => "${datadir}/server.key", - source => 'file:///etc/ssl/private/ssl-cert-snakeoil.key', - owner => $::postgresql::server::user, - group => $::postgresql::server::group, - mode => '0600', - require => Exec['postgresql_initdb'], - } - } - } - } elsif $encoding != undef { - # [workaround] - # by default pg_createcluster encoding derived from locale - # but it do does not work by installing postgresql via puppet because puppet - # always override LANG to 'C' - postgresql_psql { "Set template1 encoding to ${encoding}": - command => "UPDATE pg_database - SET datistemplate = FALSE - WHERE datname = 'template1' - ; - UPDATE pg_database - SET encoding = pg_char_to_encoding('${encoding}'), datistemplate = TRUE - WHERE datname = 'template1'", - unless => "SELECT datname FROM pg_database WHERE - datname = 'template1' AND encoding = pg_char_to_encoding('${encoding}')", - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/install.pp b/vagrant/puppet/modules/postgresql/manifests/server/install.pp deleted file mode 100644 index 8724f9f37..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/install.pp +++ /dev/null @@ -1,23 +0,0 @@ -# PRIVATE CLASS: do not call directly -class postgresql::server::install { - $package_ensure = $postgresql::server::package_ensure - $package_name = $postgresql::server::package_name - $client_package_name = $postgresql::server::client_package_name - - $_package_ensure = $package_ensure ? { - true => 'present', - false => 'purged', - 'absent' => 'purged', - default => $package_ensure, - } - - package { 'postgresql-server': - ensure => $_package_ensure, - name => $package_name, - - # This is searched for to create relationships with the package repos, be - # careful about its removal - tag => 'postgresql', - } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/passwd.pp b/vagrant/puppet/modules/postgresql/manifests/server/passwd.pp deleted file mode 100644 index ba5009819..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/passwd.pp +++ /dev/null @@ -1,37 +0,0 @@ -# PRIVATE CLASS: do not call directly -class postgresql::server::passwd { - $postgres_password = $postgresql::server::postgres_password - $user = $postgresql::server::user - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - $port = $postgresql::server::port - - if ($postgres_password != undef) { - # NOTE: this password-setting logic relies on the pg_hba.conf being - # configured to allow the postgres system user to connect via psql - # without specifying a password ('ident' or 'trust' security). This is - # the default for pg_hba.conf. - $escaped = postgresql_escape($postgres_password) - exec { 'set_postgres_postgrespw': - # This command works w/no password because we run it as postgres system - # user - command => "${psql_path} -c \"ALTER ROLE \\\"${user}\\\" PASSWORD \${NEWPASSWD_ESCAPED}\"", - user => $user, - group => $group, - logoutput => true, - cwd => '/tmp', - environment => [ - "PGPASSWORD=${postgres_password}", - "PGPORT=${port}", - "NEWPASSWD_ESCAPED=${escaped}", - ], - # With this command we're passing -h to force TCP authentication, which - # does require a password. We specify the password via the PGPASSWORD - # environment variable. If the password is correct (current), this - # command will exit with an exit code of 0, which will prevent the main - # command from running. - unless => "${psql_path} -h localhost -p ${port} -c 'select 1' > /dev/null", - path => '/usr/bin:/usr/local/bin:/bin', - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/pg_hba_rule.pp b/vagrant/puppet/modules/postgresql/manifests/server/pg_hba_rule.pp deleted file mode 100644 index 406568fbc..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/pg_hba_rule.pp +++ /dev/null @@ -1,62 +0,0 @@ -# This resource manages an individual rule that applies to the file defined in -# $target. See README.md for more details. -define postgresql::server::pg_hba_rule( - $type, - $database, - $user, - $auth_method, - $address = undef, - $description = 'none', - $auth_option = undef, - $order = '150', - - # Needed for testing primarily, support for multiple files is not really - # working. - $target = $postgresql::server::pg_hba_conf_path, - $postgresql_version = $postgresql::server::_version -) { - - #Allow users to manage pg_hba.conf even if they are not managing the whole PostgreSQL instance - if !defined( 'postgresql::server' ) { - $manage_pg_hba_conf = true - } - else { - $manage_pg_hba_conf = $postgresql::server::manage_pg_hba_conf - } - - if $manage_pg_hba_conf == false { - fail('postgresql::server::manage_pg_hba_conf has been disabled, so this resource is now unused and redundant, either enable that option or remove this resource from your manifests') - } else { - validate_re($type, '^(local|host|hostssl|hostnossl)$', - "The type you specified [${type}] must be one of: local, host, hostssl, hostnosssl") - - if($type =~ /^host/ and $address == undef) { - fail('You must specify an address property when type is host based') - } - - $allowed_auth_methods = $postgresql_version ? { - '9.4' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam'], - '9.3' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam'], - '9.2' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam'], - '9.1' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam'], - '9.0' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'ldap', 'radius', 'cert', 'pam'], - '8.4' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'ldap', 'cert', 'pam'], - '8.3' => ['trust', 'reject', 'md5', 'crypt', 'password', 'gss', 'sspi', 'krb5', 'ident', 'ldap', 'pam'], - '8.2' => ['trust', 'reject', 'md5', 'crypt', 'password', 'krb5', 'ident', 'ldap', 'pam'], - '8.1' => ['trust', 'reject', 'md5', 'crypt', 'password', 'krb5', 'ident', 'pam'], - default => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam', 'crypt'] - } - - $auth_method_regex = join(['^(', join($allowed_auth_methods, '|'), ')$'],'') - validate_re($auth_method, $auth_method_regex, - join(["The auth_method you specified [${auth_method}] must be one of: ", join($allowed_auth_methods, ', ')],'')) - - # Create a rule fragment - $fragname = "pg_hba_rule_${name}" - concat::fragment { $fragname: - target => $target, - content => template('postgresql/pg_hba_rule.conf'), - order => $order, - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/pg_ident_rule.pp b/vagrant/puppet/modules/postgresql/manifests/server/pg_ident_rule.pp deleted file mode 100644 index 3e9cdcd35..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/pg_ident_rule.pp +++ /dev/null @@ -1,27 +0,0 @@ -# This resource manages an individual rule that applies to the file defined in -# $target. See README.md for more details. -define postgresql::server::pg_ident_rule( - $map_name, - $system_username, - $database_username, - $description = 'none', - $order = '150', - - # Needed for testing primarily, support for multiple files is not really - # working. - $target = $postgresql::server::pg_ident_conf_path -) { - - if $postgresql::server::manage_pg_ident_conf == false { - fail('postgresql::server::manage_pg_ident_conf has been disabled, so this resource is now unused and redundant, either enable that option or remove this resource from your manifests') - } else { - - # Create a rule fragment - $fragname = "pg_ident_rule_${name}" - concat::fragment { $fragname: - target => $target, - content => template('postgresql/pg_ident_rule.conf'), - order => $order, - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/plperl.pp b/vagrant/puppet/modules/postgresql/manifests/server/plperl.pp deleted file mode 100644 index 6ad5cf9b2..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/plperl.pp +++ /dev/null @@ -1,19 +0,0 @@ -# This class installs the PL/Perl procedural language for postgresql. See -# README.md for more details. -class postgresql::server::plperl( - $package_ensure = 'present', - $package_name = $postgresql::server::plperl_package_name -) { - package { 'postgresql-plperl': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - anchor { 'postgresql::server::plperl::start': }-> - Class['postgresql::server::install']-> - Package['postgresql-plperl']-> - Class['postgresql::server::service']-> - anchor { 'postgresql::server::plperl::end': } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/plpython.pp b/vagrant/puppet/modules/postgresql/manifests/server/plpython.pp deleted file mode 100644 index 962dbad62..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/plpython.pp +++ /dev/null @@ -1,19 +0,0 @@ -# This class installs the PL/Python procedural language for postgresql. See -# README.md for more details. -class postgresql::server::plpython( - $package_ensure = 'present', - $package_name = $postgresql::server::plpython_package_name, -) { - package { 'postgresql-plpython': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - anchor { 'postgresql::server::plpython::start': }-> - Class['postgresql::server::install']-> - Package['postgresql-plpython']-> - Class['postgresql::server::service']-> - anchor { 'postgresql::server::plpython::end': } - -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/postgis.pp b/vagrant/puppet/modules/postgresql/manifests/server/postgis.pp deleted file mode 100644 index ac4c64105..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/postgis.pp +++ /dev/null @@ -1,24 +0,0 @@ -# Install the postgis postgresql packaging. See README.md for more details. -class postgresql::server::postgis ( - $package_name = $postgresql::params::postgis_package_name, - $package_ensure = 'present' -) inherits postgresql::params { - validate_string($package_name) - - package { 'postgresql-postgis': - ensure => $package_ensure, - name => $package_name, - tag => 'postgresql', - } - - anchor { 'postgresql::server::postgis::start': }-> - Class['postgresql::server::install']-> - Package['postgresql-postgis']-> - Class['postgresql::server::service']-> - anchor { 'postgresql::server::postgis::end': } - - if $postgresql::globals::manage_package_repo { - Class['postgresql::repo'] -> - Package['postgresql-postgis'] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/recovery.pp b/vagrant/puppet/modules/postgresql/manifests/server/recovery.pp deleted file mode 100644 index 924866e96..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/recovery.pp +++ /dev/null @@ -1,38 +0,0 @@ -# This resource manages the parameters that applies to the recovery.conf template. See README.md for more details. -define postgresql::server::recovery( - $restore_command = undef, - $archive_cleanup_command = undef, - $recovery_end_command = undef, - $recovery_target_name = undef, - $recovery_target_time = undef, - $recovery_target_xid = undef, - $recovery_target_inclusive = undef, - $recovery_target = undef, - $recovery_target_timeline = undef, - $pause_at_recovery_target = undef, - $standby_mode = undef, - $primary_conninfo = undef, - $primary_slot_name = undef, - $trigger_file = undef, - $recovery_min_apply_delay = undef, - $target = $postgresql::server::recovery_conf_path -) { - - if $postgresql::server::manage_recovery_conf == false { - fail('postgresql::server::manage_recovery_conf has been disabled, so this resource is now unused and redundant, either enable that option or remove this resource from your manifests') - } else { - if($restore_command == undef and $archive_cleanup_command == undef and $recovery_end_command == undef - and $recovery_target_name == undef and $recovery_target_time == undef and $recovery_target_xid == undef - and $recovery_target_inclusive == undef and $recovery_target == undef and $recovery_target_timeline == undef - and $pause_at_recovery_target == undef and $standby_mode == undef and $primary_conninfo == undef - and $primary_slot_name == undef and $trigger_file == undef and $recovery_min_apply_delay == undef) { - fail('postgresql::server::recovery use this resource but do not pass a parameter will avoid creating the recovery.conf, because it makes no sense.') - } - - # Create the recovery.conf content - concat::fragment { 'recovery.conf': - target => $target, - content => template('postgresql/recovery.conf'), - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/reload.pp b/vagrant/puppet/modules/postgresql/manifests/server/reload.pp deleted file mode 100644 index 47f270452..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/reload.pp +++ /dev/null @@ -1,14 +0,0 @@ -# PRIVATE CLASS: do not use directly -class postgresql::server::reload { - $service_name = $postgresql::server::service_name - $service_status = $postgresql::server::service_status - $service_reload = $postgresql::server::service_reload - - exec { 'postgresql_reload': - path => '/usr/bin:/usr/sbin:/bin:/sbin', - command => $service_reload, - onlyif => $service_status, - refreshonly => true, - require => Class['postgresql::server::service'], - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/role.pp b/vagrant/puppet/modules/postgresql/manifests/server/role.pp deleted file mode 100644 index 3637b6908..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/role.pp +++ /dev/null @@ -1,122 +0,0 @@ -# Define for creating a database role. See README.md for more information -define postgresql::server::role( - $password_hash = false, - $createdb = false, - $createrole = false, - $db = $postgresql::server::default_database, - $port = undef, - $login = true, - $inherit = true, - $superuser = false, - $replication = false, - $connection_limit = '-1', - $username = $title, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $psql_user = $postgresql::server::user - $psql_group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - - # - # Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port - # - if $port != undef { - $port_override = $port - } elsif $connect_settings != undef and has_key( $connect_settings, 'PGPORT') { - $port_override = undef - } else { - $port_override = $postgresql::server::port - } - - # If possible use the version of the remote database, otherwise - # fallback to our local DB version - if $connect_settings != undef and has_key( $connect_settings, 'DBVERSION') { - $version = $connect_settings['DBVERSION'] - } else { - $version = $postgresql::server::_version - } - - $login_sql = $login ? { true => 'LOGIN', default => 'NOLOGIN' } - $inherit_sql = $inherit ? { true => 'INHERIT', default => 'NOINHERIT' } - $createrole_sql = $createrole ? { true => 'CREATEROLE', default => 'NOCREATEROLE' } - $createdb_sql = $createdb ? { true => 'CREATEDB', default => 'NOCREATEDB' } - $superuser_sql = $superuser ? { true => 'SUPERUSER', default => 'NOSUPERUSER' } - $replication_sql = $replication ? { true => 'REPLICATION', default => '' } - if ($password_hash != false) { - $environment = "NEWPGPASSWD=${password_hash}" - $password_sql = "ENCRYPTED PASSWORD '\$NEWPGPASSWD'" - } else { - $password_sql = '' - $environment = [] - } - - Postgresql_psql { - db => $db, - port => $port_override, - psql_user => $psql_user, - psql_group => $psql_group, - psql_path => $psql_path, - connect_settings => $connect_settings, - require => [ - Postgresql_psql["CREATE ROLE ${username} ENCRYPTED PASSWORD ****"], - Class['postgresql::server'], - ], - } - - postgresql_psql { "CREATE ROLE ${username} ENCRYPTED PASSWORD ****": - command => "CREATE ROLE \"${username}\" ${password_sql} ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql} CONNECTION LIMIT ${connection_limit}", - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'", - environment => $environment, - require => Class['Postgresql::Server'], - } - - postgresql_psql {"ALTER ROLE \"${username}\" ${superuser_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolsuper=${superuser}", - } - - postgresql_psql {"ALTER ROLE \"${username}\" ${createdb_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolcreatedb=${createdb}", - } - - postgresql_psql {"ALTER ROLE \"${username}\" ${createrole_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolcreaterole=${createrole}", - } - - postgresql_psql {"ALTER ROLE \"${username}\" ${login_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolcanlogin=${login}", - } - - postgresql_psql {"ALTER ROLE \"${username}\" ${inherit_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolinherit=${inherit}", - } - - if(versioncmp($version, '9.1') >= 0) { - if $replication_sql == '' { - postgresql_psql {"ALTER ROLE \"${username}\" NOREPLICATION": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolreplication=${replication}", - } - } else { - postgresql_psql {"ALTER ROLE \"${username}\" ${replication_sql}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolreplication=${replication}", - } - } - } - - postgresql_psql {"ALTER ROLE \"${username}\" CONNECTION LIMIT ${connection_limit}": - unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}' and rolconnlimit=${connection_limit}", - } - - if $password_hash { - if($password_hash =~ /^md5.+/) { - $pwd_hash_sql = $password_hash - } else { - $pwd_md5 = md5("${password_hash}${username}") - $pwd_hash_sql = "md5${pwd_md5}" - } - postgresql_psql { "ALTER ROLE ${username} ENCRYPTED PASSWORD ****": - command => "ALTER ROLE \"${username}\" ${password_sql}", - unless => "SELECT usename FROM pg_shadow WHERE usename='${username}' and passwd='${pwd_hash_sql}'", - environment => $environment, - } - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/schema.pp b/vagrant/puppet/modules/postgresql/manifests/server/schema.pp deleted file mode 100644 index 74a00dedb..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/schema.pp +++ /dev/null @@ -1,60 +0,0 @@ -# = Type: postgresql::server::schema -# -# Create a new schema. See README.md for more details. -# -# == Requires: -# -# The database must exist and the PostgreSQL user should have enough privileges -# -# == Sample Usage: -# -# postgresql::server::schema {'private': -# db => 'template1', -# } -# -define postgresql::server::schema( - $db = $postgresql::server::default_database, - $owner = undef, - $schema = $title, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $user = $postgresql::server::user - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - $version = $postgresql::server::_version - - # If the connection settings do not contain a port, then use the local server port - if $connect_settings != undef and has_key( $connect_settings, 'PGPORT') { - $port = undef - } else { - $port = $postgresql::server::port - } - - Postgresql_psql { - db => $db, - psql_user => $user, - psql_group => $group, - psql_path => $psql_path, - port => $port, - connect_settings => $connect_settings, - } - - $schema_title = "Create Schema '${title}'" - $authorization = $owner? { - undef => '', - default => "AUTHORIZATION \"${owner}\"", - } - - $schema_command = "CREATE SCHEMA \"${schema}\" ${authorization}" - $unless = "SELECT nspname FROM pg_namespace WHERE nspname='${schema}'" - - postgresql_psql { $schema_title: - command => $schema_command, - unless => $unless, - require => Class['postgresql::server'], - } - - if($owner != undef and defined(Postgresql::Server::Role[$owner])) { - Postgresql::Server::Role[$owner]->Postgresql_psql[$schema_title] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/service.pp b/vagrant/puppet/modules/postgresql/manifests/server/service.pp deleted file mode 100644 index de06818be..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/service.pp +++ /dev/null @@ -1,46 +0,0 @@ -# PRIVATE CLASS: do not call directly -class postgresql::server::service { - $service_ensure = $postgresql::server::service_ensure - $service_enable = $postgresql::server::service_enable - $service_manage = $postgresql::server::service_manage - $service_name = $postgresql::server::service_name - $service_provider = $postgresql::server::service_provider - $service_status = $postgresql::server::service_status - $user = $postgresql::server::user - $port = $postgresql::server::port - $default_database = $postgresql::server::default_database - - anchor { 'postgresql::server::service::begin': } - - if $service_manage { - - service { 'postgresqld': - ensure => $service_ensure, - enable => $service_enable, - name => $service_name, - provider => $service_provider, - hasstatus => true, - status => $service_status, - } - - if $service_ensure == 'running' { - # This blocks the class before continuing if chained correctly, making - # sure the service really is 'up' before continuing. - # - # Without it, we may continue doing more work before the database is - # prepared leading to a nasty race condition. - postgresql::validate_db_connection { 'validate_service_is_running': - run_as => $user, - database_name => $default_database, - database_port => $port, - sleep => 1, - tries => 60, - create_db_first => false, - require => Service['postgresqld'], - before => Anchor['postgresql::server::service::end'] - } - } - } - - anchor { 'postgresql::server::service::end': } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/server/table_grant.pp b/vagrant/puppet/modules/postgresql/manifests/server/table_grant.pp deleted file mode 100644 index 452f13d9d..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/table_grant.pp +++ /dev/null @@ -1,26 +0,0 @@ -# This resource wraps the grant resource to manage table grants specifically. -# See README.md for more details. -define postgresql::server::table_grant( - $privilege, - $table, - $db, - $role, - $port = undef, - $psql_db = undef, - $psql_user = undef, - $connect_settings = undef, - $onlyif_exists = false, -) { - postgresql::server::grant { "table:${name}": - role => $role, - db => $db, - port => $port, - privilege => $privilege, - object_type => 'TABLE', - object_name => $table, - psql_db => $psql_db, - psql_user => $psql_user, - onlyif_exists => $onlyif_exists, - connect_settings => $connect_settings, - } -} \ No newline at end of file diff --git a/vagrant/puppet/modules/postgresql/manifests/server/tablespace.pp b/vagrant/puppet/modules/postgresql/manifests/server/tablespace.pp deleted file mode 100644 index 8fb22b571..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/server/tablespace.pp +++ /dev/null @@ -1,56 +0,0 @@ -# This module creates tablespace. See README.md for more details. -define postgresql::server::tablespace( - $location, - $owner = undef, - $spcname = $title, - $connect_settings = $postgresql::server::default_connect_settings, -) { - $user = $postgresql::server::user - $group = $postgresql::server::group - $psql_path = $postgresql::server::psql_path - - # If the connection settings do not contain a port, then use the local server port - if $connect_settings != undef and has_key( $connect_settings, 'PGPORT') { - $port = undef - } else { - $port = $postgresql::server::port - } - - Postgresql_psql { - psql_user => $user, - psql_group => $group, - psql_path => $psql_path, - port => $port, - connect_settings => $connect_settings, - } - - if ($owner == undef) { - $owner_section = '' - } else { - $owner_section = "OWNER \"${owner}\"" - } - - $create_tablespace_command = "CREATE TABLESPACE \"${spcname}\" ${owner_section} LOCATION '${location}'" - - file { $location: - ensure => directory, - owner => $user, - group => $group, - mode => '0700', - seluser => 'system_u', - selrole => 'object_r', - seltype => 'postgresql_db_t', - require => Class['postgresql::server'], - } - - $create_ts = "Create tablespace '${spcname}'" - postgresql_psql { "Create tablespace '${spcname}'": - command => $create_tablespace_command, - unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'", - require => [Class['postgresql::server'], File[$location]], - } - - if($owner != undef and defined(Postgresql::Server::Role[$owner])) { - Postgresql::Server::Role[$owner]->Postgresql_psql[$create_ts] - } -} diff --git a/vagrant/puppet/modules/postgresql/manifests/validate_db_connection.pp b/vagrant/puppet/modules/postgresql/manifests/validate_db_connection.pp deleted file mode 100644 index bbdc94424..000000000 --- a/vagrant/puppet/modules/postgresql/manifests/validate_db_connection.pp +++ /dev/null @@ -1,91 +0,0 @@ -# This type validates that a successful postgres connection can be established -# between the node on which this resource is run and a specified postgres -# instance (host/port/user/password/database name). -# -# See README.md for more details. -define postgresql::validate_db_connection( - $database_host = undef, - $database_name = undef, - $database_password = undef, - $database_username = undef, - $database_port = undef, - $connect_settings = undef, - $run_as = undef, - $sleep = 2, - $tries = 10, - $create_db_first = true -) { - include postgresql::client - include postgresql::params - - $psql_path = $postgresql::params::psql_path - $validcon_script_path = $postgresql::client::validcon_script_path - - $cmd_init = "${psql_path} --tuples-only --quiet " - $cmd_host = $database_host ? { - undef => '', - default => "-h ${database_host} ", - } - $cmd_user = $database_username ? { - undef => '', - default => "-U ${database_username} ", - } - $cmd_port = $database_port ? { - undef => '', - default => "-p ${database_port} ", - } - $cmd_dbname = $database_name ? { - undef => "--dbname ${postgresql::params::default_database} ", - default => "--dbname ${database_name} ", - } - $pass_env = $database_password ? { - undef => undef, - default => "PGPASSWORD=${database_password}", - } - $cmd = join([$cmd_init, $cmd_host, $cmd_user, $cmd_port, $cmd_dbname], ' ') - $validate_cmd = "${validcon_script_path} ${sleep} ${tries} '${cmd}'" - - # This is more of a safety valve, we add a little extra to compensate for the - # time it takes to run each psql command. - $timeout = (($sleep + 2) * $tries) - - # Combine $database_password and $connect_settings into an array of environment - # variables, ensure $database_password is last, allowing it to override a password - # from the $connect_settings hash - if $connect_settings != undef { - if $pass_env != undef { - $env = concat(join_keys_to_values( $connect_settings, '='), $pass_env) - } else { - $env = join_keys_to_values( $connect_settings, '=') - } - } else { - $env = $pass_env - } - - $exec_name = "validate postgres connection for ${database_username}@${database_host}:${database_port}/${database_name}" - - exec { $exec_name: - command => "echo 'Unable to connect to defined database using: ${cmd}' && false", - unless => $validate_cmd, - cwd => '/tmp', - environment => $env, - logoutput => 'on_failure', - user => $run_as, - path => '/bin:/usr/bin:/usr/local/bin', - timeout => $timeout, - require => Class['postgresql::client'], - } - - # This is a little bit of puppet magic. What we want to do here is make - # sure that if the validation and the database instance creation are being - # applied on the same machine, then the database resource is applied *before* - # the validation resource. Otherwise, the validation is guaranteed to fail - # on the first run. - # - # We accomplish this by using Puppet's resource collection syntax to search - # for the Database resource in our current catalog; if it exists, the - # appropriate relationship is created here. - if($create_db_first) { - Postgresql::Server::Database<|title == $database_name|> -> Exec[$exec_name] - } -} diff --git a/vagrant/puppet/modules/postgresql/metadata.json b/vagrant/puppet/modules/postgresql/metadata.json deleted file mode 100644 index 2a59dc9d2..000000000 --- a/vagrant/puppet/modules/postgresql/metadata.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "puppetlabs-postgresql", - "version": "4.8.0", - "author": "Inkling/Puppet Labs", - "summary": "Offers support for basic management of PostgreSQL databases.", - "license": "Apache-2.0", - "source": "git://github.com/puppetlabs/puppetlabs-postgresql.git", - "project_page": "https://github.com/puppetlabs/puppetlabs-postgresql", - "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":"4.x"}, - {"name":"puppetlabs/apt","version_requirement":">=1.8.0 <3.0.0"}, - {"name":"puppetlabs/concat","version_requirement":">= 1.1.0 <3.0.0"} - ], - "data_provider": null, - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04", - "16.04" - ] - } - ], - "requirements": [ - { - "name": "puppet", - "version_requirement": ">= 3.0.0 < 5.0.0" - } - ] -} diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/00-utf8_encoding_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/00-utf8_encoding_spec.rb deleted file mode 100644 index 2e7770bed..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/00-utf8_encoding_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -# These tests are designed to ensure that the module, when ran with defaults, -# sets up everything correctly and allows us to connect to Postgres. -describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'with defaults' do - pp = <<-EOS - class { 'postgresql::globals': - encoding => 'UTF8', - locale => 'en_NG', - } -> - class { 'postgresql::server': } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe port(5432) do - it { is_expected.to be_listening } - end - - it 'can connect with psql' do - psql('--command="\l" postgres', 'postgres') do |r| - expect(r.stdout).to match(/List of databases/) - end - end - - it 'must set UTF8 as template1 encoding' do - psql('--command="SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname=\'template1\'"') do |r| - expect(r.stdout).to match(/UTF8/) - end - end -end - - - diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/alternative_port_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/alternative_port_spec.rb deleted file mode 100644 index 11094d36a..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/alternative_port_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper_acceptance' - -# These tests ensure that postgres can change itself to an alternative port -# properly. -describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'on an alternative port' do - pp = <<-EOS - class { 'postgresql::server': port => '55433' } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe port(55433) do - it { is_expected.to be_listening } - end - - it 'can connect with psql' do - psql('-p 55433 --command="\l" postgres', 'postgres') do |r| - expect(r.stdout).to match(/List of databases/) - end - end - -end - - - diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/db_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/db_spec.rb deleted file mode 100644 index 449c4b0fe..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/db_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'postgresql::server::db', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'creates a database' do - begin - tmpdir = default.tmpdir('postgresql') - pp = <<-EOS - class { 'postgresql::server': - postgres_password => 'space password', - } - postgresql::server::tablespace { 'postgresql-test-db': - location => '#{tmpdir}', - } -> - postgresql::server::db { 'postgresql-test-db': - comment => 'testcomment', - user => 'test-user', - password => 'test1', - tablespace => 'postgresql-test-db', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - - # Verify that the postgres password works - shell("echo 'localhost:*:*:postgres:space password' > /root/.pgpass") - shell("chmod 600 /root/.pgpass") - shell("psql -U postgres -h localhost --command='\\l'") - - psql('--command="select datname from pg_database" "postgresql-test-db"') do |r| - expect(r.stdout).to match(/postgresql-test-db/) - expect(r.stderr).to eq('') - end - - psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"') do |r| - expect(r.stdout).to match(/\(1 row\)/) - end - - result = shell('psql --version') - version = result.stdout.match(%r{\s(\d\.\d)})[1] - if version > "8.1" - comment_information_function = "shobj_description" - else - comment_information_function = "obj_description" - end - psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") do |r| - expect(r.stdout).to match(/\(1 row\)/) - end - ensure - psql('--command=\'drop database "postgresql-test-db" postgres\'') - psql('--command="DROP USER test"') - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/default_parameters_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/default_parameters_spec.rb deleted file mode 100644 index 47634828a..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/default_parameters_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper_acceptance' - -# These tests are designed to ensure that the module, when ran with defaults, -# sets up everything correctly and allows us to connect to Postgres. -describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'with defaults' do - pp = <<-EOS - class { 'postgresql::server': } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe port(5432) do - it { is_expected.to be_listening } - end - - it 'can connect with psql' do - psql('--command="\l" postgres', 'postgres') do |r| - expect(r.stdout).to match(/List of databases/) - end - end - -end - - - diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/centos-7-x64.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/centos-7-x64.yml deleted file mode 100644 index 1a40c8950..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/centos-7-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-7-x64: - roles: - - agent - - default - platform: redhat-7-x86_64 - hypervisor: vagrant - box: puppetlabs/centos-7.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/debian-8-x64.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/debian-8-x64.yml deleted file mode 100644 index fef6e63ca..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/debian-8-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - debian-8-x64: - roles: - - agent - - default - platform: debian-8-amd64 - hypervisor: vagrant - box: puppetlabs/debian-8.2-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/default.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/default.yml deleted file mode 100644 index dba339c46..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - roles: - - agent - - default - platform: ubuntu-14.04-amd64 - hypervisor: vagrant - box: puppetlabs/ubuntu-14.04-64-nocm -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/centos-7.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/centos-7.yml deleted file mode 100644 index a3333aac5..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/centos-7.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' - # install various tools required to get the image up to usable levels - docker_image_commands: - - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/debian-8.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/debian-8.yml deleted file mode 100644 index df5c31944..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/debian-8.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/ubuntu-14.04.yml deleted file mode 100644 index b1efa5839..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - # ensure that upstart is booting correctly in the container - - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/postgresql_psql_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/postgresql_psql_spec.rb deleted file mode 100644 index 34a258c5f..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/postgresql_psql_spec.rb +++ /dev/null @@ -1,183 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'postgresql_psql', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - - it 'should always run SQL' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select 1', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - - it 'should run some SQL when the unless query returns no rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select 1', - unless => 'select 1 where 1=2', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - - it 'should not run SQL when the unless query returns rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select * from pg_database limit 1', - unless => 'select 1 where 1=1', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - it 'should not run SQL when refreshed and the unless query returns rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - notify { 'trigger': } ~> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'invalid sql statement', - unless => 'select 1 where 1=1', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - - context 'with refreshonly' do - it 'should not run SQL when the unless query returns no rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select 1', - unless => 'select 1 where 1=2', - refreshonly => true, - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - it 'should run SQL when refreshed and the unless query returns no rows' do - pp = <<-EOS.unindent - class { 'postgresql::server': } -> - notify { 'trigger': } ~> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select 1', - unless => 'select 1 where 1=2', - refreshonly => true, - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - - it 'should not run SQL when refreshed and the unless query returns rows' do - pp = <<-EOS.unindent - class { 'postgresql::server': } -> - notify { 'trigger': } ~> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'invalid sql query', - unless => 'select 1 where 1=1', - refreshonly => true, - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - end - - it 'should not run some SQL when the onlyif query returns no rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select 1', - onlyif => 'select 1 where 1=2', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - it 'should run SQL when the onlyif query returns rows' do - pp = <<-EOS - class { 'postgresql::server': } -> - postgresql_psql { 'foobar': - db => 'postgres', - psql_user => 'postgres', - command => 'select * from pg_database limit 1', - onlyif => 'select 1 where 1=1', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => true) - end - - context 'with secure password passing by environment' do - it 'should run SQL that contanins password passed by environment' do - select = "select \\'$PASS_TO_EMBED\\'" - pp = <<-EOS.unindent - class { 'postgresql::server': } -> - postgresql_psql { 'password embedded by environment: #{select}': - db => 'postgres', - psql_user => 'postgres', - command => '#{select}', - environment => [ - 'PASS_TO_EMBED=pa$swD', - ], - } - EOS - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => false) - end - it 'should run SQL that contanins password passed by environment in check' do - select = "select 1 where \\'$PASS_TO_EMBED\\'=\\'passwD\\'" - pp = <<-EOS.unindent - class { 'postgresql::server': } -> - postgresql_psql { 'password embedded by environment in check: #{select}': - db => 'postgres', - psql_user => 'postgres', - command => 'invalid sql query', - unless => '#{select}', - environment => [ - 'PASS_TO_EMBED=passwD', - ], - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :expect_changes => false) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/remote_access_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/remote_access_spec.rb deleted file mode 100644 index 9dd31de1b..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/remote_access_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'remote-access', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - before do - skip "These tests require the spec/acceptance/nodesets/centos-64-x64-2-hosts nodeset" - end - - describe "configuring multi-node postgresql" do - - # Get the database's IP to connect to from the database - let(:database_ip_address) do - hosts_as('database').inject({}) do |memo,host| - fact_on host, "ipaddress_eth1" - end - end - - hosts_as('database').each do |host| - it "should be able to configure a host as database on #{host}" do - pp = <<-EOS - # Stop firewall so we can easily connect - service {'iptables': - ensure => 'stopped', - } - - class { 'postgresql::server': - ip_mask_allow_all_users => '0.0.0.0/0', - listen_addresses => '*', - } - - postgresql::server::db { 'puppet': - user => 'puppet', - password => postgresql_password('puppet', 'puppet'), - } - - postgresql::server::pg_hba_rule { 'allow full yolo access password': - type => 'host', - database => 'all', - user => 'all', - address => '0.0.0.0/0', - auth_method => 'password', - order => '002', - } - EOS - apply_manifest_on(host, pp, :catch_failures => true) - end - end - - hosts_as('client').each do |host| - it "should be able to configure a host as client on #{host} and then access database" do - pp = <<-EOS - class { 'postgresql::client':} - - $connection_settings = { - 'PGUSER' => "puppet", - 'PGPASSWORD' => "puppet", - 'PGHOST' => "#{database_ip_address}", - 'PGPORT' => "5432", - 'PGDATABASE' => "puppet", - } - - postgresql_psql { 'run using connection_settings': - command => 'select 1', - psql_user => 'root', - psql_group => 'root', - connect_settings => $connection_settings, - } - EOS - apply_manifest_on(host, pp, :catch_failures => true) - end - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/server/recovery_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/server/recovery_spec.rb deleted file mode 100644 index b27a5c5af..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/server/recovery_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'postgresql::server::recovery', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - describe 'should manage recovery' do - after(:all) do - pp = <<-EOS.unindent - file { '/tmp/recovery.conf': - ensure => absent, - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - it 'adds conf file' do - pp = <<-EOS.unindent - class { 'postgresql::globals': - recovery_conf_path => '/tmp/recovery.conf', - manage_recovery_conf => true, - } - - class { 'postgresql::server': } - - # Create a recovery.conf file - postgresql::server::recovery { "recovery.conf": - restore_command => 'restore_command', - recovery_target_timeline => 'recovery_target_timeline', - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file('/tmp/recovery.conf') do - it { is_expected.to be_file } - it { is_expected.to contain /restore_command = 'restore_command'/ } - it { is_expected.to contain /recovery_target_timeline = 'recovery_target_timeline'/ } - end - end - - describe 'should not manage recovery' do - it 'does not add conf file' do - pp = <<-EOS.unindent - class { 'postgresql::globals': - manage_recovery_conf => false, - } - - class { 'postgresql::server': } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file('/tmp/recovery.conf') do - it { is_expected.not_to be_file } - end - end -end - diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/server/schema_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/server/schema_spec.rb deleted file mode 100644 index 065ec6360..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/server/schema_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'postgresql::server::schema:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'should create a schema for a user' do - begin - pp = <<-EOS.unindent - $db = 'schema_test' - $user = 'psql_schema_tester' - $password = 'psql_schema_pw' - - class { 'postgresql::server': } - - # Since we are not testing pg_hba or any of that, make a local user for ident auth - user { $user: - ensure => present, - } - - postgresql::server::role { $user: - password_hash => postgresql_password($user, $password), - } - - postgresql::server::database { $db: - owner => $user, - require => Postgresql::Server::Role[$user], - } - - # Create a rule for the user - postgresql::server::pg_hba_rule { "allow ${user}": - type => 'local', - database => $db, - user => $user, - auth_method => 'ident', - order => 1, - } - - postgresql::server::schema { $user: - db => $db, - owner => $user, - require => Postgresql::Server::Database[$db], - } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - - ## Check that the user can create a table in the database - psql('--command="create table psql_schema_tester.foo (foo int)" schema_test', 'psql_schema_tester') do |r| - expect(r.stdout).to match(/CREATE TABLE/) - expect(r.stderr).to eq('') - end - ensure - psql('--command="drop table psql_schema_tester.foo" schema_test', 'psql_schema_tester') - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/acceptance/z_alternative_pgdata_spec.rb b/vagrant/puppet/modules/postgresql/spec/acceptance/z_alternative_pgdata_spec.rb deleted file mode 100644 index 9f80f96e2..000000000 --- a/vagrant/puppet/modules/postgresql/spec/acceptance/z_alternative_pgdata_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper_acceptance' - -# These tests ensure that postgres can change itself to an alternative pgdata -# location properly. - -# Allow postgresql to use /tmp/* as a datadir -if fact('osfamily') == 'RedHat' and fact('selinux') == 'true' - shell 'setenforce 0' -end - -describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - it 'on an alternative pgdata location' do - pp = <<-EOS - #file { '/var/lib/pgsql': ensure => directory, } -> - # needs_initdb will be true by default for all OS's except Debian - # in order to change the datadir we need to tell it explicitly to call initdb - class { 'postgresql::server': datadir => '/tmp/data', needs_initdb => true } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file('/tmp/data') do - it { should be_directory } - end - - it 'can connect with psql' do - psql('--command="\l" postgres', 'postgres') do |r| - expect(r.stdout).to match(/List of databases/) - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/spec.opts b/vagrant/puppet/modules/postgresql/spec/spec.opts deleted file mode 100644 index 91cd6427e..000000000 --- a/vagrant/puppet/modules/postgresql/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/vagrant/puppet/modules/postgresql/spec/spec_helper.rb b/vagrant/puppet/modules/postgresql/spec/spec_helper.rb deleted file mode 100644 index 22d5d689f..000000000 --- a/vagrant/puppet/modules/postgresql/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -#This file is generated by ModuleSync, do not edit. -require 'puppetlabs_spec_helper/module_spec_helper' - -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError -end diff --git a/vagrant/puppet/modules/postgresql/spec/spec_helper_acceptance.rb b/vagrant/puppet/modules/postgresql/spec/spec_helper_acceptance.rb deleted file mode 100644 index 2525ec3fc..000000000 --- a/vagrant/puppet/modules/postgresql/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' -require 'beaker/puppet_install_helper' - -run_puppet_install_helper - -UNSUPPORTED_PLATFORMS = ['AIX','windows','Solaris','Suse'] - -class String - # Provide ability to remove indentation from strings, for the purpose of - # left justifying heredoc blocks. - def unindent - gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "") - end -end - -def shellescape(str) - str = str.to_s - - # An empty argument will be skipped, so return empty quotes. - return "''" if str.empty? - - str = str.dup - - # Treat multibyte characters as is. It is caller's responsibility - # to encode the string in the right encoding for the shell - # environment. - str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1") - - # A LF cannot be escaped with a backslash because a backslash + LF - # combo is regarded as line continuation and simply ignored. - str.gsub!(/\n/, "'\n'") - - return str -end - -def psql(psql_cmd, user = 'postgres', exit_codes = [0,1], &block) - psql = "psql #{psql_cmd}" - shell("su #{shellescape(user)} -c #{shellescape(psql)}", :acceptable_exit_codes => exit_codes, &block) -end - - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'postgresql') - - # Set up selinux if appropriate. - if fact('osfamily') == 'RedHat' && fact('selinux') == 'true' - pp = <<-EOS - if $::osfamily == 'RedHat' and $::selinux == 'true' { - $semanage_package = $::operatingsystemmajrelease ? { - '5' => 'policycoreutils', - default => 'policycoreutils-python', - } - - package { $semanage_package: ensure => installed } - exec { 'set_postgres': - command => 'semanage port -a -t postgresql_port_t -p tcp 5433', - path => '/bin:/usr/bin/:/sbin:/usr/sbin', - subscribe => Package[$semanage_package], - } - } - EOS - - apply_manifest_on(agents, pp, :catch_failures => false) - end - - # net-tools required for netstat utility being used by be_listening - if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7' - pp = <<-EOS - package { 'net-tools': ensure => installed } - EOS - - apply_manifest_on(agents, pp, :catch_failures => false) - end - - hosts.each do |host| - on host, "/bin/touch #{default['puppetpath']}/hiera.yaml" - on host, 'chmod 755 /root' - if fact_on(host, 'osfamily') == 'Debian' - on host, "echo \"en_US ISO-8859-1\nen_NG.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n\" > /etc/locale.gen" - on host, '/usr/sbin/locale-gen' - on host, '/usr/sbin/update-locale' - end - - on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','install','puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','install','--force','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] } - end - - - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/spec_helper_local.rb b/vagrant/puppet/modules/postgresql/spec/spec_helper_local.rb deleted file mode 100644 index e25a51b70..000000000 --- a/vagrant/puppet/modules/postgresql/spec/spec_helper_local.rb +++ /dev/null @@ -1,14 +0,0 @@ -RSpec.configure do |c| - c.mock_with :rspec - - c.include PuppetlabsSpec::Files - c.after :each do - PuppetlabsSpec::Files.cleanup - end -end - -# Convenience helper for returning parameters for a type from the -# catalogue. -def param(type, title, param) - param_value(catalogue, type, title, param) -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/client_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/client_spec.rb deleted file mode 100644 index 3d63b4647..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/client_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::client', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - - describe 'with parameters' do - let :params do - { - :validcon_script_path => '/opt/bin/my-validate-con.sh', - :package_ensure => 'absent', - :package_name => 'mypackage', - :file_ensure => 'file' - } - end - - it 'should modify package' do - is_expected.to contain_package("postgresql-client").with({ - :ensure => 'absent', - :name => 'mypackage', - :tag => 'postgresql', - }) - end - - it 'should have specified validate connexion' do - should contain_file('/opt/bin/my-validate-con.sh').with({ - :ensure => 'file', - :owner => 0, - :group => 0, - :mode => '0755' - }) - end - end - - describe 'with no parameters' do - it 'should create package with postgresql tag' do - is_expected.to contain_package('postgresql-client').with({ - :tag => 'postgresql', - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/globals_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/globals_spec.rb deleted file mode 100644 index ce7933623..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/globals_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::globals', :type => :class do - context "on a debian 6" do - let (:facts) do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :lsbdistid => 'Debian', - :lsbdistcodename => 'squeeze', - } - end - - describe 'with no parameters' do - it 'should work' do - is_expected.to contain_class("postgresql::globals") - end - end - - describe 'manage_package_repo => true' do - let(:params) do - { - :manage_package_repo => true, - } - end - it 'should pull in class postgresql::repo' do - is_expected.to contain_class("postgresql::repo") - end - end - end - - context 'on redhat family systems' do - let (:facts) do - { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '7.1', - } - end - describe 'with no parameters' do - it 'should work' do - is_expected.to contain_class("postgresql::globals") - end - end - - describe 'manage_package_repo on RHEL => true' do - let(:params) do - { - :manage_package_repo => true, - :repo_proxy => 'http://proxy-server:8080', - } - end - - it 'should pull in class postgresql::repo' do - is_expected.to contain_class("postgresql::repo") - end - - it do - should contain_yumrepo('yum.postgresql.org').with( - 'enabled' => '1', - 'proxy' => 'http://proxy-server:8080' - ) - end - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/devel_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/devel_spec.rb deleted file mode 100644 index 17aa7f217..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/devel_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::lib::devel', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - it { is_expected.to contain_class("postgresql::lib::devel") } - - describe 'link pg_config to /usr/bin' do - it { should_not contain_file('/usr/bin/pg_config') \ - .with_ensure('link') \ - .with_target('/usr/lib/postgresql/8.4/bin/pg_config') - } - end - - describe 'disable link_pg_config' do - let(:params) {{ - :link_pg_config => false, - }} - it { should_not contain_file('/usr/bin/pg_config') } - end - - describe 'should not link pg_config on RedHat with default version' do - let(:facts) {{ - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.3', - :operatingsystemmajrelease => '6', - }} - it { should_not contain_file('/usr/bin/pg_config') } - end - - describe 'link pg_config on RedHat with non-default version' do - let(:facts) {{ - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.3', - :operatingsystemmajrelease => '6', - }} - let :pre_condition do - "class { '::postgresql::globals': version => '9.3' }" - end - - it { should contain_file('/usr/bin/pg_config') \ - .with_ensure('link') \ - .with_target('/usr/pgsql-9.3/bin/pg_config') - } - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/java_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/java_spec.rb deleted file mode 100644 index f31c3f032..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/java_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::lib::java', :type => :class do - - describe 'on a debian based os' do - let :facts do { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - it { is_expected.to contain_package('postgresql-jdbc').with( - :name => 'libpostgresql-jdbc-java', - :ensure => 'present', - :tag => 'postgresql' - )} - end - - describe 'on a redhat based os' do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - } - end - it { is_expected.to contain_package('postgresql-jdbc').with( - :name => 'postgresql-jdbc', - :ensure => 'present', - :tag => 'postgresql' - )} - describe 'when parameters are supplied' do - let :params do - {:package_ensure => 'latest', :package_name => 'somepackage'} - end - it { is_expected.to contain_package('postgresql-jdbc').with( - :name => 'somepackage', - :ensure => 'latest', - :tag => 'postgresql' - )} - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/perl_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/perl_spec.rb deleted file mode 100644 index 922cfa0b8..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/perl_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::lib::perl', :type => :class do - - describe 'on a redhat based os' do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - } - end - it { is_expected.to contain_package('perl-DBD-Pg').with( - :name => 'perl-DBD-Pg', - :ensure => 'present' - )} - end - - describe 'on a debian based os' do - let :facts do { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - it { is_expected.to contain_package('perl-DBD-Pg').with( - :name => 'libdbd-pg-perl', - :ensure => 'present' - )} - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/pgdocs_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/pgdocs_spec.rb deleted file mode 100644 index a751e987d..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/pgdocs_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::lib::docs', :type => :class do - - describe 'on a redhat based os' do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - } - end - it { is_expected.to contain_package('postgresql-docs').with( - :name => 'postgresql-docs', - :ensure => 'present', - :tag => 'postgresql' - )} - describe 'when parameters are supplied' do - let :params do - {:package_ensure => 'latest', :package_name => 'somepackage'} - end - it { is_expected.to contain_package('postgresql-docs').with( - :name => 'somepackage', - :ensure => 'latest', - :tag => 'postgresql' - )} - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/python_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/python_spec.rb deleted file mode 100644 index 095c2e15a..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/lib/python_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::lib::python', :type => :class do - - describe 'on a redhat based os' do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - } - end - it { is_expected.to contain_package('python-psycopg2').with( - :name => 'python-psycopg2', - :ensure => 'present' - )} - end - - describe 'on a debian based os' do - let :facts do { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - it { is_expected.to contain_package('python-psycopg2').with( - :name => 'python-psycopg2', - :ensure => 'present' - )} - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/params_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/params_spec.rb deleted file mode 100644 index a415966e1..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/params_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::params', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - it { is_expected.to contain_class("postgresql::params") } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/repo_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/repo_spec.rb deleted file mode 100644 index a9be84e7c..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/repo_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::repo', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :lsbdistid => 'Debian', - :lsbdistcodename => 'squeeze', - } - end - - describe 'with no parameters' do - it 'should instantiate apt_postgresql_org class' do - is_expected.to contain_class('postgresql::repo::apt_postgresql_org') - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/config_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/config_spec.rb deleted file mode 100644 index c03032d9b..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/config_spec.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::config', :type => :class do - let (:pre_condition) do - "include postgresql::server" - end - - describe 'on RedHat 7' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '7.0', - :concat_basedir => tmpfilename('server'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it 'should have the correct systemd-override file' do - is_expected.to contain_file('systemd-override').with ({ - :ensure => 'present', - :path => '/etc/systemd/system/postgresql.service', - :owner => 'root', - :group => 'root', - }) - is_expected.to contain_file('systemd-override') \ - .with_content(/.include \/usr\/lib\/systemd\/system\/postgresql.service/) - end - - describe 'with manage_package_repo => true and a version' do - let (:pre_condition) do - <<-EOS - class { 'postgresql::globals': - manage_package_repo => true, - version => '9.4', - }-> - class { 'postgresql::server': } - EOS - end - - it 'should have the correct systemd-override file' do - is_expected.to contain_file('systemd-override').with ({ - :ensure => 'present', - :path => '/etc/systemd/system/postgresql-9.4.service', - :owner => 'root', - :group => 'root', - }) - is_expected.to contain_file('systemd-override') \ - .with_content(/.include \/usr\/lib\/systemd\/system\/postgresql-9.4.service/) - end - end - end - - describe 'on Fedora 21' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'Fedora', - :operatingsystemrelease => '21', - :concat_basedir => tmpfilename('server'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it 'should have the correct systemd-override file' do - is_expected.to contain_file('systemd-override').with ({ - :ensure => 'present', - :path => '/etc/systemd/system/postgresql.service', - :owner => 'root', - :group => 'root', - }) - is_expected.to contain_file('systemd-override') \ - .with_content(/.include \/lib\/systemd\/system\/postgresql.service/) - end - - describe 'with manage_package_repo => true and a version' do - let (:pre_condition) do - <<-EOS - class { 'postgresql::globals': - manage_package_repo => true, - version => '9.4', - }-> - class { 'postgresql::server': } - EOS - end - - it 'should have the correct systemd-override file' do - is_expected.to contain_file('systemd-override').with ({ - :ensure => 'present', - :path => '/etc/systemd/system/postgresql-9.4.service', - :owner => 'root', - :group => 'root', - }) - is_expected.to contain_file('systemd-override') \ - .with_content(/.include \/lib\/systemd\/system\/postgresql-9.4.service/) - end - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/contrib_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/contrib_spec.rb deleted file mode 100644 index b84f764d0..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/contrib_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::contrib', :type => :class do - let :pre_condition do - "class { 'postgresql::server': }" - end - - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - describe 'with parameters' do - let(:params) do - { - :package_name => 'mypackage', - :package_ensure => 'absent', - } - end - - it 'should create package with correct params' do - is_expected.to contain_package('postgresql-contrib').with({ - :ensure => 'absent', - :name => 'mypackage', - :tag => 'postgresql', - }) - end - end - - describe 'with no parameters' do - it 'should create package with postgresql tag' do - is_expected.to contain_package('postgresql-contrib').with({ - :tag => 'postgresql', - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/initdb_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/initdb_spec.rb deleted file mode 100644 index 5ddfb7004..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/initdb_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::initdb', :type => :class do - let (:pre_condition) do - "include postgresql::server" - end - describe 'on RedHat' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.0', - :concat_basedir => tmpfilename('server'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it { is_expected.to contain_file('/var/lib/pgsql/data').with_ensure('directory') } - end - describe 'on Amazon' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'Amazon', - :operatingsystemrelease => '1.0', - :concat_basedir => tmpfilename('server'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it { is_expected.to contain_file('/var/lib/pgsql92/data').with_ensure('directory') } - end -end - diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plperl_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plperl_spec.rb deleted file mode 100644 index 00ddf09c5..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plperl_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::plperl', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('plperl'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :pre_condition do - "class { 'postgresql::server': }" - end - - describe 'with no parameters' do - it { is_expected.to contain_class("postgresql::server::plperl") } - it 'should create package' do - is_expected.to contain_package('postgresql-plperl').with({ - :ensure => 'present', - :tag => 'postgresql', - }) - end - end - - describe 'with parameters' do - let :params do - { - :package_ensure => 'absent', - :package_name => 'mypackage', - } - end - - it { is_expected.to contain_class("postgresql::server::plperl") } - it 'should create package with correct params' do - is_expected.to contain_package('postgresql-plperl').with({ - :ensure => 'absent', - :name => 'mypackage', - :tag => 'postgresql', - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plpython_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plpython_spec.rb deleted file mode 100644 index f2e165411..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/plpython_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::plpython', :type => :class do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.0', - :concat_basedir => tmpfilename('plpython'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :pre_condition do - "class { 'postgresql::server': }" - end - - describe 'on RedHat with no parameters' do - it { is_expected.to contain_class("postgresql::server::plpython") } - it 'should create package' do - is_expected.to contain_package('postgresql-plpython').with({ - :ensure => 'present', - :tag => 'postgresql', - }) - end - end - - describe 'with parameters' do - let :params do - { - :package_ensure => 'absent', - :package_name => 'mypackage', - } - end - - it { is_expected.to contain_class("postgresql::server::plpython") } - it 'should create package with correct params' do - is_expected.to contain_package('postgresql-plpython').with({ - :ensure => 'absent', - :name => 'mypackage', - :tag => 'postgresql', - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/postgis_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server/postgis_spec.rb deleted file mode 100644 index 1e53c21c5..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server/postgis_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::postgis', :type => :class do - let :pre_condition do - "class { 'postgresql::server': }" - end - - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('postgis'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - describe 'with parameters' do - let(:params) do - { - :package_name => 'mypackage', - :package_ensure => 'absent', - } - end - - it 'should create package with correct params' do - is_expected.to contain_package('postgresql-postgis').with({ - :ensure => 'absent', - :name => 'mypackage', - :tag => 'postgresql', - }) - end - end - - describe 'with no parameters' do - it 'should create package with postgresql tag' do - is_expected.to contain_package('postgresql-postgis').with({ - :tag => 'postgresql', - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/classes/server_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/classes/server_spec.rb deleted file mode 100644 index 852b7e497..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/classes/server_spec.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server', :type => :class do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :lsbdistid => 'Debian', - :lsbdistcodename => 'jessie', - :operatingsystemrelease => '8.0', - :concat_basedir => tmpfilename('server'), - :kernel => 'Linux', - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - describe 'with no parameters' do - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it { is_expected.to contain_exec('postgresql_reload').with({ - 'command' => 'service postgresql reload', - }) - } - it 'should validate connection' do - is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'service_ensure => running' do - let(:params) do - { - :service_ensure => 'running', - :postgres_password => 'new-p@s$word-to-set' - } - end - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it { is_expected.to contain_class("postgresql::server::passwd") } - it 'should validate connection' do - is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running') - end - it 'should set postgres password' do - is_expected.to contain_exec('set_postgres_postgrespw').with({ - 'command' => '/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"', - 'user' => 'postgres', - 'environment' => [ - "PGPASSWORD=new-p@s$word-to-set", - "PGPORT=5432", - "NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$" - ], - 'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null", - }) - end - end - - describe 'service_ensure => stopped' do - let(:params) {{ :service_ensure => 'stopped' }} - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it 'shouldnt validate connection' do - is_expected.not_to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'service_restart_on_change => false' do - let(:params) {{ :service_restart_on_change => false }} - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it { is_expected.to_not contain_Postgresql_conf('data_directory').that_notifies('Class[postgresql::server::service]') - } - it 'should validate connection' do - is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'service_restart_on_change => true' do - let(:params) {{ :service_restart_on_change => true }} - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it { is_expected.to contain_Postgresql_conf('data_directory').that_notifies('Class[postgresql::server::service]') - } - it 'should validate connection' do - is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'service_reload => /bin/true' do - let(:params) {{ :service_reload => '/bin/true' }} - it { is_expected.to contain_class("postgresql::params") } - it { is_expected.to contain_class("postgresql::server") } - it { is_expected.to contain_exec('postgresql_reload').with({ - 'command' => '/bin/true', - }) - } - it 'should validate connection' do - is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'service_manage => true' do - let(:params) {{ :service_manage => true }} - it { is_expected.to contain_service('postgresqld') } - end - - describe 'service_manage => false' do - let(:params) {{ :service_manage => false }} - it { is_expected.not_to contain_service('postgresqld') } - it 'shouldnt validate connection' do - is_expected.not_to contain_postgresql__validate_db_connection('validate_service_is_running') - end - end - - describe 'package_ensure => absent' do - let(:params) do - { - :package_ensure => 'absent', - } - end - - it 'should remove the package' do - is_expected.to contain_package('postgresql-server').with({ - :ensure => 'purged', - }) - end - - it 'should still enable the service' do - is_expected.to contain_service('postgresqld').with({ - :ensure => 'running', - }) - end - end - - describe 'needs_initdb => true' do - let(:params) do - { - :needs_initdb => true, - } - end - - it 'should contain proper initdb exec' do - is_expected.to contain_exec('postgresql_initdb') - end - end - - describe 'postgresql_version' do - let(:pre_condition) do - <<-EOS - class { 'postgresql::globals': - manage_package_repo => true, - version => '99.5', - before => Class['postgresql::server'], - } - EOS - end - it 'contains the correct package version' do - is_expected.to contain_class('postgresql::repo').with_version('99.5') - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/config_entry_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/config_entry_spec.rb deleted file mode 100644 index 34963b8bf..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/config_entry_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::config_entry', :type => :define do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let(:title) { 'config_entry'} - - let :target do - tmpfilename('postgresql_conf') - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - context "syntax check" do - let(:params) { { :ensure => 'present'} } - it { is_expected.to contain_postgresql__server__config_entry('config_entry') } - end - - context 'ports' do - context 'redhat 6' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.4', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let(:params) {{ :ensure => 'present', :name => 'port_spec', :value => '5432' }} - - it 'stops postgresql and changes the port' do - is_expected.to contain_exec('postgresql_stop_port') - is_expected.to contain_augeas('override PGPORT in /etc/sysconfig/pgsql/postgresql') - end - end - context 'redhat 7' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '7.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let(:params) {{ :ensure => 'present', :name => 'port_spec', :value => '5432' }} - - it 'stops postgresql and changes the port' do - is_expected.to contain_file('systemd-override') - is_expected.to contain_exec('restart-systemd') - end - end - context 'fedora 19' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystem => 'Fedora', - :operatingsystemrelease => '19', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let(:params) {{ :ensure => 'present', :name => 'port_spec', :value => '5432' }} - - it 'stops postgresql and changes the port' do - is_expected.to contain_file('systemd-override') - is_expected.to contain_exec('restart-systemd') - end - end - end - - context "data_directory" do - let(:params) {{ :ensure => 'present', :name => 'data_directory_spec', :value => '/var/pgsql' }} - - it 'stops postgresql and changes the data directory' do - is_expected.to contain_exec('postgresql_data_directory') - is_expected.to contain_augeas('override PGDATA in /etc/sysconfig/pgsql/postgresql') - end - end - - context "passes values through appropriately" do - let(:params) {{ :ensure => 'present', :name => 'check_function_bodies', :value => 'off' }} - - it 'with no quotes' do - is_expected.to contain_postgresql_conf('check_function_bodies').with({ - :name => 'check_function_bodies', - :value => 'off' }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_grant_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_grant_spec.rb deleted file mode 100644 index 19dfce99f..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_grant_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::database_grant', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - let :params do - { - :privilege => 'ALL', - :db => 'test', - :role => 'test', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__database_grant('test') } - it { is_expected.to contain_postgresql__server__grant('database:test') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_spec.rb deleted file mode 100644 index 232ee31a3..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/database_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::database', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let :title do - 'test' - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__database('test') } - it { is_expected.to contain_postgresql_psql("Create db 'test'") } - - context "with comment set to 'test comment'" do - let (:params) {{ :comment => 'test comment' }} - - it { is_expected.to contain_postgresql_psql("COMMENT ON DATABASE \"test\" IS 'test comment'").with_connect_settings( {} ) } - end - - context "with specific db connection settings - default port" do - let :pre_condition do - "class {'postgresql::server':}" - end - - let (:params) {{ :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', }}} - - it { is_expected.to contain_postgresql_psql("Create db 'test'").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1' } ).with_port( 5432 ) } - end - - context "with specific db connection settings - including port" do - let :pre_condition do - "class {'postgresql::globals':} - - class {'postgresql::server':}" - end - - let (:params) {{ :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234' }}} - - it { is_expected.to contain_postgresql_psql("Create db 'test'").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ).with_port( nil ) } - - end - - context "with global db connection settings - including port" do - let :pre_condition do - "class {'postgresql::globals': - default_connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.2', - 'PGPORT' => '1234' } - } - - class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql_psql("Create db 'test'").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.2','PGPORT' => '1234' } ).with_port( nil ) } - - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/db_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/db_spec.rb deleted file mode 100644 index 78e36b002..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/db_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::db', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - context 'without dbname param' do - - let :params do - { - :user => 'test', - :password => 'test', - :owner => 'tester', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__db('test') } - it { is_expected.to contain_postgresql__server__database('test').with_owner('tester') } - it { is_expected.to contain_postgresql__server__role('test').that_comes_before('Postgresql::Server::Database[test]') } - it { is_expected.to contain_postgresql__server__database_grant('GRANT test - ALL - test') } - - end - - context 'dbname' do - - let :params do - { - :dbname => 'testtest', - :user => 'test', - :password => 'test', - :owner => 'tester', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__database('testtest') } - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/extension_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/extension_spec.rb deleted file mode 100644 index 54386a165..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/extension_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::extension', :type => :define do - let :pre_condition do - "class { 'postgresql::server': } - postgresql::server::database { 'template_postgis': - template => 'template1', - }" - end - - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('postgis'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let (:title) { 'postgis' } - let (:params) { { - :database => 'template_postgis', - } } - - context "with mandatory arguments only" do - it { - is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({ - :db => 'template_postgis', - :command => 'CREATE EXTENSION "postgis"', - :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count = 1", - }).that_requires('Postgresql::Server::Database[template_postgis]') - } - end - - context "when setting package name" do - let (:params) { super().merge({ - :package_name => 'postgis', - }) } - - it { - is_expected.to contain_package('postgis').with({ - :ensure => 'present', - :name => 'postgis', - }).that_comes_before('Postgresql_psql[Add postgis extension to template_postgis]') - } - end - - context "when ensuring absence" do - let (:params) { super().merge({ - :ensure => 'absent', - :package_name => 'postgis', - }) } - - it { - is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({ - :db => 'template_postgis', - :command => 'DROP EXTENSION "postgis"', - :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count != 1", - }).that_requires('Postgresql::Server::Database[template_postgis]') - } - - it { - is_expected.to contain_package('postgis').with({ - :ensure => 'absent', - :name => 'postgis', - }) - } - - context "when keeping package installed" do - let (:params) { super().merge({ - :package_ensure => 'present', - }) } - - it { - is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({ - :db => 'template_postgis', - :command => 'DROP EXTENSION "postgis"', - :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count != 1", - }).that_requires('Postgresql::Server::Database[template_postgis]') - } - - it { - is_expected.to contain_package('postgis').with({ - :ensure => 'present', - :name => 'postgis', - }).that_requires('Postgresql_psql[Add postgis extension to template_postgis]') - } - end - end -end - -describe 'postgresql::server::extension', :type => :define do - let :pre_condition do - "class { 'postgresql::server': } - postgresql::server::database { 'template_postgis2': - template => 'template1', - }" - end - - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('postgis'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let (:title) { 'postgis_db2' } - let (:params) { { - :database => 'template_postgis2', - :extension => 'postgis', - } } - - context "with mandatory arguments only" do - it { - is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis2').with({ - :db => 'template_postgis2', - :command => 'CREATE EXTENSION "postgis"', - :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count = 1", - }).that_requires('Postgresql::Server::Database[template_postgis2]') - } - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/grant_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/grant_spec.rb deleted file mode 100644 index 45d9cce5f..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/grant_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::grant', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - context 'plain' do - let :params do - { - :db => 'test', - :role => 'test', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - end - - context 'sequence' do - let :params do - { - :db => 'test', - :role => 'test', - :privilege => 'usage', - :object_type => 'sequence', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - it { is_expected.to contain_postgresql_psql('grant:test').with( - { - 'command' => "GRANT USAGE ON SEQUENCE \"test\" TO\n \"test\"", - 'unless' => "SELECT 1 WHERE has_sequence_privilege('test',\n 'test', 'USAGE')", - }) } - end - - context 'all sequences' do - let :params do - { - :db => 'test', - :role => 'test', - :privilege => 'usage', - :object_type => 'all sequences in schema', - :object_name => 'public', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - it { is_expected.to contain_postgresql_psql('grant:test').with( - { - 'command' => "GRANT USAGE ON ALL SEQUENCES IN SCHEMA \"public\" TO\n \"test\"", - 'unless' => "SELECT 1 FROM (\n SELECT sequence_name\n FROM information_schema.sequences\n WHERE sequence_schema='public'\n EXCEPT DISTINCT\n SELECT object_name as sequence_name\n FROM information_schema.role_usage_grants\n WHERE object_type='SEQUENCE'\n AND grantee='test'\n AND object_schema='public'\n AND privilege_type='USAGE'\n ) P\n HAVING count(P.sequence_name) = 0", - }) } - end - - context "with specific db connection settings - default port" do - let :params do - { - :db => 'test', - :role => 'test', - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', }, - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1' } ).with_port( 5432 ) } - end - - context "with specific db connection settings - including port" do - let :params do - { - :db => 'test', - :role => 'test', - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234', }, - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ) } - end - - context "with specific db connection settings - port overriden by explicit parameter" do - let :params do - { - :db => 'test', - :role => 'test', - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234', }, - :port => '5678', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__grant('test') } - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ).with_port( '5678' ) } - end -end \ No newline at end of file diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_hba_rule_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_hba_rule_spec.rb deleted file mode 100644 index f36d27dda..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_hba_rule_spec.rb +++ /dev/null @@ -1,198 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::pg_hba_rule', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('pg_hba'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let :title do - 'test' - end - let :target do - tmpfilename('pg_hba_rule') - end - - context 'test template 1' do - let :pre_condition do - <<-EOS - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'host', - :database => 'all', - :user => 'all', - :address => '1.1.1.1/24', - :auth_method => 'md5', - :target => target, - } - end - it do - is_expected.to contain_concat__fragment('pg_hba_rule_test').with({ - :content => /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/ - }) - end - end - - context 'test template 2' do - let :pre_condition do - <<-EOS - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'local', - :database => 'all', - :user => 'all', - :auth_method => 'ident', - :target => target, - } - end - it do - is_expected.to contain_concat__fragment('pg_hba_rule_test').with({ - :content => /local\s+all\s+all\s+ident/ - }) - end - end - - context 'test template 3' do - let :pre_condition do - <<-EOS - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'host', - :database => 'all', - :user => 'all', - :address => '0.0.0.0/0', - :auth_method => 'ldap', - :auth_option => 'foo=bar', - :target => target, - } - end - it do - is_expected.to contain_concat__fragment('pg_hba_rule_test').with({ - :content => /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/ - }) - end - end - - context 'validation' do - context 'validate type test 1' do - let :pre_condition do - <<-EOS - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'invalid', - :database => 'all', - :user => 'all', - :address => '0.0.0.0/0', - :auth_method => 'ldap', - :target => target, - } - end - it 'should fail parsing when type is not valid' do - expect { catalogue }.to raise_error(Puppet::Error, - /The type you specified \[invalid\] must be one of/) - end - end - - context 'validate auth_method' do - let :pre_condition do - <<-EOS - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'local', - :database => 'all', - :user => 'all', - :address => '0.0.0.0/0', - :auth_method => 'invalid', - :target => target, - } - end - - it 'should fail parsing when auth_method is not valid' do - expect { catalogue }.to raise_error(Puppet::Error, - /The auth_method you specified \[invalid\] must be one of/) - end - end - - context 'validate unsupported auth_method' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - version => '9.0', - } - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'local', - :database => 'all', - :user => 'all', - :address => '0.0.0.0/0', - :auth_method => 'peer', - :target => target, - } - end - - it 'should fail parsing when auth_method is not valid' do - expect { catalogue }.to raise_error(Puppet::Error, - /The auth_method you specified \[peer\] must be one of: trust, reject, md5, password, gss, sspi, krb5, ident, ldap, radius, cert, pam/) - end - end - - context 'validate supported auth_method' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - version => '9.2', - } - class { 'postgresql::server': } - EOS - end - - let :params do - { - :type => 'local', - :database => 'all', - :user => 'all', - :address => '0.0.0.0/0', - :auth_method => 'peer', - :target => target, - } - end - - it do - is_expected.to contain_concat__fragment('pg_hba_rule_test').with({ - :content => /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/ - }) - end - end - - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_ident_rule_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_ident_rule_spec.rb deleted file mode 100644 index 71dfff866..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/pg_ident_rule_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::pg_ident_rule', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('pg_ident'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let :title do - 'test' - end - let :target do - tmpfilename('pg_ident_rule') - end - - context 'managing pg_ident' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_pg_ident_conf => true, - } - class { 'postgresql::server': } - EOS - end - - let :params do - { - :map_name => 'thatsmymap', - :system_username => 'systemuser', - :database_username => 'dbuser', - } - end - it do - is_expected.to contain_concat__fragment('pg_ident_rule_test').with({ - :content => /thatsmymap\s+systemuser\s+dbuser/ - }) - end - end - context 'not managing pg_ident' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_pg_ident_conf => false, - } - class { 'postgresql::server': } - EOS - end - let :params do - { - :map_name => 'thatsmymap', - :system_username => 'systemuser', - :database_username => 'dbuser', - } - end - it 'should fail because $manage_pg_ident_conf is false' do - expect { catalogue }.to raise_error(Puppet::Error, - /postgresql::server::manage_pg_ident_conf has been disabled/) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/recovery_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/recovery_spec.rb deleted file mode 100644 index 8c78e3ec3..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/recovery_spec.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::recovery', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('recovery'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - let :title do - 'test' - end - let :target do - tmpfilename('recovery') - end - - context 'managing recovery' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_recovery_conf => true, - } - class { 'postgresql::server': } - EOS - end - - let :params do - { - :restore_command => 'restore_command', - :recovery_target_timeline => 'recovery_target_timeline', - } - end - it do - is_expected.to contain_concat__fragment('recovery.conf').with({ - :content => /restore_command = 'restore_command'[\n]+recovery_target_timeline = 'recovery_target_timeline'/ - }) - end - end - context 'not managing recovery' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_recovery_conf => false, - } - class { 'postgresql::server': } - EOS - end - let :params do - { - :restore_command => '', - } - end - it 'should fail because $manage_recovery_conf is false' do - expect { catalogue }.to raise_error(Puppet::Error, - /postgresql::server::manage_recovery_conf has been disabled/) - end - end - context 'not managing recovery, missing param' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_recovery_conf => true, - } - class { 'postgresql::server': } - EOS - end - it 'should fail because no param set' do - expect { catalogue }.to raise_error(Puppet::Error, - /postgresql::server::recovery use this resource but do not pass a parameter will avoid creating the recovery.conf, because it makes no sense./) - end - end - - context 'managing recovery with all params' do - let :pre_condition do - <<-EOS - class { 'postgresql::globals': - manage_recovery_conf => true, - } - class { 'postgresql::server': } - EOS - end - - let :params do - { - :restore_command => 'restore_command', - :archive_cleanup_command => 'archive_cleanup_command', - :recovery_end_command => 'recovery_end_command', - :recovery_target_name => 'recovery_target_name', - :recovery_target_time => 'recovery_target_time', - :recovery_target_xid => 'recovery_target_xid', - :recovery_target_inclusive => true, - :recovery_target => 'recovery_target', - :recovery_target_timeline => 'recovery_target_timeline', - :pause_at_recovery_target => true, - :standby_mode => 'on', - :primary_conninfo => 'primary_conninfo', - :primary_slot_name => 'primary_slot_name', - :trigger_file => 'trigger_file', - :recovery_min_apply_delay => 0, - } - end - it do - is_expected.to contain_concat__fragment('recovery.conf').with({ - :content => /restore_command = 'restore_command'[\n]+archive_cleanup_command = 'archive_cleanup_command'[\n]+recovery_end_command = 'recovery_end_command'[\n]+recovery_target_name = 'recovery_target_name'[\n]+recovery_target_time = 'recovery_target_time'[\n]+recovery_target_xid = 'recovery_target_xid'[\n]+recovery_target_inclusive = true[\n]+recovery_target = 'recovery_target'[\n]+recovery_target_timeline = 'recovery_target_timeline'[\n]+pause_at_recovery_target = true[\n]+standby_mode = on[\n]+primary_conninfo = 'primary_conninfo'[\n]+primary_slot_name = 'primary_slot_name'[\n]+trigger_file = 'trigger_file'[\n]+recovery_min_apply_delay = 0[\n]+/ - }) - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/role_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/role_spec.rb deleted file mode 100644 index 88833a113..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/role_spec.rb +++ /dev/null @@ -1,135 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::role', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('contrib'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - let :params do - { - :password_hash => 'new-pa$s', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__role('test') } - it 'should have create role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "CREATE ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT rolname FROM pg_roles WHERE rolname='test'", - 'port' => "5432", - }) - end - it 'should have alter role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "ALTER ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD'", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT usename FROM pg_shadow WHERE usename='test' and passwd='md5b6f7fcbbabb4befde4588a26c1cfd2fa'", - 'port' => "5432", - }) - end - - context "with specific db connection settings - default port" do - let :params do - { - :password_hash => 'new-pa$s', - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__role('test') } - it 'should have create role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "CREATE ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT rolname FROM pg_roles WHERE rolname='test'", - 'port' => "5432", - - 'connect_settings' => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - }) - end - it 'should have alter role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "ALTER ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD'", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT usename FROM pg_shadow WHERE usename='test' and passwd='md5b6f7fcbbabb4befde4588a26c1cfd2fa'", - 'port' => "5432", - - 'connect_settings' => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - }) - end - end - - context "with specific db connection settings - including port" do - let :params do - { - :password_hash => 'new-pa$s', - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__role('test') } - it 'should have create role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "CREATE ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT rolname FROM pg_roles WHERE rolname='test'", - 'connect_settings' => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - }) - end - it 'should have alter role for "test" user with password as ****' do - is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****').with({ - 'command' => "ALTER ROLE \"test\" ENCRYPTED PASSWORD '$NEWPGPASSWD'", - 'environment' => "NEWPGPASSWD=new-pa$s", - 'unless' => "SELECT usename FROM pg_shadow WHERE usename='test' and passwd='md5b6f7fcbbabb4befde4588a26c1cfd2fa'", - 'connect_settings' => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', - 'PGPORT' => '1234', - 'PGUSER' => 'login-user', - 'PGPASSWORD' => 'login-pass' }, - }) - end - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/schema_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/schema_spec.rb deleted file mode 100644 index f5d106fae..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/schema_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::schema', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('schema'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - let :params do - { - :owner => 'jane', - :db => 'janedb', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { should contain_postgresql__server__schema('test') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/table_grant_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/table_grant_spec.rb deleted file mode 100644 index eac55bd60..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/table_grant_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::table_grant', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('table_grant'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - let :params do - { - :privilege => 'ALL', - :db => 'test', - :role => 'test', - :table => 'foo', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__table_grant('test') } - it { is_expected.to contain_postgresql__server__grant('table:test') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/tablespace_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/server/tablespace_spec.rb deleted file mode 100644 index 560a50eee..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/server/tablespace_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::server::tablespace', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - :kernel => 'Linux', - :concat_basedir => tmpfilename('tablespace'), - :id => 'root', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - - let :title do - 'test' - end - - let :params do - { - :location => '/srv/data/foo', - } - end - - let :pre_condition do - "class {'postgresql::server':}" - end - - it { is_expected.to contain_postgresql__server__tablespace('test') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/defines/validate_db_connection_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/defines/validate_db_connection_spec.rb deleted file mode 100644 index 9cf5048f4..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/defines/validate_db_connection_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'spec_helper' - -describe 'postgresql::validate_db_connection', :type => :define do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6.0', - } - end - - let :title do - 'test' - end - - describe 'should work with only default parameters' do - it { is_expected.to contain_postgresql__validate_db_connection('test') } - end - - describe 'should work with all parameters' do - let :params do - { - :database_host => 'test', - :database_name => 'test', - :database_password => 'test', - :database_username => 'test', - :database_port => 5432, - :run_as => 'postgresq', - :sleep => 4, - :tries => 30, - } - end - it { is_expected.to contain_postgresql__validate_db_connection('test') } - - it 'should have proper path for validate command' do - is_expected.to contain_exec('validate postgres connection for test@test:5432/test').with({ - :unless => %r'^/usr/local/bin/validate_postgresql_connection.sh\s+\d+' - }) - end - end - - describe 'should work while specifying validate_connection in postgresql::client' do - - let :params do - { - :database_host => 'test', - :database_name => 'test', - :database_password => 'test', - :database_username => 'test', - :database_port => 5432 - } - end - - let :pre_condition do - "class { 'postgresql::client': validcon_script_path => '/opt/something/validate.sh' }" - end - - it 'should have proper path for validate command' do - is_expected.to contain_exec('validate postgres connection for test@test:5432/test').with({ - :unless => %r'^/opt/something/validate.sh\s+\d+' - }) - end - - end - -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb deleted file mode 100644 index e21b52120..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_acls_to_resources_hash_spec.rb +++ /dev/null @@ -1,137 +0,0 @@ -require 'spec_helper' - -describe 'postgresql_acls_to_resources_hash', :type => :puppet_function do - context 'individual transform tests' do - it do - input = 'local all postgres ident' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"local", - "database"=>"all", - "user"=>"postgres", - "auth_method"=>"ident", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input = 'local all root ident' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"local", - "database"=>"all", - "user"=>"root", - "auth_method"=>"ident", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input_array = [ - 'local all all ident', - ] - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"local", - "database"=>"all", - "user"=>"all", - "auth_method"=>"ident", - "order"=>"100", - }, - } - - is_expected.to run.with_params(input_array, 'test', 100).and_return(result) - end - - it do - input = 'host all all 127.0.0.1/32 md5' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"host", - "database"=>"all", - "user"=>"all", - "address"=>"127.0.0.1/32", - "auth_method"=>"md5", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input = 'host all all 0.0.0.0/0 md5' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"host", - "database"=>"all", - "user"=>"all", - "address"=>"0.0.0.0/0", - "auth_method"=>"md5", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input = 'host all all ::1/128 md5' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"host", - "database"=>"all", - "user"=>"all", - "address"=>"::1/128", - "auth_method"=>"md5", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input = 'host all all 1.1.1.1 255.255.255.0 md5' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"host", - "database"=>"all", - "user"=>"all", - "address"=>"1.1.1.1 255.255.255.0", - "auth_method"=>"md5", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - - it do - input = 'host all all 1.1.1.1 255.255.255.0 ldap ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"' - result = { - "postgresql class generated rule test 0"=>{ - "type"=>"host", - "database"=>"all", - "user"=>"all", - "address"=>"1.1.1.1 255.255.255.0", - "auth_method"=>"ldap", - "auth_option"=>"ldapserver=ldap.example.net ldapprefix=\"cn=\" ldapsuffix=\", dc=example, dc=net\"", - "order"=>"100", - }, - } - - is_expected.to run.with_params([input], 'test', 100).and_return(result) - end - end - - it 'should return an empty hash when input is empty array' do - is_expected.to run.with_params([], 'test', 100).and_return({}) - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_escape_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_escape_spec.rb deleted file mode 100644 index b4c9488a2..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_escape_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'postgresql_escape', :type => :puppet_function do - it { is_expected.to run.with_params('foo'). - and_return('$$foo$$') } -end -describe 'postgresql_escape', :type => :puppet_function do - it { is_expected.to run.with_params('fo$$o'). - and_return('$ed$fo$$o$ed$') } -end -describe 'postgresql_escape', :type => :puppet_function do - it { is_expected.to run.with_params('foo$'). - and_return('$a$foo$$a$') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_password_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_password_spec.rb deleted file mode 100644 index b5aa00bfd..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/functions/postgresql_password_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -describe 'postgresql_password', :type => :puppet_function do - it { is_expected.to run.with_params('foo', 'bar'). - and_return('md596948aad3fcae80c08a35c9b5958cd89') } -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/provider/postgresql_conf/parsed_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/provider/postgresql_conf/parsed_spec.rb deleted file mode 100644 index 505504378..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/provider/postgresql_conf/parsed_spec.rb +++ /dev/null @@ -1,147 +0,0 @@ -require 'spec_helper' -require "tempfile" - -provider_class = Puppet::Type.type(:postgresql_conf).provider(:parsed) - -describe provider_class do - let(:title) { 'postgresql_conf' } - let(:provider) { - conf_class = Puppet::Type.type(:postgresql_conf) - provider = conf_class.provider(:parsed) - conffile = tmpfilename('postgresql.conf') - provider.any_instance.stub(:target).and_return conffile - provider - } - - before do - end - - after :each do - provider.initvars - end - - describe "simple configuration that should be allowed" do - it "should parse a simple ini line" do - expect(provider.parse_line("listen_addreses = '*'")).to eq( - { :name=>"listen_addreses", :value=>"*", :comment=>nil, :record_type=>:parsed } - ) - end - - it "should parse a simple ini line (2)" do - expect(provider.parse_line(" listen_addreses = '*'")).to eq( - { :name=>"listen_addreses", :value=>"*", :comment=>nil, :record_type=>:parsed } - ) - end - - it "should parse a simple ini line (3)" do - expect(provider.parse_line("listen_addreses = '*' # dont mind me")).to eq( - { :name=>"listen_addreses", :value=>"*", :comment=>"dont mind me", :record_type=>:parsed } - ) - end - - it "should parse a comment" do - expect(provider.parse_line("# dont mind me")).to eq( - { :line=>"# dont mind me", :record_type=>:comment } - ) - end - - it "should parse a comment (2)" do - expect(provider.parse_line(" \t# dont mind me")).to eq( - { :line=>" \t# dont mind me", :record_type=>:comment } - ) - end - - it "should allow includes" do - expect(provider.parse_line("include puppetextra")).to eq( - { :name=>"include", :value=>"puppetextra", :comment=>nil, :record_type=>:parsed } - ) - end - - it "should allow numbers through without quotes" do - expect(provider.parse_line("wal_keep_segments = 32")).to eq( - { :name=>"wal_keep_segments", :value=>"32", :comment=>nil, :record_type=>:parsed } - ) - end - - it "should allow blanks through " do - expect(provider.parse_line("")).to eq( - { :line=>"", :record_type=>:blank } - ) - end - - it "should parse keys with dots " do - expect(provider.parse_line("auto_explain.log_min_duration = 1ms")).to eq( - { :name => "auto_explain.log_min_duration", :value => "1ms", :comment => nil, :record_type => :parsed } - ) - end - end - - describe "configuration that should be set" do - it "should set comment lines" do - expect(provider.to_line({ :line=>"# dont mind me", :record_type=>:comment })).to eq( - '# dont mind me' - ) - end - - it "should set blank lines" do - expect(provider.to_line({ :line=>"", :record_type=>:blank })).to eq( - '' - ) - end - - it "should set simple configuration" do - expect(provider.to_line({:name=>"listen_addresses", :value=>"*", :comment=>nil, :record_type=>:parsed })).to eq( - "listen_addresses = '*'" - ) - end - - it "should set simple configuration with period in name" do - expect(provider.to_line({:name => "auto_explain.log_min_duration", :value => '100ms', :comment => nil, :record_type => :parsed })).to eq( - "auto_explain.log_min_duration = 100ms" - ) - end - - it "should set simple configuration even with comments" do - expect(provider.to_line({:name=>"listen_addresses", :value=>"*", :comment=>'dont mind me', :record_type=>:parsed })).to eq( - "listen_addresses = '*' # dont mind me" - ) - end - - it 'should quote includes' do - expect(provider.to_line( {:name=>"include", :value=>"puppetextra", :comment=>nil, :record_type=>:parsed })).to eq( - "include 'puppetextra'" - ) - end - - it 'should quote multiple words' do - expect(provider.to_line( {:name=>"archive_command", :value=>"rsync up", :comment=>nil, :record_type=>:parsed })).to eq( - "archive_command = 'rsync up'" - ) - end - - it 'shouldn\'t quote numbers' do - expect(provider.to_line( {:name=>"wal_segments", :value=>"32", :comment=>nil, :record_type=>:parsed })).to eq( - "wal_segments = 32" - ) - end - - it "should allow numbers" do - expect(provider.to_line( {:name=>"integer", :value=>42, :comment=>nil, :record_type=>:parsed })).to eq( - "integer = 42" - ) - end - - it "should allow floats" do - expect(provider.to_line( {:name=>"float", :value=>2.71828182845, :comment=>nil, :record_type=>:parsed })).to eq( - "float = 2.71828182845" - ) - end - - it "quotes addresses" do - expect(provider.to_line( {:name=>"listen_addresses", :value=>"0.0.0.0", :comment=>nil, :record_type=>:parsed })).to eq( - "listen_addresses = '0.0.0.0'" - ) - end - end -end - diff --git a/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb deleted file mode 100644 index b75bd987a..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'spec_helper' - -describe Puppet::Type.type(:postgresql_psql).provider(:ruby) do - let(:name) { 'rspec psql test' } - let(:resource) do - Puppet::Type.type(:postgresql_psql).new({ :name => name, :provider => :ruby }.merge attributes) - end - - let(:provider) { resource.provider } - - context("#run_sql_command") do - describe "with default attributes" do - let(:attributes) do { :db => 'spec_db' } end - - it "executes with the given psql_path on the given DB" do - expect(provider).to receive(:run_command).with(['psql', '-d', - attributes[:db], '-t', '-c', '"SELECT \'something\' as \"Custom column\""'], 'postgres', - 'postgres', {}) - - provider.run_sql_command('SELECT \'something\' as "Custom column"') - end - end - describe "with psql_path and db" do - let(:attributes) do { - :psql_path => '/opt/postgres/psql', - :psql_user => 'spec_user', - :psql_group => 'spec_group', - :cwd => '/spec', - :db => 'spec_db' - } end - - it "executes with the given psql_path on the given DB" do - expect(Dir).to receive(:chdir).with(attributes[:cwd]).and_yield - expect(provider).to receive(:run_command).with([attributes[:psql_path], - '-d', attributes[:db], '-t', '-c', '"SELECT \'something\' as \"Custom column\""'], - attributes[:psql_user], attributes[:psql_group], {}) - - provider.run_sql_command('SELECT \'something\' as "Custom column"') - end - end - describe "with search_path string" do - let(:attributes) do { - :search_path => "schema1" - } end - - it "executes with the given search_path" do - expect(provider).to receive(:run_command).with(['psql', '-t', '-c', - '"set search_path to schema1; SELECT \'something\' as \"Custom column\""'], - 'postgres', 'postgres', {}) - - provider.run_sql_command('SELECT \'something\' as "Custom column"') - end - end - describe "with search_path array" do - let(:attributes) do { - :search_path => ['schema1','schema2'], - } end - - it "executes with the given search_path" do - expect(provider).to receive(:run_command).with(['psql', '-t', '-c', - '"set search_path to schema1,schema2; SELECT \'something\' as \"Custom column\""'], - 'postgres', - 'postgres', - {} - ) - - provider.run_sql_command('SELECT \'something\' as "Custom column"') - end - end - end - describe "with port string" do - let(:attributes) do { :port => '5555' } end - - it "executes with the given port" do - expect(provider).to receive(:run_command).with(["psql", - "-p", "5555", - "-t", "-c", "\"SELECT something\""], - "postgres", "postgres", {} ) - - provider.run_sql_command("SELECT something") - end - end - describe "with connect_settings" do - let(:attributes) do { :connect_settings => { 'PGHOST' => '127.0.0.1' } } end - - it "executes with the given host" do - expect(provider).to receive(:run_command).with(["psql", - "-t", "-c", - "\"SELECT something\""], - "postgres", "postgres", { 'PGHOST' => '127.0.0.1' } ) - - provider.run_sql_command("SELECT something") - end - end - - context("#run_unless_sql_command") do - let(:attributes) do { } end - - it "calls #run_sql_command with SQL" do - expect(provider).to receive(:run_sql_command).with('SELECT COUNT(*) FROM (SELECT 1) count') - provider.run_unless_sql_command('SELECT 1') - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb deleted file mode 100644 index 4fc8b5539..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'spec_helper' - -type = Puppet::Type.type(:postgresql_replication_slot) -describe type.provider(:ruby) do - let(:name) { 'standby' } - let(:resource) do - type.new({ :name => name, :provider => :ruby }.merge attributes) - end - - let(:sql_instances) do - "abc | | physical | | | t | | | 0/3000420 -def | | physical | | | t | | | 0/3000420\n" - end - - class SuccessStatus - def success? - true - end - end - let(:success_status) { SuccessStatus.new } - - class FailStatus - def success? - false - end - end - let(:fail_status) { FailStatus.new } - - let(:provider) { resource.provider } - - context 'when listing instances' do - let(:attributes) do { } end - - it 'should list instances' do - provider.class.expects(:run_command).with( - ['psql', '-t', '-c', 'SELECT * FROM pg_replication_slots;'], - 'postgres', 'postgres').returns([sql_instances, nil]) - instances = provider.class.instances - expect(instances.size).to eq 2 - expect(instances[0].name).to eq 'abc' - expect(instances[1].name).to eq 'def' - end - end - - context 'when creating slot' do - let(:attributes) do { :ensure => 'present' } end - - context 'when creation works' do - it 'should call psql and succeed' do - provider.class.expects(:run_command).with( - ['psql', '-t', '-c', "SELECT * FROM pg_create_physical_replication_slot('standby');"], - 'postgres', 'postgres').returns([nil, success_status]) - - expect { provider.create }.not_to raise_error - end - end - - context 'when creation fails' do - it 'should call psql and fail' do - provider.class.expects(:run_command).with( - ['psql', '-t', '-c', "SELECT * FROM pg_create_physical_replication_slot('standby');"], - 'postgres', 'postgres').returns([nil, fail_status]) - - expect { provider.create }.to raise_error(Puppet::Error, /Failed to create replication slot standby:/) - end - end - end - - context 'when destroying slot' do - let(:attributes) do { :ensure => 'absent' } end - - context 'when destruction works' do - it 'should call psql and succeed' do - provider.class.expects(:run_command).with( - ['psql', '-t', '-c', "SELECT pg_drop_replication_slot('standby');"], - 'postgres', 'postgres').returns([nil, success_status]) - - expect { provider.destroy }.not_to raise_error - end - end - - context 'when destruction fails' do - it 'should call psql and fail' do - provider.class.expects(:run_command).with( - ['psql', '-t', '-c', "SELECT pg_drop_replication_slot('standby');"], - 'postgres', 'postgres').returns([nil, fail_status]) - - expect { provider.destroy }.to raise_error(Puppet::Error, /Failed to destroy replication slot standby:/) - end - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_psql_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_psql_spec.rb deleted file mode 100644 index 38833271a..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_psql_spec.rb +++ /dev/null @@ -1,251 +0,0 @@ -require 'spec_helper' - -describe Puppet::Type.type(:postgresql_psql), "when validating attributes" do - [:name, :unless, :db, :psql_path, :psql_user, :psql_group, :connect_settings].each do |attr| - it "should have a #{attr} parameter" do - expect(Puppet::Type.type(:postgresql_psql).attrtype(attr)).to eq(:param) - end - end - - [:command].each do |attr| - it "should have a #{attr} property" do - expect(Puppet::Type.type(:postgresql_psql).attrtype(attr)).to eq(:property) - end - end -end - -describe Puppet::Type.type(:postgresql_psql), :unless => Puppet.features.microsoft_windows? do - subject do - Puppet::Type.type(:postgresql_psql).new({:name => 'rspec'}.merge attributes) - end - - describe "available attributes" do - { - :name => "rspec", - :command => "SELECT stuff", - :unless => "SELECT other,stuff", - :db => "postgres", - :psql_path => "/bin/false", - :psql_user => "postgres", - :psql_group => "postgres", - :cwd => "/var/lib", - :refreshonly => :true, - :search_path => [ "schema1", "schema2"], - :connect_settings => { 'PGHOST' => 'postgres-db-server', - 'DBVERSION' => '9.1', }, - }.each do |attr, value| - context attr do - let(:attributes) do { attr => value } end - - describe [attr] do - subject { super()[attr] } - it { is_expected.to eq(value) } - end - end - end - - context "default values" do - let(:attributes) do {} end - - describe '[:psql_path]' do - subject { super()[:psql_path] } - it { is_expected.to eq("psql") } - end - - describe '[:psql_user]' do - subject { super()[:psql_user] } - it { is_expected.to eq("postgres") } - end - - describe '[:psql_group]' do - subject { super()[:psql_group] } - it { is_expected.to eq("postgres") } - end - - describe '[:cwd]' do - subject { super()[:cwd] } - it { is_expected.to eq("/tmp") } - end - - describe '#refreshonly?' do - subject { super().refreshonly? } - it { is_expected.to be_falsey } - end - end - end - - describe "#command" do - let(:attributes) do {:command => 'SELECT stuff'} end - - it "will have the value :notrun if the command should execute" do - expect(subject).to receive(:should_run_sql).and_return(true) - expect(subject.property(:command).retrieve).to eq(:notrun) - end - - it "will be the 'should' value if the command should not execute" do - expect(subject).to receive(:should_run_sql).and_return(false) - expect(subject.property(:command).retrieve).to eq('SELECT stuff') - end - - it "will call provider#run_sql_command on sync" do - expect(subject.provider).to receive(:run_sql_command).with('SELECT stuff').and_return(["done", 0]) - subject.property(:command).sync - end - end - - describe "#unless" do - let(:attributes) do {:unless => 'SELECT something'} end - - describe "#matches" do - it "does not fail when the status is successful" do - expect(subject.provider).to receive(:run_unless_sql_command).and_return ["1 row returned", 0] - subject.parameter(:unless).matches('SELECT something') - end - - it "returns true when rows are returned" do - expect(subject.provider).to receive(:run_unless_sql_command).and_return ["1 row returned", 0] - expect(subject.parameter(:unless).matches('SELECT something')).to be_truthy - end - - it "returns false when no rows are returned" do - expect(subject.provider).to receive(:run_unless_sql_command).and_return ["0 rows returned", 0] - expect(subject.parameter(:unless).matches('SELECT something')).to be_falsey - end - - it "raises an error when the sql command fails" do - allow(subject.provider).to receive(:run_unless_sql_command).and_return ["Something went wrong", 1] - expect { - subject.parameter(:unless).matches('SELECT something') - }.to raise_error(Puppet::Error, /Something went wrong/) - end - end - end - - describe "#should_run_sql" do - context "without 'unless'" do - [true, :true].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_falsey } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_truthy } - end - end - end - - [false, :false].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_truthy } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_truthy } - end - end - end - end - - context "with matching 'unless'" do - before { expect(subject.parameter(:unless)).to receive(:matches).with('SELECT something').and_return(true) } - - [true, :true].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - :unless => 'SELECT something', - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_falsey } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_falsey } - end - end - end - - [false, :false].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - :unless => 'SELECT something', - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_falsey } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_falsey } - end - end - end - end - - context "when not matching 'unless'" do - before { expect(subject.parameter(:unless)).to receive(:matches).with('SELECT something').and_return(false) } - - [true, :true].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - :unless => 'SELECT something', - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_falsey } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_truthy } - end - end - end - - [false, :false].each do |refreshonly| - context "refreshonly => #{refreshonly.inspect}" do - let(:attributes) do { - :refreshonly => refreshonly, - :unless => 'SELECT something', - } end - - context "not refreshing" do - it { expect(subject.should_run_sql).to be_truthy } - end - - context "refreshing" do - it { expect(subject.should_run_sql(true)).to be_truthy } - end - end - end - end - end - - describe "#refresh" do - let(:attributes) do {} end - - it "syncs command property when command should run" do - expect(subject).to receive(:should_run_sql).with(true).and_return(true) - expect(subject.property(:command)).to receive(:sync) - subject.refresh - end - - it "does not sync command property when command should not run" do - expect(subject).to receive(:should_run_sql).with(true).and_return(false) - expect(subject.property(:command)).not_to receive(:sync) - subject.refresh - end - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_replication_slot_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_replication_slot_spec.rb deleted file mode 100644 index 0d7c66885..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/puppet/type/postgresql_replication_slot_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe Puppet::Type.type(:postgresql_replication_slot) do - subject do - Puppet::Type.type(:postgresql_psql).new({:name => 'standby'}) - end - - it 'should have a name parameter' do - expect(subject[:name]).to eq 'standby' - end -end diff --git a/vagrant/puppet/modules/postgresql/spec/unit/type/postgresql_conf_spec.rb b/vagrant/puppet/modules/postgresql/spec/unit/type/postgresql_conf_spec.rb deleted file mode 100644 index 4214facc3..000000000 --- a/vagrant/puppet/modules/postgresql/spec/unit/type/postgresql_conf_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/bin/env ruby -require 'spec_helper' - -describe Puppet::Type.type(:postgresql_conf) do - before do - @provider_class = described_class.provide(:simple) { mk_resource_methods } - @provider_class.stub(:suitable?).and_return true - described_class.stub(:defaultprovider).and_return @provider_class - end - - describe "namevar validation" do - it "should have :name as its namevar" do - expect(described_class.key_attributes).to eq([:name]) - end - it "should not invalid names" do - expect { described_class.new(:name => 'foo bar') }.to raise_error(Puppet::Error, /Invalid value/) - end - it "should allow dots in names" do - expect { described_class.new(:name => 'foo.bar') }.to_not raise_error - end - end - - describe "when validating attributes" do - [:name, :provider].each do |param| - it "should have a #{param} parameter" do - expect(described_class.attrtype(param)).to eq(:param) - end - end - - [:value, :target].each do |property| - it "should have a #{property} property" do - expect(described_class.attrtype(property)).to eq(:property) - end - end - end - - describe "when validating values" do - describe "ensure" do - it "should support present as a value for ensure" do - expect { described_class.new(:name => 'foo', :ensure => :present) }.to_not raise_error - end - it "should support absent as a value for ensure" do - expect { described_class.new(:name => 'foo', :ensure => :absent) }.to_not raise_error - end - it "should not support other values" do - expect { described_class.new(:name => 'foo', :ensure => :foo) }.to raise_error(Puppet::Error, /Invalid value/) - end - end - end -end diff --git a/vagrant/puppet/modules/postgresql/templates/pg_hba_rule.conf b/vagrant/puppet/modules/postgresql/templates/pg_hba_rule.conf deleted file mode 100644 index af54db5b2..000000000 --- a/vagrant/puppet/modules/postgresql/templates/pg_hba_rule.conf +++ /dev/null @@ -1,5 +0,0 @@ - -# Rule Name: <%=@name%> -# Description: <%=@description%> -# Order: <%=@order%> -<%=@type%> <%=@database%> <%=@user%> <%=@address%> <%=@auth_method%> <%=@auth_option%> diff --git a/vagrant/puppet/modules/postgresql/templates/pg_ident_rule.conf b/vagrant/puppet/modules/postgresql/templates/pg_ident_rule.conf deleted file mode 100644 index 238c6e96f..000000000 --- a/vagrant/puppet/modules/postgresql/templates/pg_ident_rule.conf +++ /dev/null @@ -1,5 +0,0 @@ - -# Rule Name: <%=@name%> -# Description: <%=@description%> -# Order: <%=@order%> -<%=@map_name%> <%=@system_username%> <%=@database_username%> diff --git a/vagrant/puppet/modules/postgresql/templates/recovery.conf b/vagrant/puppet/modules/postgresql/templates/recovery.conf deleted file mode 100644 index a678faee0..000000000 --- a/vagrant/puppet/modules/postgresql/templates/recovery.conf +++ /dev/null @@ -1,47 +0,0 @@ -<% if @restore_command -%> -restore_command = '<%= @restore_command %>' -<% end -%> -<% if @archive_cleanup_command -%> -archive_cleanup_command = '<%= @archive_cleanup_command %>' -<% end -%> -<% if @recovery_end_command -%> -recovery_end_command = '<%= @recovery_end_command %>' -<% end -%> - -<% if @recovery_target_name -%> -recovery_target_name = '<%= @recovery_target_name %>' -<% end -%> -<% if @recovery_target_time -%> -recovery_target_time = '<%= @recovery_target_time %>' -<% end -%> -<% if @recovery_target_xid -%> -recovery_target_xid = '<%= @recovery_target_xid %>' -<% end -%> -<% if @recovery_target_inclusive -%> -recovery_target_inclusive = <%= @recovery_target_inclusive %> -<% end -%> -<% if @recovery_target -%> -recovery_target = '<%= @recovery_target %>' -<% end -%> -<% if @recovery_target_timeline -%> -recovery_target_timeline = '<%= @recovery_target_timeline %>' -<% end -%> -<% if @pause_at_recovery_target -%> -pause_at_recovery_target = <%= @pause_at_recovery_target %> -<% end -%> - -<% if @standby_mode -%> -standby_mode = <%= @standby_mode %> -<% end -%> -<% if @primary_conninfo -%> -primary_conninfo = '<%= @primary_conninfo %>' -<% end -%> -<% if @primary_slot_name -%> -primary_slot_name = '<%= @primary_slot_name %>' -<% end -%> -<% if @trigger_file -%> -trigger_file = '<%= @trigger_file %>' -<% end -%> -<% if @recovery_min_apply_delay -%> -recovery_min_apply_delay = <%= @recovery_min_apply_delay %> -<% end -%> diff --git a/vagrant/puppet/modules/postgresql/templates/systemd-override.erb b/vagrant/puppet/modules/postgresql/templates/systemd-override.erb deleted file mode 100644 index eb4f787f7..000000000 --- a/vagrant/puppet/modules/postgresql/templates/systemd-override.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%- if scope.lookupvar('::operatingsystem') == 'Fedora' -%> -.include /lib/systemd/system/<%= @service_name %>.service -<% else -%> -.include /usr/lib/systemd/system/<%= @service_name %>.service -<% end -%> -[Service] -Environment=PGPORT=<%= @port %> -Environment=PGDATA=<%= @datadir %> diff --git a/vagrant/puppet/modules/python/Gemfile b/vagrant/puppet/modules/python/Gemfile deleted file mode 100644 index 2918dfec5..000000000 --- a/vagrant/puppet/modules/python/Gemfile +++ /dev/null @@ -1,47 +0,0 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -group :development, :test do - gem 'metadata-json-lint', :require => false - gem 'rspec-puppet', :require => false - gem 'puppetlabs_spec_helper', '1.1.1' - gem 'puppet-lint', :require => false - gem 'pry', :require => false - gem 'simplecov', :require => false -end - -# pin old versions for ruby 1.8.7 -if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' - gem 'rspec', '~> 2.0' - gem 'rake', '~> 10.0' -else - gem 'rake', :require => false -end - -if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '2.0' - # json 2.x requires ruby 2.0. Lock to 1.8 - gem 'json', '~> 1.8' - # json_pure 2.0.2 requires ruby 2.0. Lock to 2.0.1 - gem 'json_pure', '= 2.0.1' -else - gem 'json' -end - -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false -end - -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end - -group :system_tests do - gem 'serverspec', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false -end - -# vim:ft=ruby diff --git a/vagrant/puppet/modules/python/LICENSE b/vagrant/puppet/modules/python/LICENSE deleted file mode 100644 index 404e08ab9..000000000 --- a/vagrant/puppet/modules/python/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright © [2012-2014] [Sergey Stankevich] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vagrant/puppet/modules/python/README.md b/vagrant/puppet/modules/python/README.md deleted file mode 100644 index 28f829303..000000000 --- a/vagrant/puppet/modules/python/README.md +++ /dev/null @@ -1,334 +0,0 @@ -# puppet-python [![Build Status](https://travis-ci.org/stankevich/puppet-python.svg?branch=master)](https://travis-ci.org/stankevich/puppet-python) - -Puppet module for installing and managing python, pip, virtualenvs and Gunicorn virtual hosts. - -=== - -# Compatibility # - -* Puppet v3 (with and without the future parser) -* Puppet v4 - -## Ruby versions - -* 1.8.7 -* 1.9.3 -* 2.0.0 -* 2.1.0 -* 2.3.1 - -## OS Distributions ## - -This module has been tested to work on the following systems. - -* Debian 6 -* Debian 7 -* Debian 8 -* EL 5 -* EL 6 -* EL 7 -* Suse 11 -* Ubuntu 10.04 -* Ubuntu 12.04 -* Ubuntu 14.04 - -=== - -## Installation - -```shell -git submodule add https://github.com/stankevich/puppet-python.git /path/to/python -``` -OR - -``` shell -puppet module install stankevich-python -``` - -## Usage - -### python - -Installs and manages python, python-pip, python-dev, python-virtualenv and Gunicorn. - -**ensure** - Desired installation state for the Python package. Options are absent, present and latest. Default: present - -**version** - Python version to install. Default: system - -**pip** - Desired installation state for the python-pip package. Options are absent, present and latest. Default: present - -**dev** - Desired installation state for the python-dev package. Options are absent, present and latest. Default: absent - -**virtualenv** - Desired installation state for the virtualenv package. Options are absent, present and latest. Default: absent - -**gunicorn** - Desired installation state for Gunicorn. Options are absent, present and latest. Default: absent - -**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true - -**use_epel** - Boolean to determine if the epel class is used. Default: true - -```puppet - class { 'python' : - version => 'system', - pip => 'present', - dev => 'absent', - virtualenv => 'absent', - gunicorn => 'absent', - } -``` - -### python::pip - -Installs and manages packages from pip. - -**pkgname** - the name of the package to install. Required. - -**ensure** - present/latest/absent. You can also specify the version. Default: present - -**virtualenv** - virtualenv to run pip in. Default: system (no virtualenv) - -**url** - URL to install from. Default: none - -**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root - -**proxy** - Proxy server to use for outbound connections. Default: none - -**environment** - Additional environment variables required to install the packages. Default: none - -**egg** - The egg name to use. Default: `$name` of the class, e.g. cx_Oracle - -**install_args** - String of additional flags to pass to pip during installaton. Default: none - -**uninstall_args** - String of additional flags to pass to pip during uninstall. Default: none - -**timeout** - Timeout for the pip install command. Defaults to 1800. -```puppet - python::pip { 'cx_Oracle' : - pkgname => 'cx_Oracle', - ensure => '5.1.2', - virtualenv => '/var/www/project1', - owner => 'appuser', - proxy => 'http://proxy.domain.com:3128', - environment => 'ORACLE_HOME=/usr/lib/oracle/11.2/client64', - install_args => '-e', - timeout => 1800, - } -``` - -### python::requirements - -Installs and manages Python packages from requirements file. - -**virtualenv** - virtualenv to run pip in. Default: system-wide - -**proxy** - Proxy server to use for outbound connections. Default: none - -**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root - -**src** - The `--src` parameter to `pip`, used to specify where to install `--editable` resources; by default no `--src` parameter is passed to `pip`. - -**group** - The group that was used to create the virtualenv. This is used to create the requirements file with correct permissions if it's not present already. - -**manage_requirements** - Create the requirements file if it doesn't exist. Default: true - -```puppet - python::requirements { '/var/www/project1/requirements.txt' : - virtualenv => '/var/www/project1', - proxy => 'http://proxy.domain.com:3128', - owner => 'appuser', - group => 'apps', - } -``` - -### python::virtualenv - -Creates Python virtualenv. - -**ensure** - present/absent. Default: present - -**version** - Python version to use. Default: system default - -**requirements** - Path to pip requirements.txt file. Default: none - -**proxy** - Proxy server to use for outbound connections. Default: none - -**systempkgs** - Copy system site-packages into virtualenv. Default: don't - -**distribute** - Include distribute in the virtualenv. Default: true - -**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name - -**owner** - Specify the owner of this virtualenv - -**group** - Specify the group for this virtualenv - -**index** - Base URL of Python package index. Default: none - -**cwd** - The directory from which to run the "pip install" command. Default: undef - -**timeout** - The maximum time in seconds the "pip install" command should take. Default: 1800 - -```puppet - python::virtualenv { '/var/www/project1' : - ensure => present, - version => 'system', - requirements => '/var/www/project1/requirements.txt', - proxy => 'http://proxy.domain.com:3128', - systempkgs => true, - distribute => false, - venv_dir => '/home/appuser/virtualenvs', - owner => 'appuser', - group => 'apps', - cwd => '/var/www/project1', - timeout => 0, - } -``` - -### python::pyvenv - -Creates Python3 virtualenv. - -**ensure** - present/absent. Default: present - -**version** - Python version to use. Default: system default - -**systempkgs** - Copy system site-packages into virtualenv. Default: don't - -**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name - -**owner** - Specify the owner of this virtualenv - -**group** - Specify the group for this virtualenv - -**path** - Specifies the PATH variable that contains `pyvenv` executable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] - -**environment** - Specify any environment variables to use when creating pyvenv - -```puppet - python::pyvenv { '/var/www/project1' : - ensure => present, - version => 'system', - systempkgs => true, - venv_dir => '/home/appuser/virtualenvs', - owner => 'appuser', - group => 'apps', - } -``` - -### python::gunicorn - -Manages Gunicorn virtual hosts. - -**ensure** - present/absent. Default: present - -**virtualenv** - Run in virtualenv, specify directory. Default: disabled - -**mode** - Gunicorn mode. wsgi/django. Default: wsgi - -**dir** - Application directory. - -**bind** - Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. Default: `unix:/tmp/gunicorn-$name.socket` or `unix:${virtualenv}/${name}.socket` - -**environment** - Set ENVIRONMENT variable. Default: none - -**appmodule** - Set the application module name for gunicorn to load when not using Django. Default: `app:app` - -**osenv** - Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default: false - -**timeout** - Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. Default: 30 - -**template** - Which ERB template to use. Default: python/gunicorn.erb - -```puppet - python::gunicorn { 'vhost' : - ensure => present, - virtualenv => '/var/www/project1', - mode => 'wsgi', - dir => '/var/www/project1/current', - bind => 'unix:/tmp/gunicorn.socket', - environment => 'prod', - appmodule => 'app:app', - osenv => { 'DBHOST' => 'dbserver.example.com' }, - timeout => 30, - template => 'python/gunicorn.erb', - } -``` - -### python::dotfile - -Manages arbitrary python dotiles with a simple config hash. - -**ensure** - present/absent. Default: present - -**filename** - Default: $title - -**mode** - Default: 0644 - -**owner** - Default: root - -**group** - Default: root - -**config** Config hash. This will be expanded to an ini-file. Default: {} - -```puppet -python::dotfile { '/var/lib/jenkins/.pip/pip.conf': - ensure => present, - owner => 'jenkins', - group => 'jenkins', - config => { - 'global' => { - 'index-url => 'https://mypypi.acme.com/simple/' - 'extra-index-url => https://pypi.risedev.at/simple/ - } - } -} -``` - -### hiera configuration - -This module supports configuration through hiera. The following example -creates two python3 virtualenvs. The configuration also pip installs a -package into each environment. - -```yaml -python::python_pyvenvs: - "/opt/env1": - version: "system" - "/opt/env2": - version: "system" -python::python_pips: - "nose": - virtualenv: "/opt/env1" - "coverage": - virtualenv: "/opt/env2" -``` - -### Using SCL packages from RedHat or CentOS - -To use this module with Linux distributions in the Red Hat family and python distributions -from softwarecollections.org, set python::provider to 'rhscl' and python::version to the name -of the collection you want to use (e.g., 'python27', 'python33', or 'rh-python34'). - -## Release Notes - -**Version 1.9.8 Notes** -The `pip`, `virtualenv` and `gunicorn` parameters of `Class['python']` have changed. These parameters now accept `absent`, `present` and `latest` rather than `true` and `false`. The boolean values are still supported and are equivalent to `present` and `absent` respectively. Support for these boolean parameters is deprecated and will be removed in a later release. - -**Version 1.7.10 Notes** - -Installation of python-pip previously defaulted to `false` and was not installed. This default is now `true` and python-pip is installed. To prevent the installation of python-pip specify `pip => false` as a parameter when instantiating the `python` puppet class. - -**Version 1.1.x Notes** - -Version `1.1.x` makes several fundamental changes to the core of this module, adding some additional features, improving performance and making operations more robust in general. - -Please note that several changes have been made in `v1.1.x` which make manifests incompatible with the previous version. However, modifying your manifests to suit is trivial. Please see the notes below. - -Currently, the changes you need to make are as follows: - -* All pip definitions MUST include the owner field which specifies which user owns the virtualenv that packages will be installed in. Adding this greatly improves performance and efficiency of this module. -* You must explicitly specify pip => true in the python class if you want pip installed. As such, the pip package is now independent of the dev package and so one can exist without the other. - -## Authors - -[Sergey Stankevich](https://github.com/stankevich) | [Shiva Poudel](https://github.com/shivapoudel) | [Peter Souter](https://github.com/petems) | [Garrett Honeycutt](http://learnpuppet.com) diff --git a/vagrant/puppet/modules/python/Rakefile b/vagrant/puppet/modules/python/Rakefile deleted file mode 100644 index 28d00a1e4..000000000 --- a/vagrant/puppet/modules/python/Rakefile +++ /dev/null @@ -1,40 +0,0 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' - -# These two gems aren't always present, for instance -# on Travis with --without development -begin - require 'puppet_blacksmith/rake_tasks' -rescue LoadError -end - -PuppetLint.configuration.fail_on_warnings -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_class_parameter_defaults') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] - -exclude_paths = [ - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc "Run syntax, lint, and spec tests." -task :test => [ - :syntax, - :lint, - :spec, -] diff --git a/vagrant/puppet/modules/python/checksums.json b/vagrant/puppet/modules/python/checksums.json deleted file mode 100644 index 82620168b..000000000 --- a/vagrant/puppet/modules/python/checksums.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "Gemfile": "0547bad52d0fc155cf7d1a3b3ee1b5a1", - "LICENSE": "cf2903831f7e18e82a84cce52f44e4a8", - "README.md": "d59deed05d984e57de169e83748e2667", - "Rakefile": "c21964c8a408d779e62fd2ae09497bc1", - "lib/facter/pip_version.rb": "94fb2b635dbe71abe0891ba3c1262acf", - "lib/facter/python_version.rb": "03f933f329dd8ca388962d5c72048391", - "lib/facter/virtualenv_version.rb": "09837fdf91dfc4daff395874ab63b992", - "manifests/config.pp": "e96cbfc9b920703d3ba91111226de7f5", - "manifests/dotfile.pp": "f6196d257b1c9e8ffde00eef603f4863", - "manifests/gunicorn.pp": "c4f14bcac12a07ad5c28d1a663e97a14", - "manifests/init.pp": "c6276e7ddc76b1a81e2e3b371736f25c", - "manifests/install.pp": "846e133e2273d8c3b89316af60929740", - "manifests/params.pp": "ff627cbce285a66b28542b369c049eab", - "manifests/pip.pp": "68588ae7a9837bc24fc94cf002eab903", - "manifests/pyvenv.pp": "fe680b2c5abc2ac569ff63229f174403", - "manifests/requirements.pp": "866cb2d0ecc5a6415b64b8501c6ca779", - "manifests/virtualenv.pp": "0b8b17c2ff38e930fb1460b12eaefa0d", - "metadata.json": "c1b1f404c7ce6cf4697a78cefce23fac", - "spec/acceptance/class_spec.rb": "784a085709ec2d998961bd6fe45452a6", - "spec/acceptance/facts_test_spec.rb": "c1b5485528b0b1163947e134cea7ce2a", - "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151", - "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b", - "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af", - "spec/acceptance/nodesets/debian-70rc1-x64.yml": "715f798e696d3582c66d13f0e8e5f009", - "spec/acceptance/nodesets/debian-73-x64.yml": "b44b7146a828c37482c06879862fb5d9", - "spec/acceptance/nodesets/default.yml": "e27bb4d7526ad3c7a1c4aeb87decec15", - "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297", - "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269", - "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0", - "spec/acceptance/virtualenv_spec.rb": "4494eaf3b0de430fac9df01504c93d2d", - "spec/classes/python_spec.rb": "b8bf529ee72f7bfe54c33fc880a549d3", - "spec/defines/gunicorn_spec.rb": "de12b6b712b04f1175b33cdc6c92b041", - "spec/defines/pip_spec.rb": "63a2e7aadb37c634158e33a603087cb4", - "spec/defines/pyvenv_spec.rb": "010c4568f19e22603ad712c189192ab8", - "spec/defines/requirements_spec.rb": "9591058f9b823ffc7db27a9d30a10177", - "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", - "spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc", - "spec/spec_helper_acceptance.rb": "59044ad83a006591c63dab149b43afad", - "spec/unit/facter/pip_version_spec.rb": "bc1e73c99891f780d5f6ca60258e8097", - "spec/unit/facter/python_version_spec.rb": "be3b595c06e94867efea854b2796d617", - "spec/unit/facter/virtualenv_version_spec.rb": "abb87062002bec85ef1b5b28eeda4101", - "templates/gunicorn.erb": "7d1a6b3340dbdad069e0bdfb14255271", - "templates/inifile.erb": "ce9b0646bd1bcf91a2be0997d44c917f", - "tests/gunicorn.pp": "ac09401c1e329008fef8e9ad6e6971bd", - "tests/init.pp": "251c210b05aab1f84c49a38f7fe48bbe", - "tests/pip.pp": "e3a793d4c714c39df31f3f79f0d7629c", - "tests/pyvenv.pp": "d4c050a2b358d4516d613869fab23113", - "tests/requirements.pp": "4a5e714fbbd623e519f0c07914367730", - "tests/virtualenv.pp": "698f811b9110cbc5d9262f0500bd7ee4" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/python/lib/facter/pip_version.rb b/vagrant/puppet/modules/python/lib/facter/pip_version.rb deleted file mode 100644 index 71f60aea7..000000000 --- a/vagrant/puppet/modules/python/lib/facter/pip_version.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Make pip version available as a fact - -Facter.add("pip_version") do - setcode do - if Facter::Util::Resolution.which('pip') - Facter::Util::Resolution.exec('pip --version 2>&1').match(/^pip (\d+\.\d+\.?\d*).*$/)[1] - end - end -end diff --git a/vagrant/puppet/modules/python/lib/facter/python_version.rb b/vagrant/puppet/modules/python/lib/facter/python_version.rb deleted file mode 100644 index c4ffa45c7..000000000 --- a/vagrant/puppet/modules/python/lib/facter/python_version.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Make python versions available as facts - -def get_python_version(executable) - if Facter::Util::Resolution.which(executable) - results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+\.\d+\+?)$/) - if results - results[1] - end - end -end - -Facter.add("python_version") do - setcode do - get_python_version 'python' - end -end - -Facter.add("python2_version") do - setcode do - default_version = get_python_version 'python' - if default_version.nil? or !default_version.start_with?('2') - get_python_version 'python2' - else - default_version - end - end -end - -Facter.add("python3_version") do - setcode do - get_python_version 'python3' - end -end diff --git a/vagrant/puppet/modules/python/lib/facter/virtualenv_version.rb b/vagrant/puppet/modules/python/lib/facter/virtualenv_version.rb deleted file mode 100644 index a0917d09e..000000000 --- a/vagrant/puppet/modules/python/lib/facter/virtualenv_version.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Make virtualenv version available as a fact - -Facter.add("virtualenv_version") do - setcode do - if Facter::Util::Resolution.which('virtualenv') - Facter::Util::Resolution.exec('virtualenv --version 2>&1').match(/^(\d+\.\d+\.?\d*).*$/)[0] - end - end -end diff --git a/vagrant/puppet/modules/python/manifests/config.pp b/vagrant/puppet/modules/python/manifests/config.pp deleted file mode 100644 index 78a424b97..000000000 --- a/vagrant/puppet/modules/python/manifests/config.pp +++ /dev/null @@ -1,40 +0,0 @@ -# == Define: python::config -# -# Optionally installs the gunicorn service -# -# === Examples -# -# include python::config -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Fotis Gimian -# - -class python::config { - - Class['python::install'] -> Python::Pip <| |> - Class['python::install'] -> Python::Requirements <| |> - Class['python::install'] -> Python::Virtualenv <| |> - - Python::Virtualenv <| |> -> Python::Pip <| |> - - if $python::manage_gunicorn { - if $python::gunicorn != 'absent' { - Class['python::install'] -> Python::Gunicorn <| |> - - Python::Gunicorn <| |> ~> Service['gunicorn'] - - service { 'gunicorn': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => false, - pattern => '/usr/bin/gunicorn', - } - } - } - -} diff --git a/vagrant/puppet/modules/python/manifests/dotfile.pp b/vagrant/puppet/modules/python/manifests/dotfile.pp deleted file mode 100644 index 5bc70ae98..000000000 --- a/vagrant/puppet/modules/python/manifests/dotfile.pp +++ /dev/null @@ -1,62 +0,0 @@ -# == Define: python::dotfile -# -# Manages any python dotfiles with a simple config hash. -# -# === Parameters -# -# [*ensure*] -# present|absent. Default: present -# -# [*filename*] -# Filename. Default: $title -# -# [*mode*] -# File mode. Default: 0644 -# -# [*owner*] -# [*group*] -# Owner/group. Default: `root`/`root` -# -# [*config*] -# Config hash. This will be expanded to an ini-file. Default: {} -# -# === Examples -# -# python::dotfile { '/var/lib/jenkins/.pip/pip.conf': -# ensure => present, -# owner => 'jenkins', -# group => 'jenkins', -# config => { -# 'global' => { -# 'index-url => 'https://mypypi.acme.com/simple/' -# 'extra-index-url => https://pypi.risedev.at/simple/ -# } -# } -# } -# -# -define python::dotfile ( - $ensure = 'present', - $filename = $title, - $owner = 'root', - $group = 'root', - $mode = '0644', - $config = {}, -) { - $parent_dir = dirname($filename) - - exec { "create ${title}'s parent dir": - command => "install -o ${owner} -g ${group} -d ${parent_dir}", - path => [ '/usr/bin', '/bin', '/usr/local/bin', ], - creates => $parent_dir, - } - - file { $filename: - ensure => $ensure, - owner => $owner, - group => $group, - mode => $mode, - content => template("${module_name}/inifile.erb"), - require => Exec["create ${title}'s parent dir"], - } -} diff --git a/vagrant/puppet/modules/python/manifests/gunicorn.pp b/vagrant/puppet/modules/python/manifests/gunicorn.pp deleted file mode 100644 index b943e3321..000000000 --- a/vagrant/puppet/modules/python/manifests/gunicorn.pp +++ /dev/null @@ -1,107 +0,0 @@ -# == Define: python::gunicorn -# -# Manages Gunicorn virtual hosts. -# -# === Parameters -# -# [*ensure*] -# present|absent. Default: present -# -# [*virtualenv*] -# Run in virtualenv, specify directory. Default: disabled -# -# [*mode*] -# Gunicorn mode. -# wsgi|django. Default: wsgi -# -# [*dir*] -# Application directory. -# -# [*bind*] -# Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. -# Default: system-wide: unix:/tmp/gunicorn-$name.socket -# virtualenv: unix:${virtualenv}/${name}.socket -# -# [*environment*] -# Set ENVIRONMENT variable. Default: none -# -# [*appmodule*] -# Set the application module name for gunicorn to load when not using Django. -# Default: app:app -# -# [*osenv*] -# Allows setting environment variables for the gunicorn service. Accepts a -# hash of 'key': 'value' pairs. -# Default: false -# -# [*timeout*] -# Allows setting the gunicorn idle worker process time before being killed. -# The unit of time is seconds. -# Default: 30 -# -# [*template*] -# Which ERB template to use. Default: python/gunicorn.erb -# -# [*args*] -# Custom arguments to add in gunicorn config file. Default: [] -# -# === Examples -# -# python::gunicorn { 'vhost': -# ensure => present, -# virtualenv => '/var/www/project1', -# mode => 'wsgi', -# dir => '/var/www/project1/current', -# bind => 'unix:/tmp/gunicorn.socket', -# environment => 'prod', -# owner => 'www-data', -# group => 'www-data', -# appmodule => 'app:app', -# osenv => { 'DBHOST' => 'dbserver.example.com' }, -# timeout => 30, -# template => 'python/gunicorn.erb', -# } -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Marc Fournier -# -define python::gunicorn ( - $ensure = present, - $virtualenv = false, - $mode = 'wsgi', - $dir = false, - $bind = false, - $environment = false, - $owner = 'www-data', - $group = 'www-data', - $appmodule = 'app:app', - $osenv = false, - $timeout = 30, - $workers = false, - $access_log_format = false, - $accesslog = false, - $errorlog = false, - $log_level = 'error', - $template = 'python/gunicorn.erb', - $args = [], -) { - - # Parameter validation - if ! $dir { - fail('python::gunicorn: dir parameter must not be empty') - } - - validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}") - - file { "/etc/gunicorn.d/${name}": - ensure => $ensure, - mode => '0644', - owner => 'root', - group => 'root', - content => template($template), - } - -} diff --git a/vagrant/puppet/modules/python/manifests/init.pp b/vagrant/puppet/modules/python/manifests/init.pp deleted file mode 100644 index c0aa6f236..000000000 --- a/vagrant/puppet/modules/python/manifests/init.pp +++ /dev/null @@ -1,147 +0,0 @@ -# == Class: python -# -# Installs and manages python, python-dev, python-virtualenv and Gunicorn. -# -# === Parameters -# -# [*ensure*] -# Desired installation state for the Python package. Valid options are absent, -# present and latest. Default: present -# -# [*version*] -# Python version to install. Beware that valid values for this differ a) by -# the provider you choose and b) by the osfamily/operatingsystem you are using. -# Default: system default -# Allowed values: -# - provider == pip: everything pip allows as a version after the 'python==' -# - else: 'system', 'pypy', 3/3.3/... -# - Be aware that 'system' usually means python 2.X. -# - 'pypy' actually lets us use pypy as python. -# - 3/3.3/... means you are going to install the python3/python3.3/... -# package, if available on your osfamily. -# -# [*pip*] -# Desired installation state for python-pip. Boolean values are deprecated. -# Default: present -# Allowed values: 'absent', 'present', 'latest' -# -# [*dev*] -# Desired installation state for python-dev. Boolean values are deprecated. -# Default: absent -# Allowed values: 'absent', 'present', 'latest' -# -# [*virtualenv*] -# Desired installation state for python-virtualenv. Boolean values are -# deprecated. Default: absent -# Allowed values: 'absent', 'present', 'latest -# -# [*gunicorn*] -# Desired installation state for Gunicorn. Boolean values are deprecated. -# Default: absent -# Allowed values: 'absent', 'present', 'latest' -# -# [*manage_gunicorn*] -# Allow Installation / Removal of Gunicorn. Default: true -# -# [*provider*] -# What provider to use for installation of the packages, except gunicorn and -# Python itself. Default: system default provider -# Allowed values: 'pip' -# -# [*use_epel*] -# Boolean to determine if the epel class is used. Default: true -# -# === Examples -# -# class { 'python': -# version => 'system', -# pip => 'present', -# dev => 'present', -# virtualenv => 'present', -# gunicorn => 'present', -# } -# -# === Authors -# -# Sergey Stankevich -# Garrett Honeycutt -# -class python ( - $ensure = $python::params::ensure, - $version = $python::params::version, - $pip = $python::params::pip, - $dev = $python::params::dev, - $virtualenv = $python::params::virtualenv, - $gunicorn = $python::params::gunicorn, - $manage_gunicorn = $python::params::manage_gunicorn, - $gunicorn_package_name = $python::params::gunicorn_package_name, - $provider = $python::params::provider, - $valid_versions = $python::params::valid_versions, - $python_pips = { }, - $python_virtualenvs = { }, - $python_pyvenvs = { }, - $python_requirements = { }, - $use_epel = $python::params::use_epel, - $rhscl_use_public_repository = $python::params::rhscl_use_public_repository, -) inherits python::params{ - - if $provider != undef and $provider != '' { - validate_re($provider, ['^(pip|scl|rhscl)$'], - "Only 'pip', 'rhscl' and 'scl' are valid providers besides the system default. Detected provider is <${provider}>.") - } - - $exec_prefix = $provider ? { - 'scl' => "/usr/bin/scl enable ${version} -- ", - 'rhscl' => "/usr/bin/scl enable ${version} -- ", - default => '', - } - - validate_re($ensure, ['^(absent|present|latest)$']) - validate_re($version, concat(['system', 'pypy'], $valid_versions)) - - if $pip == false or $pip == true { - warning('Use of boolean values for the $pip parameter is deprecated') - } else { - validate_re($pip, ['^(absent|present|latest)$']) - } - - if $virtualenv == false or $virtualenv == true { - warning('Use of boolean values for the $virtualenv parameter is deprecated') - } else { - validate_re($virtualenv, ['^(absent|present|latest)$']) - } - - if $virtualenv == false or $virtualenv == true { - warning('Use of boolean values for the $virtualenv parameter is deprecated') - } else { - validate_re($virtualenv, ['^(absent|present|latest)$']) - } - - if $gunicorn == false or $gunicorn == true { - warning('Use of boolean values for the $gunicorn parameter is deprecated') - } else { - validate_re($gunicorn, ['^(absent|present|latest)$']) - } - - validate_bool($manage_gunicorn) - validate_bool($use_epel) - - # Module compatibility check - $compatible = [ 'Debian', 'RedHat', 'Suse' ] - if ! ($::osfamily in $compatible) { - fail("Module is not compatible with ${::operatingsystem}") - } - - # Anchor pattern to contain dependencies - anchor { 'python::begin': } -> - class { 'python::install': } -> - class { 'python::config': } -> - anchor { 'python::end': } - - # Allow hiera configuration of python resources - create_resources('python::pip', $python_pips) - create_resources('python::pyvenv', $python_pyvenvs) - create_resources('python::virtualenv', $python_virtualenvs) - create_resources('python::requirements', $python_requirements) - -} diff --git a/vagrant/puppet/modules/python/manifests/install.pp b/vagrant/puppet/modules/python/manifests/install.pp deleted file mode 100644 index 57d507350..000000000 --- a/vagrant/puppet/modules/python/manifests/install.pp +++ /dev/null @@ -1,234 +0,0 @@ -# == Class: python::install -# -# Installs core python packages, -# -# === Examples -# -# include python::install -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Fotis Gimian -# Garrett Honeycutt -# -class python::install { - - $python = $::python::version ? { - 'system' => 'python', - 'pypy' => 'pypy', - default => "${python::version}", # lint:ignore:only_variable_string - } - - $pythondev = $::osfamily ? { - 'RedHat' => "${python}-devel", - 'Debian' => "${python}-dev", - 'Suse' => "${python}-devel", - } - - $dev_ensure = $python::dev ? { - true => 'present', - false => 'absent', - default => $python::dev, - } - - $pip_ensure = $python::pip ? { - true => 'present', - false => 'absent', - default => $python::pip, - } - - $venv_ensure = $python::virtualenv ? { - true => 'present', - false => 'absent', - default => $python::virtualenv, - } - - package { 'python': - ensure => $python::ensure, - name => $python, - } - - package { 'virtualenv': - ensure => $venv_ensure, - require => Package['python'], - } - - case $python::provider { - pip: { - - package { 'pip': - ensure => $pip_ensure, - require => Package['python'], - } - - package { 'python-dev': - ensure => $dev_ensure, - name => $pythondev, - } - - # Install pip without pip, see https://pip.pypa.io/en/stable/installing/. - exec { 'bootstrap pip': - command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python', - unless => 'which pip', - path => [ '/bin', '/usr/bin', '/usr/local/bin' ], - require => Package['python'], - } - - # Puppet is opinionated about the pip command name - file { 'pip-python': - ensure => link, - path => '/usr/bin/pip-python', - target => '/usr/bin/pip', - require => Exec['bootstrap pip'], - } - - Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |> - - Package <| title == 'pip' |> { - name => 'pip', - provider => 'pip', - } - Package <| title == 'virtualenv' |> { - name => 'virtualenv', - provider => 'pip', - } - } - scl: { - # SCL is only valid in the RedHat family. If RHEL, package must be - # enabled using the subscription manager outside of puppet. If CentOS, - # the centos-release-SCL will install the repository. - $install_scl_repo_package = $::operatingsystem ? { - 'CentOS' => 'present', - default => 'absent', - } - - package { 'centos-release-scl': - ensure => $install_scl_repo_package, - before => Package['scl-utils'], - } - package { 'scl-utils': - ensure => 'latest', - before => Package['python'], - } - - # This gets installed as a dependency anyway - # package { "${python::version}-python-virtualenv": - # ensure => $venv_ensure, - # require => Package['scl-utils'], - # } - package { "${python}-scldevel": - ensure => $dev_ensure, - require => Package['scl-utils'], - } - if $pip_ensure != 'absent' { - exec { 'python-scl-pip-install': - command => "${python::exec_prefix}easy_install pip", - path => ['/usr/bin', '/bin'], - creates => "/opt/rh/${python::version}/root/usr/bin/pip", - require => Package['scl-utils'], - } - } - } - rhscl: { - # rhscl is RedHat SCLs from softwarecollections.org - if $::python::rhscl_use_public_repository { - $scl_package = "rhscl-${::python::version}-epel-${::operatingsystemmajrelease}-${::architecture}" - package { $scl_package: - source => "https://www.softwarecollections.org/en/scls/rhscl/${::python::version}/epel-${::operatingsystemmajrelease}-${::architecture}/download/${scl_package}.noarch.rpm", - provider => 'rpm', - tag => 'python-scl-repo', - } - } - - Package <| title == 'python' |> { - tag => 'python-scl-package', - } - - Package <| title == 'virtualenv' |> { - name => "${python}-python-virtualenv", - } - - package { "${python}-scldevel": - ensure => $dev_ensure, - tag => 'python-scl-package', - } - - package { "${python}-python-pip": - ensure => $pip_ensure, - tag => 'python-pip-package', - } - - if $::python::rhscl_use_public_repository { - Package <| tag == 'python-scl-repo' |> -> - Package <| tag == 'python-scl-package' |> - } - - Package <| tag == 'python-scl-package' |> -> - Package <| tag == 'python-pip-package' |> - } - default: { - - package { 'pip': - ensure => $pip_ensure, - require => Package['python'], - } - - package { 'python-dev': - ensure => $dev_ensure, - name => $pythondev, - } - - if $::osfamily == 'RedHat' { - if $pip_ensure != 'absent' { - if $python::use_epel == true { - include 'epel' - Class['epel'] -> Package['pip'] - } - } - if ($venv_ensure != 'absent') and ($::operatingsystemrelease =~ /^6/) { - if $python::use_epel == true { - include 'epel' - Class['epel'] -> Package['virtualenv'] - } - } - - $virtualenv_package = "${python}-virtualenv" - } else { - if $::lsbdistcodename == 'jessie' { - $virtualenv_package = 'virtualenv' - } else { - $virtualenv_package = 'python-virtualenv' - } - } - - if $::python::version =~ /^3/ { - $pip_package = 'python3-pip' - } else { - $pip_package = 'python-pip' - } - - Package <| title == 'pip' |> { - name => $pip_package, - } - - Package <| title == 'virtualenv' |> { - name => $virtualenv_package, - } - } - } - - if $python::manage_gunicorn { - $gunicorn_ensure = $python::gunicorn ? { - true => 'present', - false => 'absent', - default => $python::gunicorn, - } - - package { 'gunicorn': - ensure => $gunicorn_ensure, - name => $python::gunicorn_package_name, - } - } -} diff --git a/vagrant/puppet/modules/python/manifests/params.pp b/vagrant/puppet/modules/python/manifests/params.pp deleted file mode 100644 index ee0a7b976..000000000 --- a/vagrant/puppet/modules/python/manifests/params.pp +++ /dev/null @@ -1,28 +0,0 @@ -# == Class: python::params -# -# The python Module default configuration settings. -# -class python::params { - $ensure = 'present' - $version = 'system' - $pip = 'present' - $dev = 'absent' - $virtualenv = 'absent' - $gunicorn = 'absent' - $manage_gunicorn = true - $provider = undef - $valid_versions = $::osfamily ? { - 'RedHat' => ['3','27','33'], - 'Debian' => ['3', '3.3', '2.7'], - 'Suse' => [], - } - $use_epel = true - - $gunicorn_package_name = $::osfamily ? { - 'RedHat' => 'python-gunicorn', - default => 'gunicorn', - } - - $rhscl_use_public_repository = true - -} diff --git a/vagrant/puppet/modules/python/manifests/pip.pp b/vagrant/puppet/modules/python/manifests/pip.pp deleted file mode 100644 index 6dd01017c..000000000 --- a/vagrant/puppet/modules/python/manifests/pip.pp +++ /dev/null @@ -1,275 +0,0 @@ -# == Define: python::pip -# -# Installs and manages packages from pip. -# -# === Parameters -# -# [*name] -# must be unique -# -# [*pkgname] -# name of the package. If pkgname is not specified, use name (title) instead. -# -# [*ensure*] -# present|absent. Default: present -# -# [*virtualenv*] -# virtualenv to run pip in. -# -# [*url*] -# URL to install from. Default: none -# -# [*owner*] -# The owner of the virtualenv being manipulated. Default: root -# -# [*group*] -# The group of the virtualenv being manipulated. Default: root -# -# [*index*] -# Base URL of Python package index. Default: none (http://pypi.python.org/simple/) -# -# [*proxy*] -# Proxy server to use for outbound connections. Default: none -# -# [*editable*] -# Boolean. If true the package is installed as an editable resource. -# -# [*environment*] -# Additional environment variables required to install the packages. Default: none -# -# [*timeout*] -# The maximum time in seconds the "pip install" command should take. Default: 1800 -# -# [*install_args*] -# String. Any additional installation arguments that will be supplied -# when running pip install. -# -# [*uninstall_args*] -# String. Any additional arguments that will be supplied when running -# pip uninstall. -# -# [*log_dir*] -# String. Log directory. -# -# === Examples -# -# python::pip { 'flask': -# virtualenv => '/var/www/project1', -# proxy => 'http://proxy.domain.com:3128', -# index => 'http://www.example.com/simple/', -# } -# -# === Authors -# -# Sergey Stankevich -# Fotis Gimian -# -define python::pip ( - $pkgname = $name, - $ensure = present, - $virtualenv = 'system', - $url = false, - $owner = 'root', - $group = 'root', - $index = false, - $proxy = false, - $egg = false, - $editable = false, - $environment = [], - $install_args = '', - $uninstall_args = '', - $timeout = 1800, - $log_dir = '/tmp', - $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], -) { - - $python_provider = getparam(Class['python'], 'provider') - $python_version = getparam(Class['python'], 'version') - - # Get SCL exec prefix - # NB: this will not work if you are running puppet from scl enabled shell - $exec_prefix = $python_provider ? { - 'scl' => "scl enable ${python_version} -- ", - 'rhscl' => "scl enable ${python_version} -- ", - default => '', - } - - # Parameter validation - if ! $virtualenv { - fail('python::pip: virtualenv parameter must not be empty') - } - - if $virtualenv == 'system' and $owner != 'root' { - fail('python::pip: root user must be used when virtualenv is system') - } - - $cwd = $virtualenv ? { - 'system' => '/', - default => $virtualenv, - } - - validate_absolute_path($cwd) - - $log = $virtualenv ? { - 'system' => $log_dir, - default => $virtualenv, - } - - $pip_env = $virtualenv ? { - 'system' => "${exec_prefix}pip", - default => "${exec_prefix}${virtualenv}/bin/pip", - } - - $pypi_index = $index ? { - false => '', - default => "--index-url=${index}", - } - - $pypi_search_index = $index ? { - false => '', - default => "--index=${index}", - } - - $proxy_flag = $proxy ? { - false => '', - default => "--proxy=${proxy}", - } - - if $editable == true { - $install_editable = ' -e ' - } - else { - $install_editable = '' - } - - #TODO: Do more robust argument checking, but below is a start - if ($ensure == absent) and ($install_args != '') { - fail('python::pip cannot provide install_args with ensure => absent') - } - - if ($ensure == present) and ($uninstall_args != '') { - fail('python::pip cannot provide uninstall_args with ensure => present') - } - - # Check if searching by explicit version. - if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.\w+\+?\w*(\.\w+)*)$/ { - $grep_regex = "^${pkgname}==${ensure}\$" - } else { - $grep_regex = $pkgname ? { - /==/ => "^${pkgname}\$", - default => "^${pkgname}==", - } - } - - $egg_name = $egg ? { - false => $pkgname, - default => $egg - } - - $source = $url ? { - false => $pkgname, - /^(\/|[a-zA-Z]\:)/ => $url, - /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ => $url, - default => "${url}#egg=${egg_name}", - } - - # We need to jump through hoops to make sure we issue the correct pip command - # depending on wheel support and versions. - # - # Pip does not support wheels prior to version 1.4.0 - # Pip wheels require setuptools/distribute > 0.8 - # Python 2.6 and older does not support setuptools/distribute > 0.8 - # Pip >= 1.5 tries to use wheels by default, even if wheel package is not - # installed, in this case the --no-use-wheel flag needs to be passed - # Versions prior to 1.5 don't support the --no-use-wheel flag - # - # To check for this we test for wheel parameter using help and then using - # version, this makes sure we only use wheels if they are supported and - # installed - - # Explicit version out of VCS when PIP supported URL is provided - if $source =~ /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ { - if $ensure != present and $ensure != latest { - exec { "pip_install_${name}": - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} ;}", - unless => "${pip_env} freeze | grep -i -e ${grep_regex}", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } else { - exec { "pip_install_${name}": - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", - unless => "${pip_env} freeze | grep -i -e ${grep_regex}", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } - } else { - case $ensure { - /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.\w+\+?\w*(\.\w+)*)$/: { - # Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes - # Explicit version. - exec { "pip_install_${name}": - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} ;}", - unless => "${pip_env} freeze | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } -# - present: { - # Whatever version is available. - exec { "pip_install_${name}": - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", - unless => "${pip_env} freeze | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } - - latest: { - # Latest version. - exec { "pip_install_${name}": - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install --upgrade \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install --upgrade ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", - unless => "${pip_env} search ${pypi_search_index} ${proxy_flag} ${source} | grep -i INSTALLED.*latest", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } - - default: { - # Anti-action, uninstall. - exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag}", - onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", - user => $owner, - group => $group, - cwd => $cwd, - environment => $environment, - timeout => $timeout, - path => $path, - } - } - } - } -} diff --git a/vagrant/puppet/modules/python/manifests/pyvenv.pp b/vagrant/puppet/modules/python/manifests/pyvenv.pp deleted file mode 100644 index 5f8feceaf..000000000 --- a/vagrant/puppet/modules/python/manifests/pyvenv.pp +++ /dev/null @@ -1,104 +0,0 @@ -# == Define: python::pyvenv -# -# Create a Python3 virtualenv using pyvenv. -# -# === Parameters -# -# [*ensure*] -# present|absent. Default: present -# -# [*version*] -# Python version to use. Default: system default -# -# [*systempkgs*] -# Copy system site-packages into virtualenv. Default: don't -# -# [*venv_dir*] -# Directory to install virtualenv to. Default: $name -# -# [*owner*] -# The owner of the virtualenv being manipulated. Default: root -# -# [*group*] -# The group relating to the virtualenv being manipulated. Default: root -# -# [*mode*] -# Optionally specify directory mode. Default: 0755 -# -# [*path*] -# Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] - -# [*environment*] -# Optionally specify environment variables for pyvenv -# -# === Examples -# -# python::venv { '/var/www/project1': -# ensure => present, -# version => 'system', -# systempkgs => true, -# } -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Marc Fournier -# Fotis Gimian -# Seth Cleveland -# -define python::pyvenv ( - $ensure = present, - $version = 'system', - $systempkgs = false, - $venv_dir = $name, - $owner = 'root', - $group = 'root', - $mode = '0755', - $path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ], - $environment = [], -) { - - include ::python - - if $ensure == 'present' { - - $virtualenv_cmd = $version ? { - 'system' => "${python::exec_prefix}pyvenv", - default => "${python::exec_prefix}pyvenv-${version}", - } - - if ( $systempkgs == true ) { - $system_pkgs_flag = '--system-site-packages' - } else { - $system_pkgs_flag = '' - } - - file { $venv_dir: - ensure => directory, - owner => $owner, - group => $group, - mode => $mode - } - - exec { "python_virtualenv_${venv_dir}": - command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${venv_dir}", - user => $owner, - creates => "${venv_dir}/bin/activate", - path => $path, - cwd => '/tmp', - environment => $environment, - unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv - require => File[$venv_dir], - } - } elsif $ensure == 'absent' { - file { $venv_dir: - ensure => absent, - force => true, - recurse => true, - purge => true, - } - } else { - fail( "Illegal ensure value: ${ensure}. Expected (present or absent)") - } -} diff --git a/vagrant/puppet/modules/python/manifests/requirements.pp b/vagrant/puppet/modules/python/manifests/requirements.pp deleted file mode 100644 index 75d2b698b..000000000 --- a/vagrant/puppet/modules/python/manifests/requirements.pp +++ /dev/null @@ -1,141 +0,0 @@ -# == Define: python::requirements -# -# Installs and manages Python packages from requirements file. -# -# === Parameters -# -# [*requirements*] -# Path to the requirements file. Defaults to the resource name -# -# [*virtualenv*] -# virtualenv to run pip in. Default: system-wide -# -# [*owner*] -# The owner of the virtualenv being manipulated. Default: root -# -# [*group*] -# The group relating to the virtualenv being manipulated. Default: root -# -# [*proxy*] -# Proxy server to use for outbound connections. Default: none -# -# [*src*] -# Pip --src parameter; if the requirements file contains --editable resources, -# this parameter specifies where they will be installed. See the pip -# documentation for more. Default: none (i.e. use the pip default). -# -# [*environment*] -# Additional environment variables required to install the packages. Default: none -# -# [*forceupdate*] -# Run a pip install requirements even if we don't receive an event from the -# requirements file - Useful for when the requirements file is written as part of a -# resource other than file (E.g vcsrepo) -# -# [*cwd*] -# The directory from which to run the "pip install" command. Default: undef -# -# [*extra_pip_args*] -# Extra arguments to pass to pip after the requirements file -# -# [*manage_requirements*] -# Create the requirements file if it doesn't exist. Default: true -# -# [*fix_requirements_owner*] -# Change owner and group of requirements file. Default: true -# -# [*log_dir*] -# String. Log directory. -# -# [*timeout*] -# The maximum time in seconds the "pip install" command should take. Default: 1800 -# -# === Examples -# -# python::requirements { '/var/www/project1/requirements.txt': -# virtualenv => '/var/www/project1', -# proxy => 'http://proxy.domain.com:3128', -# } -# -# === Authors -# -# Sergey Stankevich -# Ashley Penney -# Fotis Gimian -# -define python::requirements ( - $requirements = $name, - $virtualenv = 'system', - $owner = 'root', - $group = 'root', - $proxy = false, - $src = false, - $environment = [], - $forceupdate = false, - $cwd = undef, - $extra_pip_args = '', - $manage_requirements = true, - $fix_requirements_owner = true, - $log_dir = '/tmp', - $timeout = 1800, -) { - - include ::python - - if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { - fail('python::pip: root user must be used when virtualenv is system') - } - - if $fix_requirements_owner { - $owner_real = $owner - $group_real = $group - } else { - $owner_real = undef - $group_real = undef - } - - $log = $virtualenv ? { - 'system' => $log_dir, - default => $virtualenv, - } - - $pip_env = $virtualenv ? { - 'system' => "${::python::exec_prefix} pip", - default => "${::python::exec_prefix} ${virtualenv}/bin/pip", - } - - $proxy_flag = $proxy ? { - false => '', - default => "--proxy=${proxy}", - } - - $src_flag = $src ? { - false => '', - default => "--src=${src}", - } - - # This will ensure multiple python::virtualenv definitions can share the - # the same requirements file. - if !defined(File[$requirements]) and $manage_requirements == true { - file { $requirements: - ensure => present, - mode => '0644', - owner => $owner_real, - group => $group_real, - audit => content, - replace => false, - content => '# Puppet will install and/or update pip packages listed here', - } - } - - exec { "python_requirements${name}": - provider => shell, - command => "${pip_env} --log ${log}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements} ${extra_pip_args}", - refreshonly => !$forceupdate, - timeout => $timeout, - cwd => $cwd, - user => $owner, - subscribe => File[$requirements], - environment => $environment, - } -} diff --git a/vagrant/puppet/modules/python/manifests/virtualenv.pp b/vagrant/puppet/modules/python/manifests/virtualenv.pp deleted file mode 100644 index 459b33998..000000000 --- a/vagrant/puppet/modules/python/manifests/virtualenv.pp +++ /dev/null @@ -1,202 +0,0 @@ -# == Define: python::virtualenv -# -# Creates Python virtualenv. -# -# === Parameters -# -# [*ensure*] -# present|absent. Default: present -# -# [*version*] -# Python version to use. Default: system default -# -# [*requirements*] -# Path to pip requirements.txt file. Default: none -# -# [*systempkgs*] -# Copy system site-packages into virtualenv. Default: don't -# If virtualenv version < 1.7 this flag has no effect since -# [*venv_dir*] -# Directory to install virtualenv to. Default: $name -# -# [*distribute*] -# Include distribute in the virtualenv. Default: true -# -# [*index*] -# Base URL of Python package index. Default: none (http://pypi.python.org/simple/) -# -# [*owner*] -# The owner of the virtualenv being manipulated. Default: root -# -# [*group*] -# The group relating to the virtualenv being manipulated. Default: root -# -# [*mode*] -# Optionally specify directory mode. Default: 0755 -# -# [*proxy*] -# Proxy server to use for outbound connections. Default: none -# -# [*environment*] -# Additional environment variables required to install the packages. Default: none -# -# [*path*] -# Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] -# -# [*cwd*] -# The directory from which to run the "pip install" command. Default: undef -# -# [*timeout*] -# The maximum time in seconds the "pip install" command should take. Default: 1800 -# -# [*extra_pip_args*] -# Extra arguments to pass to pip after requirements file. Default: blank -# -# === Examples -# -# python::virtualenv { '/var/www/project1': -# ensure => present, -# version => 'system', -# requirements => '/var/www/project1/requirements.txt', -# proxy => 'http://proxy.domain.com:3128', -# systempkgs => true, -# index => 'http://www.example.com/simple/', -# } -# -# === Authors -# -# Sergey Stankevich -# Shiva Poudel -# -define python::virtualenv ( - $ensure = present, - $version = 'system', - $requirements = false, - $systempkgs = false, - $venv_dir = $name, - $distribute = true, - $index = false, - $owner = 'root', - $group = 'root', - $mode = '0755', - $proxy = false, - $environment = [], - $path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ], - $cwd = undef, - $timeout = 1800, - $extra_pip_args = '', - $virtualenv = undef -) { - include ::python - - if $ensure == 'present' { - $python = $version ? { - 'system' => 'python', - 'pypy' => 'pypy', - default => "python${version}", - } - - if $virtualenv == undef { - $used_virtualenv = 'virtualenv' - } else { - $used_virtualenv = $virtualenv - } - - $proxy_flag = $proxy ? { - false => '', - default => "--proxy=${proxy}", - } - - $proxy_command = $proxy ? { - false => '', - default => "&& export http_proxy=${proxy}", - } - - # Virtualenv versions prior to 1.7 do not support the - # --system-site-packages flag, default off for prior versions - # Prior to version 1.7 the default was equal to --system-site-packages - # and the flag --no-site-packages had to be passed to do the opposite - $_virtualenv_version = getvar('virtualenv_version') ? { - /.*/ => getvar('virtualenv_version'), - default => '', - } - if (( versioncmp($_virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { - $system_pkgs_flag = '--system-site-packages' - } elsif (( versioncmp($_virtualenv_version,'1.7') < 0 ) and ( $systempkgs == false )) { - $system_pkgs_flag = '--no-site-packages' - } else { - $system_pkgs_flag = $systempkgs ? { - true => '--system-site-packages', - false => '--no-site-packages', - default => fail('Invalid value for systempkgs. Boolean value is expected') - } - } - - $distribute_pkg = $distribute ? { - true => 'distribute', - default => 'setuptools', - } - $pypi_index = $index ? { - false => '', - default => "-i ${index}", - } - - # Python 2.6 and older does not support setuptools/distribute > 0.8 which - # is required for pip wheel support, pip therefor requires --no-use-wheel flag - # if the # pip version is more recent than 1.4.1 but using an old python or - # setuputils/distribute version - # To check for this we test for wheel parameter using help and then using - # version, this makes sure we only use wheels if they are supported - - file { $venv_dir: - ensure => directory, - owner => $owner, - group => $group, - mode => $mode - } - - $virtualenv_cmd = "${python::exec_prefix}${used_virtualenv}" - $pip_cmd = "${python::exec_prefix}${venv_dir}/bin/pip" - - exec { "python_virtualenv_${venv_dir}": - command => "true ${proxy_command} && ${virtualenv_cmd} ${system_pkgs_flag} -p ${python} ${venv_dir} && ${pip_cmd} wheel --help > /dev/null 2>&1 && { ${pip_cmd} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_cmd} --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${pip_cmd} --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} ;}", - user => $owner, - creates => "${venv_dir}/bin/activate", - path => $path, - cwd => '/tmp', - environment => $environment, - unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv - require => File[$venv_dir], - } - - if $requirements { - exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${pip_cmd} wheel --help > /dev/null 2>&1 && { ${pip_cmd} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_cmd} --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag -r ${requirements} ${extra_pip_args}", - refreshonly => true, - timeout => $timeout, - user => $owner, - subscribe => Exec["python_virtualenv_${venv_dir}"], - environment => $environment, - cwd => $cwd - } - - python::requirements { "${requirements}_${venv_dir}": - requirements => $requirements, - virtualenv => $venv_dir, - proxy => $proxy, - owner => $owner, - group => $group, - cwd => $cwd, - require => Exec["python_virtualenv_${venv_dir}"], - extra_pip_args => $extra_pip_args, - } - } - } elsif $ensure == 'absent' { - file { $venv_dir: - ensure => absent, - force => true, - recurse => true, - purge => true, - } - } -} diff --git a/vagrant/puppet/modules/python/metadata.json b/vagrant/puppet/modules/python/metadata.json deleted file mode 100644 index 9dc047926..000000000 --- a/vagrant/puppet/modules/python/metadata.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "stankevich-python", - "version": "1.17.0", - "author": "stankevich", - "summary": "Python Module", - "license": "Apache-2.0", - "source": "git://github.com/stankevich/puppet-python.git", - "project_page": "https://github.com/stankevich/puppet-python", - "issues_url": "https://github.com/stankevich/puppet-python/issues", - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}, - {"name":"stahnma/epel","version_requirement":">= 1.2.2 < 2.0.0"} - ], - "data_provider": null, - "description": "Puppet module for Python", - "tags": [ - "python", - "pip", - "virtualenv", - "gunicorn" - ], - "operatingsystem_support": [ - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "11.3" - ] - } - ], - "requirements": [ - { - "name": "puppet", - "version_requirement": ">=3.0.0 < 5.0.0" - } - ] -} diff --git a/vagrant/puppet/modules/python/spec/acceptance/class_spec.rb b/vagrant/puppet/modules/python/spec/acceptance/class_spec.rb deleted file mode 100644 index 0b65659cf..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/class_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'python class' do - - context 'default parameters' do - # Using puppet_apply as a helper - it 'should work with no errors' do - pp = <<-EOS - class { 'python': } - EOS - - # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - end -end diff --git a/vagrant/puppet/modules/python/spec/acceptance/facts_test_spec.rb b/vagrant/puppet/modules/python/spec/acceptance/facts_test_spec.rb deleted file mode 100644 index 6393c01f4..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/facts_test_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'python class' do - - context 'facts' do - install_python = <<-EOS - class { 'python' : - version => 'system', - pip => 'present', - virtualenv => 'present', - } - EOS - - fact_notices = <<-EOS - notify{"pip_version: ${::pip_version}":} - notify{"system_python_version: ${::system_python_version}":} - notify{"python_version: ${::python_version}":} - notify{"virtualenv_version: ${::virtualenv_version}":} - EOS - - it 'should output python facts when not installed' do - apply_manifest(fact_notices, :catch_failures => true) do |r| - expect(r.stdout).to match(/python_version: \S+/) - expect(r.stdout).to match(/pip_version: \S+/) - expect(r.stdout).to match(/virtualenv_version: \S+/) - expect(r.stdout).to match(/system_python_version: \S+/) - end - end - - it 'sets up python' do - apply_manifest(install_python, :catch_failures => true) - end - - it 'should output python facts when installed' do - apply_manifest(fact_notices, :catch_failures => true) do |r| - expect(r.stdout).to match(/python_version: \S+/) - expect(r.stdout).to match(/pip_version: \S+/) - expect(r.stdout).to match(/virtualenv_version: \S+/) - expect(r.stdout).to match(/system_python_version: \S+/) - end - end - end -end diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-59-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-59-x64.yml deleted file mode 100644 index 2ad90b86a..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-59-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-59-x64: - roles: - - master - platform: el-5-x86_64 - box : centos-59-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: git diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-64-x64-pe.yml deleted file mode 100644 index 7d9242f1b..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-64-x64-pe.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - centos-64-x64: - roles: - - master - - database - - dashboard - platform: el-6-x86_64 - box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: pe diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-65-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-65-x64.yml deleted file mode 100644 index 4e2cb809e..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/centos-65-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-vbox436-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-70rc1-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-70rc1-x64.yml deleted file mode 100644 index 4b55677f4..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-70rc1-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - debian-70rc1-x64: - roles: - - master - platform: debian-70rc1-x64 - box : debian-70rc1-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-73-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-73-x64.yml deleted file mode 100644 index d71434551..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/debian-73-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-73-x64: - roles: - - master - platform: debian-7-amd64 - box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: git \ No newline at end of file diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/default.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/default.yml deleted file mode 100644 index 45af98934..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - ubuntu-server-12042-x64: - roles: - - master - platform: ubuntu-server-12.04-amd64 - box : ubuntu-server-12042-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss - vagrant_ssh_port_random: true diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml deleted file mode 100644 index 5ca1514e4..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-server-10044-x64: - roles: - - master - platform: ubuntu-10.04-amd64 - box : ubuntu-server-10044-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml deleted file mode 100644 index d065b304f..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-server-12042-x64: - roles: - - master - platform: ubuntu-12.04-amd64 - box : ubuntu-server-12042-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml deleted file mode 100644 index cba1cd04c..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - ubuntu-server-1404-x64: - roles: - - master - platform: ubuntu-14.04-amd64 - box : puppetlabs/ubuntu-14.04-64-nocm - box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm - hypervisor : vagrant -CONFIG: - log_level : debug - type: git diff --git a/vagrant/puppet/modules/python/spec/acceptance/virtualenv_spec.rb b/vagrant/puppet/modules/python/spec/acceptance/virtualenv_spec.rb deleted file mode 100644 index 2dfbdc3dd..000000000 --- a/vagrant/puppet/modules/python/spec/acceptance/virtualenv_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'python class' do - - context 'default parameters' do - # Using puppet_apply as a helper - it 'should work with no errors' do - pp = <<-EOS - class { 'python' : - version => 'system', - pip => 'present', - virtualenv => 'present', - } - -> - python::virtualenv { 'venv' : - ensure => 'present', - systempkgs => false, - venv_dir => '/opt/venv', - owner => 'root', - group => 'root', - } - -> - python::pip { 'rpyc' : - ensure => '3.2.3', - virtualenv => '/opt/venv', - } - EOS - - # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - end -end diff --git a/vagrant/puppet/modules/python/spec/classes/python_spec.rb b/vagrant/puppet/modules/python/spec/classes/python_spec.rb deleted file mode 100644 index f494c33e4..000000000 --- a/vagrant/puppet/modules/python/spec/classes/python_spec.rb +++ /dev/null @@ -1,275 +0,0 @@ -require 'spec_helper' - -describe 'python', :type => :class do - context "on Debian OS" do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :lsbdistcodename => 'squeeze', - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :concat_basedir => '/dne', - } - end - - it { is_expected.to contain_class("python::install") } - # Base debian packages. - it { is_expected.to contain_package("python") } - it { is_expected.to contain_package("python-dev") } - it { is_expected.to contain_package("pip") } - # Basic python packages (from pip) - it { is_expected.to contain_package("virtualenv")} - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "empty/default" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - - describe "with manage_gunicorn" do - context "true" do - let (:params) {{ :manage_gunicorn => true }} - it { is_expected.to contain_package("gunicorn") } - end - context "empty args" do - #let (:params) {{ :manage_gunicorn => '' }} - it { is_expected.to contain_package("gunicorn") } - end - context "false" do - let (:params) {{ :manage_gunicorn => false }} - it {is_expected.not_to contain_package("gunicorn")} - end - end - - describe "with python::provider" do - context "pip" do - let (:params) {{ :provider => 'pip' }} - it { is_expected.to contain_package("virtualenv").with( - 'provider' => 'pip' - )} - it { is_expected.to contain_package("pip").with( - 'provider' => 'pip' - )} - end - - # python::provider - context "default" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv")} - it { is_expected.to contain_package("pip")} - - describe "with python::virtualenv" do - context "true" do - let (:params) {{ :provider => '', :virtualenv => true }} - it { is_expected.to contain_package("virtualenv").with_ensure('present') } - end - end - - describe "without python::virtualenv" do - context "default/empty" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv").with_ensure('absent') } - end - end - end - end - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "default/empty" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - end - - context "on a Redhat 5 OS" do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '5', - :concat_basedir => '/dne', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it { is_expected.to contain_class("python::install") } - # Base debian packages. - it { is_expected.to contain_package("python") } - it { is_expected.to contain_package("python-dev").with_name("python-devel") } - it { is_expected.to contain_package("pip") } - # Basic python packages (from pip) - it { is_expected.to contain_package("virtualenv")} - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "empty/default" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - - describe "with manage_gunicorn" do - context "true" do - let (:params) {{ :manage_gunicorn => true }} - it { is_expected.to contain_package("gunicorn") } - end - context "empty args" do - #let (:params) {{ :manage_gunicorn => '' }} - it { is_expected.to contain_package("gunicorn") } - end - context "false" do - let (:params) {{ :manage_gunicorn => false }} - it {is_expected.not_to contain_package("gunicorn")} - end - end - - describe "with python::provider" do - context "pip" do - let (:params) {{ :provider => 'pip' }} - - it { is_expected.to contain_package("virtualenv").with( - 'provider' => 'pip' - )} - it { is_expected.to contain_package("pip").with( - 'provider' => 'pip' - )} - end - - # python::provider - context "default" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv")} - it { is_expected.to contain_package("pip")} - - describe "with python::virtualenv" do - context "true" do - let (:params) {{ :provider => '', :virtualenv => 'present' }} - it { is_expected.to contain_package("virtualenv").with_ensure('present') } - end - end - - describe "with python::virtualenv" do - context "default/empty" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv").with_ensure('absent') } - end - end - end - end - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "default/empty" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - end - - context "on a SLES 11 SP3" do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :lsbdistcodename => nil, - :osfamily => 'Suse', - :operatingsystem => 'SLES', - :operatingsystemrelease => '11.3', - :concat_basedir => '/dne', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - } - end - it { is_expected.to contain_class("python::install") } - # Base Suse packages. - it { is_expected.to contain_package("python") } - it { is_expected.to contain_package("python-dev").with_name("python-devel") } - it { is_expected.to contain_package("pip") } - # Basic python packages (from pip) - it { is_expected.to contain_package("virtualenv")} - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "empty/default" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - - describe "with manage_gunicorn" do - context "true" do - let (:params) {{ :manage_gunicorn => true }} - it { is_expected.to contain_package("gunicorn") } - end - context "empty args" do - #let (:params) {{ :manage_gunicorn => '' }} - it { is_expected.to contain_package("gunicorn") } - end - context "false" do - let (:params) {{ :manage_gunicorn => false }} - it {is_expected.not_to contain_package("gunicorn")} - end - end - - describe "with python::provider" do - context "pip" do - let (:params) {{ :provider => 'pip' }} - - it { is_expected.to contain_package("virtualenv").with( - 'provider' => 'pip' - )} - it { is_expected.to contain_package("pip").with( - 'provider' => 'pip' - )} - end - - # python::provider - context "default" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv")} - it { is_expected.to contain_package("pip")} - - describe "with python::virtualenv" do - context "true" do - let (:params) {{ :provider => '', :virtualenv => 'present' }} - it { is_expected.to contain_package("virtualenv").with_ensure('present') } - end - end - - describe "with python::virtualenv" do - context "default/empty" do - let (:params) {{ :provider => '' }} - it { is_expected.to contain_package("virtualenv").with_ensure('absent') } - end - end - end - end - - describe "with python::dev" do - context "true" do - let (:params) {{ :dev => 'present' }} - it { is_expected.to contain_package("python-dev").with_ensure('present') } - end - context "default/empty" do - it { is_expected.to contain_package("python-dev").with_ensure('absent') } - end - end - end -end diff --git a/vagrant/puppet/modules/python/spec/defines/gunicorn_spec.rb b/vagrant/puppet/modules/python/spec/defines/gunicorn_spec.rb deleted file mode 100644 index 116ad414f..000000000 --- a/vagrant/puppet/modules/python/spec/defines/gunicorn_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'python::gunicorn', :type => :define do - let(:title) { 'test-app' } - context 'on Debian OS' do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :lsbdistcodename => 'squeeze', - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :concat_basedir => '/dne', - } - end - - describe 'test-app with default parameter values' do - context 'configures test app with default parameter values' do - let(:params) { { :dir => '/srv/testapp' } } - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=error/) } - end - - context 'test-app with custom log level' do - let(:params) { { :dir => '/srv/testapp', :log_level => 'info' } } - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=info/) } - end - - context 'test-app with custom gunicorn preload arguments' do - let(:params) { { :dir => '/srv/testapp', :args => ['--preload'] } } - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--preload/) } - end - end - end -end diff --git a/vagrant/puppet/modules/python/spec/defines/pip_spec.rb b/vagrant/puppet/modules/python/spec/defines/pip_spec.rb deleted file mode 100644 index e03fd7f1c..000000000 --- a/vagrant/puppet/modules/python/spec/defines/pip_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'spec_helper' - -describe 'python::pip', :type => :define do - let (:title) { 'rpyc' } - context "on Debian OS" do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :lsbdistcodename => 'squeeze', - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :concat_basedir => '/dne', - } - end - - describe "virtualenv as" do - context "fails with non qualified path" do - let (:params) {{ :virtualenv => "venv" }} - it { is_expected.to raise_error(/"venv" is not an absolute path./) } - end - context "suceeds with qualified path" do - let (:params) {{ :virtualenv => "/opt/venv" }} - it { is_expected.to contain_exec("pip_install_rpyc").with_cwd('/opt/venv') } - end - context "defaults to system" do - let (:params) {{ }} - it { is_expected.to contain_exec("pip_install_rpyc").with_cwd('/') } - end - end - - describe "proxy as" do - context "defaults to empty" do - let (:params) {{ }} - it { is_expected.to contain_exec("pip_install_rpyc").without_command(/--proxy/) } - end - context "does not add proxy to search command if set to latest and proxy is unset" do - let (:params) {{ :ensure => 'latest' }} - it { is_expected.to contain_exec("pip_install_rpyc").without_command(/--proxy/) } - it { is_expected.to contain_exec("pip_install_rpyc").without_unless(/--proxy/) } - end - context "adds proxy to install command if proxy set" do - let (:params) {{ :proxy => "http://my.proxy:3128" }} - it { is_expected.to contain_exec("pip_install_rpyc").with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install $wheel_support_flag --proxy=http://my.proxy:3128 rpyc || pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc ;}") } - end - context "adds proxy to search command if set to latest" do - let (:params) {{ :proxy => "http://my.proxy:3128", :ensure => 'latest' }} - it { is_expected.to contain_exec("pip_install_rpyc").with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install --upgrade $wheel_support_flag --proxy=http://my.proxy:3128 rpyc || pip --log /tmp/pip.log install --upgrade --proxy=http://my.proxy:3128 rpyc ;}") } - it { is_expected.to contain_exec("pip_install_rpyc").with_unless('pip search --proxy=http://my.proxy:3128 rpyc | grep -i INSTALLED.*latest') } - end - end - - describe 'index as' do - context 'defaults to empty' do - let (:params) {{ }} - it { is_expected.to contain_exec('pip_install_rpyc').without_command(/--index-url/) } - end - context 'adds index to install command if index set' do - let (:params) {{ :index => 'http://www.example.com/simple/' }} - it { is_expected.to contain_exec('pip_install_rpyc').with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install $wheel_support_flag --index-url=http://www.example.com/simple/ rpyc || pip --log /tmp/pip.log install --index-url=http://www.example.com/simple/ rpyc ;}") } - end - context 'adds index to search command if set to latest' do - let (:params) {{ :index => 'http://www.example.com/simple/', :ensure => 'latest' }} - it { is_expected.to contain_exec('pip_install_rpyc').with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install --upgrade $wheel_support_flag --index-url=http://www.example.com/simple/ rpyc || pip --log /tmp/pip.log install --upgrade --index-url=http://www.example.com/simple/ rpyc ;}") } - end - end - - end -end diff --git a/vagrant/puppet/modules/python/spec/defines/pyvenv_spec.rb b/vagrant/puppet/modules/python/spec/defines/pyvenv_spec.rb deleted file mode 100644 index f801a103d..000000000 --- a/vagrant/puppet/modules/python/spec/defines/pyvenv_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'python::pyvenv', :type => :define do - let (:title) { '/opt/env' } - let (:facts) do - { - :lsbdistcodename => 'jessie', - :osfamily => 'Debian', - } - end - - it { - is_expected.to contain_file( '/opt/env') - is_expected.to contain_exec( "python_virtualenv_/opt/env").with_command("pyvenv --clear /opt/env") - } - - describe 'when ensure' do - context "is absent" do - let (:params) {{ - :ensure => 'absent' - }} - it { - is_expected.to contain_file( '/opt/env').with_ensure('absent').with_purge( true) - } - end - end -end diff --git a/vagrant/puppet/modules/python/spec/defines/requirements_spec.rb b/vagrant/puppet/modules/python/spec/defines/requirements_spec.rb deleted file mode 100644 index daf564230..000000000 --- a/vagrant/puppet/modules/python/spec/defines/requirements_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper' - -describe 'python::requirements', :type => :define do - let (:title) { '/requirements.txt' } - context "on Debian OS" do - let :facts do - { - :id => 'root', - :kernel => 'Linux', - :lsbdistcodename => 'squeeze', - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '6', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :concat_basedir => '/dne', - } - end - - describe "requirements as" do - context "/requirements.txt" do - let (:params) {{ :requirements => "/requirements.txt" }} - it { is_expected.to contain_file("/requirements.txt").with_mode('0644') } - end - context "/requirements.txt" do - let (:params) {{ :requirements => "/requirements.txt", :manage_requirements => false }} - it { is_expected.not_to contain_file("/requirements.txt") } - end - - describe "with owner" do - context "bob:bob" do - let (:params) {{ - :owner => 'bob', - :group => 'bob' - }} - it do - expect { - is_expected.to compile - }.to raise_error(/root user must be used when virtualenv is system/) - end - end - end - - describe "with owner" do - context "default" do - it { is_expected.to contain_file("/requirements.txt").with_owner('root').with_group('root') } - end - end - end - end -end diff --git a/vagrant/puppet/modules/python/spec/spec.opts b/vagrant/puppet/modules/python/spec/spec.opts deleted file mode 100644 index 91cd6427e..000000000 --- a/vagrant/puppet/modules/python/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/vagrant/puppet/modules/python/spec/spec_helper.rb b/vagrant/puppet/modules/python/spec/spec_helper.rb deleted file mode 100644 index 2c6f56649..000000000 --- a/vagrant/puppet/modules/python/spec/spec_helper.rb +++ /dev/null @@ -1 +0,0 @@ -require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/puppet/modules/python/spec/spec_helper_acceptance.rb b/vagrant/puppet/modules/python/spec/spec_helper_acceptance.rb deleted file mode 100644 index c1bb62269..000000000 --- a/vagrant/puppet/modules/python/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'beaker-rspec' - -UNSUPPORTED_PLATFORMS = [ 'windows' ] - -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - hosts.each do |host| - if host.is_pe? - install_pe - else - install_puppet - end - end -end - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - hosts.each do |host| - shell("rm -rf /etc/puppet/modules/python/") - copy_module_to(host, :source => proj_root, :module_name => 'python') - shell("/bin/touch #{default['puppetpath']}/hiera.yaml") - on host, puppet('module install puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module install stahnma-epel'), { :acceptable_exit_codes => [0,1] } - end - end -end diff --git a/vagrant/puppet/modules/python/spec/unit/facter/pip_version_spec.rb b/vagrant/puppet/modules/python/spec/unit/facter/pip_version_spec.rb deleted file mode 100644 index 63a6187b4..000000000 --- a/vagrant/puppet/modules/python/spec/unit/facter/pip_version_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "spec_helper" - -describe Facter::Util::Fact do - before { - Facter.clear - } - - let(:pip_version_output) { <<-EOS -pip 6.0.6 from /opt/boxen/homebrew/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg (python 2.7) -EOS - } - - describe "pip_version" do - context 'returns pip version when pip present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("pip").returns(true) - Facter::Util::Resolution.expects(:exec).with("pip --version 2>&1").returns(pip_version_output) - expect(Facter.value(:pip_version)).to eq("6.0.6") - end - end - - context 'returns nil when pip not present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("pip").returns(false) - expect(Facter.value(:pip_version)).to eq(nil) - end - end - - end -end diff --git a/vagrant/puppet/modules/python/spec/unit/facter/python_version_spec.rb b/vagrant/puppet/modules/python/spec/unit/facter/python_version_spec.rb deleted file mode 100644 index 48ab1edec..000000000 --- a/vagrant/puppet/modules/python/spec/unit/facter/python_version_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -require "spec_helper" - -describe Facter::Util::Fact do - before { - Facter.clear - } - - let(:python2_version_output) { <<-EOS -Python 2.7.9 -EOS - } - let(:python3_version_output) { <<-EOS -Python 3.3.0 -EOS - } - - describe "python_version" do - context 'returns Python version when `python` present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(true) - Facter::Util::Resolution.expects(:exec).with("python -V 2>&1").returns(python2_version_output) - expect(Facter.value(:python_version)).to eq("2.7.9") - end - end - - context 'returns nil when `python` not present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(false) - expect(Facter.value(:python_version)).to eq(nil) - end - end - - end - - describe "python2_version" do - context 'returns Python 2 version when `python` is present and Python 2' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(true) - Facter::Util::Resolution.expects(:exec).with("python -V 2>&1").returns(python2_version_output) - expect(Facter.value(:python2_version)).to eq('2.7.9') - end - end - - context 'returns Python 2 version when `python` is Python 3 and `python2` is present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(true) - Facter::Util::Resolution.expects(:exec).with("python -V 2>&1").returns(python3_version_output) - Facter::Util::Resolution.expects(:which).with("python2").returns(true) - Facter::Util::Resolution.expects(:exec).with("python2 -V 2>&1").returns(python2_version_output) - expect(Facter.value(:python2_version)).to eq('2.7.9') - end - end - - context 'returns nil when `python` is Python 3 and `python2` is absent' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(true) - Facter::Util::Resolution.expects(:exec).with("python -V 2>&1").returns(python3_version_output) - Facter::Util::Resolution.expects(:which).with("python2").returns(false) - expect(Facter.value(:python2_version)).to eq(nil) - end - end - - context 'returns nil when `python2` and `python` are absent' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python").returns(false) - Facter::Util::Resolution.expects(:which).with("python2").returns(false) - expect(Facter.value(:python2_version)).to eq(nil) - end - end - - end - - describe "python3_version" do - context 'returns Python 3 version when `python3` present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python3").returns(true) - Facter::Util::Resolution.expects(:exec).with("python3 -V 2>&1").returns(python3_version_output) - expect(Facter.value(:python3_version)).to eq("3.3.0") - end - end - - context 'returns nil when `python3` not present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("python3").returns(false) - expect(Facter.value(:python3_version)).to eq(nil) - end - end - - end -end diff --git a/vagrant/puppet/modules/python/spec/unit/facter/virtualenv_version_spec.rb b/vagrant/puppet/modules/python/spec/unit/facter/virtualenv_version_spec.rb deleted file mode 100644 index b9aac90e3..000000000 --- a/vagrant/puppet/modules/python/spec/unit/facter/virtualenv_version_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "spec_helper" - -describe Facter::Util::Fact do - before { - Facter.clear - } - - let(:virtualenv_version_output) { <<-EOS -12.0.7 -EOS - } - - describe "virtualenv_version" do - context 'returns virtualenv version when virtualenv present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("virtualenv").returns(true) - Facter::Util::Resolution.expects(:exec).with("virtualenv --version 2>&1").returns(virtualenv_version_output) - expect(Facter.value(:virtualenv_version)).to eq("12.0.7") - end - end - - context 'returns nil when virtualenv not present' do - it do - Facter::Util::Resolution.stubs(:exec) - Facter::Util::Resolution.expects(:which).with("virtualenv").returns(false) - expect(Facter.value(:virtualenv_version)).to eq(nil) - end - end - - end -end diff --git a/vagrant/puppet/modules/python/templates/gunicorn.erb b/vagrant/puppet/modules/python/templates/gunicorn.erb deleted file mode 100644 index 07605ade1..000000000 --- a/vagrant/puppet/modules/python/templates/gunicorn.erb +++ /dev/null @@ -1,61 +0,0 @@ -CONFIG = { -<% if @mode == 'django' -%> - 'mode': 'django', -<% else -%> - 'mode': 'wsgi', -<% end -%> -<% if @virtualenv -%> - 'environment': { -<% if @osenv -%><% @osenv.sort.each do |key, value| -%> - '<%= key %>': '<%= value %>', -<% end -%><% end -%> -<% if @environment -%> - 'ENVIRONMENT': '<%= @environment %>', -<% end -%> - 'PYTHONPATH': '<%= @virtualenv %>' - }, -<% end -%> - 'working_dir': '<%= @dir %>', - 'user': '<%= @owner %>', - 'group': '<%= @group %>', -<% if @virtualenv -%> - 'python': '<%= @virtualenv %>/bin/python', -<% else -%> - 'python': '/usr/bin/python', -<% end -%> - 'args': ( -<% if @args.any? -%> -<% for arg in @args do -%> - '<%= arg %>', -<% end -%> -<% end -%> -<% if !@virtualenv and !@bind -%> - '--bind=unix:/tmp/gunicorn-<%= @name %>.socket', -<% elsif @virtualenv and !@bind -%> - '--bind=unix:<%= @virtualenv %>/<%= @name %>.socket', -<% else -%> - '--bind=<%= @bind %>', -<% end -%> -<% if @workers -%> - '--workers=<%= @workers %>', -<% else -%> - '--workers=<%= @processorcount.to_i*2 + 1 %>', -<% end -%> - '--timeout=<%= @timeout %>', -<% if @access_log_format -%> - '--access-logformat=<%= @access_log_format %>', -<% end -%> -<% if @accesslog -%> - '--access-logfile=<%= @accesslog %>', -<% end -%> -<% if @errorlog -%> - '--error-logfile=<%= @errorlog %>', -<% end -%> -<% if @log_level %> - '--log-level=<%= @log_level %>', -<% end -%> -<% if @mode != 'django' -%> - '<%= @appmodule %>', -<% end -%> - ), -} diff --git a/vagrant/puppet/modules/python/templates/inifile.erb b/vagrant/puppet/modules/python/templates/inifile.erb deleted file mode 100644 index 47ae7138b..000000000 --- a/vagrant/puppet/modules/python/templates/inifile.erb +++ /dev/null @@ -1,8 +0,0 @@ -# this file is managed by puppet -<%- @config.sort.map do |section,conf| -%> -[<%= section -%>] -<%- conf.sort.map do |key,value| -%> -<%= key %> = <%= value %> -<%- end -%> - -<%- end -%> diff --git a/vagrant/puppet/modules/python/tests/gunicorn.pp b/vagrant/puppet/modules/python/tests/gunicorn.pp deleted file mode 100644 index d95f6d0f9..000000000 --- a/vagrant/puppet/modules/python/tests/gunicorn.pp +++ /dev/null @@ -1,20 +0,0 @@ -class { 'python': - version => 'system', - dev => true, - virtualenv => true, -} - -python::gunicorn { 'vhost': - ensure => present, - virtualenv => '/var/www/project1', - mode => 'wsgi', - dir => '/var/www/project1/current', - bind => 'unix:/tmp/gunicorn.socket', - environment => 'prod', - appmodule => 'app:app', - osenv => { - 'DBHOST' => 'dbserver.example.com' - }, - timeout => 30, - template => 'python/gunicorn.erb', -} diff --git a/vagrant/puppet/modules/python/tests/init.pp b/vagrant/puppet/modules/python/tests/init.pp deleted file mode 100644 index 4c51cc80e..000000000 --- a/vagrant/puppet/modules/python/tests/init.pp +++ /dev/null @@ -1,5 +0,0 @@ -class { 'python': - version => 'system', - dev => true, - virtualenv => true, -} diff --git a/vagrant/puppet/modules/python/tests/pip.pp b/vagrant/puppet/modules/python/tests/pip.pp deleted file mode 100644 index f0db17280..000000000 --- a/vagrant/puppet/modules/python/tests/pip.pp +++ /dev/null @@ -1,10 +0,0 @@ -class { 'python': - version => 'system', - dev => true, - virtualenv => true, -} - -python::pip { 'flask': - virtualenv => '/var/www/project1', - proxy => 'http://proxy.domain.com:3128', -} diff --git a/vagrant/puppet/modules/python/tests/pyvenv.pp b/vagrant/puppet/modules/python/tests/pyvenv.pp deleted file mode 100644 index 8cd0cbce0..000000000 --- a/vagrant/puppet/modules/python/tests/pyvenv.pp +++ /dev/null @@ -1,12 +0,0 @@ -class { 'python': - pip => false, - version => '3', -} - -python::pyvenv { '/opt/uwsgi': -} - -python::pip { 'uwsgi': - ensure => 'latest', - virtualenv => '/opt/uwsgi' -} diff --git a/vagrant/puppet/modules/python/tests/requirements.pp b/vagrant/puppet/modules/python/tests/requirements.pp deleted file mode 100644 index 90dccd8bb..000000000 --- a/vagrant/puppet/modules/python/tests/requirements.pp +++ /dev/null @@ -1,16 +0,0 @@ -class { 'python': - version => 'system', - dev => true, - virtualenv => true, -} - -python::requirements { '/var/www/project1/requirements.txt': - virtualenv => '/var/www/project1', - proxy => 'http://proxy.domain.com:3128', -} - -python::requirements { '/var/www/project1/requirements.txt': - virtualenv => 'system', - proxy => 'http://proxy.domain.com:3128', - timeout => 2400, -} diff --git a/vagrant/puppet/modules/python/tests/virtualenv.pp b/vagrant/puppet/modules/python/tests/virtualenv.pp deleted file mode 100644 index da5ab57c5..000000000 --- a/vagrant/puppet/modules/python/tests/virtualenv.pp +++ /dev/null @@ -1,13 +0,0 @@ -class { 'python': - version => 'system', - dev => true, - virtualenv => true, -} - -python::virtualenv { '/var/www/project1': - ensure => present, - version => 'system', - requirements => '/var/www/project1/requirements.txt', - proxy => 'http://proxy.domain.com:3128', - systempkgs => true, -} diff --git a/vagrant/puppet/modules/stdlib/CHANGELOG.md b/vagrant/puppet/modules/stdlib/CHANGELOG.md deleted file mode 100644 index 2bc584b0b..000000000 --- a/vagrant/puppet/modules/stdlib/CHANGELOG.md +++ /dev/null @@ -1,655 +0,0 @@ -## Supported Release 4.12.0 -###Summary - -This release provides several new functions, bugfixes, modulesync changes, and some documentation updates. - -####Features -- Adds `clamp`. This function keeps values within a specified range. -- Adds `validate_x509_rsa_key_pair`. This function validates an x509 RSA certificate and key pair. -- Adds `dig`. This function performs a deep lookup in nested hashes or arrays. -- Extends the `base64` support to fit `rfc2045` and `rfc4648`. -- Adds `is_ipv6_address` and `is_ipv4_address`. These functions validate the specified ipv4 or ipv6 addresses. -- Adds `enclose_ipv6`. This function encloses IPv6 addresses in square brackets. -- Adds `ensure_resources`. This function takes a list of resources and creates them if they do not exist. -- Extends `suffix` to support applying a suffix to keys in a hash. -- Apply modulesync changes. -- Add validate_email_address function. - -####Bugfixes -- Fixes `fqdn_rand_string` tests, since Puppet 4.4.0 and later have a higher `fqdn_rand` ceiling. -- (MODULES-3152) Adds a check to `package_provider` to prevent failures if Gem is not installed. -- Fixes to README.md. -- Fixes catch StandardError rather than the gratuitous Exception -- Fixes file_line attribute validation. -- Fixes concat with Hash arguments. - -## Supported Release 4.11.0 -###Summary - -Provides a validate_absolute_paths and Debian 8 support. There is a fix to the is_package_provider fact and a test improvement. - -####Features -- Adds new parser called is_absolute_path -- Supports Debian 8 - -####Bugfixes -- Allow package_provider fact to resolve on PE 3.x - -####Improvements -- ensures that the test passes independently of changes to rubygems for ensure_resource - -##2015-12-15 - Supported Release 4.10.0 -###Summary - -Includes the addition of several new functions and considerable improvements to the existing functions, tests and documentation. Includes some bug fixes which includes compatibility, test and fact issues. - -####Features -- Adds service_provider fact -- Adds is_a() function -- Adds package_provider fact -- Adds validate_ip_address function -- Adds seeded_rand function - -####Bugfixes -- Fix backwards compatibility from an improvement to the parseyaml function -- Renaming of load_module_metadata test to include _spec.rb -- Fix root_home fact on AIX 5.x, now '-c' rather than '-C' -- Fixed Gemfile to work with ruby 1.8.7 - -####Improvements -- (MODULES-2462) Improvement of parseyaml function -- Improvement of str2bool function -- Improvement to readme -- Improvement of intersection function -- Improvement of validate_re function -- Improved speed on Facter resolution of service_provider -- empty function now handles numeric values -- Package_provider now prevents deprecation warning about the allow_virtual parameter -- load_module_metadata now succeeds on empty file -- Check added to ensure puppetversion value is not nil -- Improvement to bool2str to return a string of choice using boolean -- Improvement to naming convention in validate_ipv4_address function - -## Supported Release 4.9.1 -###Summary - -Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. - -##2015-09-08 - Supported Release 4.9.0 -###Summary - -This release adds new features including the new functions dos2unix, unix2dos, try_get_value, convert_base as well as other features and improvements. - -####Features -- (MODULES-2370) allow `match` parameter to influence `ensure => absent` behavior -- (MODULES-2410) Add new functions dos2unix and unix2dos -- (MODULE-2456) Modify union to accept more than two arrays -- Adds a convert_base function, which can convert numbers between bases -- Add a new function "try_get_value" - -####Bugfixes -- n/a - -####Improvements -- (MODULES-2478) Support root_home fact on AIX through "lsuser" command -- Acceptance test improvements -- Unit test improvements -- Readme improvements - -## 2015-08-10 - Supported Release 4.8.0 -### Summary -This release adds a function for reading metadata.json from any module, and expands file\_line's abilities. - -#### Features -- New parameter `replace` on `file_line` -- New function `load_module_metadata()` to load metadata.json and return the content as a hash. -- Added hash support to `size()` - -#### Bugfixes -- Fix various docs typos -- Fix `file_line` resource on puppet < 3.3 - -##2015-06-22 - Supported Release 4.7.0 -###Summary - -Adds Solaris 12 support along with improved Puppet 4 support. There are significant test improvements, and some minor fixes. - -####Features -- Add support for Solaris 12 - -####Bugfixes -- Fix for AIO Puppet 4 -- Fix time for ruby 1.8.7 -- Specify rspec-puppet version -- range() fix for typeerror and missing functionality -- Fix pw_hash() on JRuby < 1.7.17 -- fqdn_rand_string: fix argument error message -- catch and rescue from looking up non-existent facts -- Use puppet_install_helper, for Puppet 4 - -####Improvements -- Enforce support for Puppet 4 testing -- fqdn_rotate/fqdn_rand_string acceptance tests and implementation -- Simplify mac address regex -- validate_integer, validate_numeric: explicitely reject hashes in arrays -- Readme edits -- Remove all the pops stuff for rspec-puppet -- Sync via modulesync -- Add validate_slength optional 3rd arg -- Move tests directory to examples directory - -##2015-04-14 - Supported Release 4.6.0 -###Summary - -Adds functions and function argument abilities, and improves compatibility with the new puppet parser - -####Features -- MODULES-444: `concat()` can now take more than two arrays -- `basename()` added to have Ruby File.basename functionality -- `delete()` can now take an array of items to remove -- `prefix()` can now take a hash -- `upcase()` can now take a hash or array of upcaseable things -- `validate_absolute_path()` can now take an array -- `validate_cmd()` can now use % in the command to embed the validation file argument in the string -- MODULES-1473: deprecate `type()` function in favor of `type3x()` -- MODULES-1473: Add `type_of()` to give better type information on future parser -- Deprecate `private()` for `assert_private()` due to future parser -- Adds `ceiling()` to take the ceiling of a number -- Adds `fqdn_rand_string()` to generate random string based on fqdn -- Adds `pw_hash()` to generate password hashes -- Adds `validate_integer()` -- Adds `validate_numeric()` (like `validate_integer()` but also accepts floats) - -####Bugfixes -- Fix seeding of `fqdn_rotate()` -- `ensure_resource()` is more verbose on debug mode -- Stricter argument checking for `dirname()` -- Fix `is_domain_name()` to better match RFC -- Fix `uriescape()` when called with array -- Fix `file_line` resource when using the `after` attribute with `match` - -##2015-01-14 - Supported Release 4.5.1 -###Summary - -This release changes the temporary facter_dot_d cache locations outside of the /tmp directory due to a possible security vunerability. CVE-2015-1029 - -####Bugfixes -- Facter_dot_d cache will now be stored in puppet libdir instead of tmp - -##2014-12-15 - Supported Release 4.5.0 -###Summary - -This release improves functionality of the member function and adds improved future parser support. - -####Features -- MODULES-1329: Update member() to allow the variable to be an array. -- Sync .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md via modulesync - -####Bugfixes -- Fix range() to work with numeric ranges with the future parser -- Accurately express SLES support in metadata.json (was missing 10SP4 and 12) -- Don't require `line` to match the `match` parameter - -##2014-11-10 - Supported Release 4.4.0 -###Summary -This release has an overhauled readme, new private manifest function, and fixes many future parser bugs. - -####Features -- All new shiny README -- New `private()` function for making private manifests (yay!) - -####Bugfixes -- Code reuse in `bool2num()` and `zip()` -- Fix many functions to handle `generate()` no longer returning a string on new puppets -- `concat()` no longer modifies the first argument (whoops) -- strict variable support for `getvar()`, `member()`, `values_at`, and `has_interface_with()` -- `to_bytes()` handles PB and EB now -- Fix `tempfile` ruby requirement for `validate_augeas()` and `validate_cmd()` -- Fix `validate_cmd()` for windows -- Correct `validate_string()` docs to reflect non-handling of `undef` -- Fix `file_line` matching on older rubies - - -##2014-07-15 - Supported Release 4.3.2 -###Summary - -This release merely updates metadata.json so the module can be uninstalled and -upgraded via the puppet module command. - -##2014-07-14 - Supported Release 4.3.1 -### Summary -This supported release updates the metadata.json to work around upgrade behavior of the PMT. - -#### Bugfixes -- Synchronize metadata.json with PMT-generated metadata to pass checksums - -##2014-06-27 - Supported Release 4.3.0 -### Summary -This release is the first supported release of the stdlib 4 series. It remains -backwards-compatible with the stdlib 3 series. It adds two new functions, one bugfix, and many testing updates. - -#### Features -- New `bool2str()` function -- New `camelcase()` function - -#### Bugfixes -- Fix `has_interface_with()` when interfaces fact is nil - -##2014-06-04 - Release 4.2.2 -### Summary - -This release adds PE3.3 support in the metadata and fixes a few tests. - -## 2014-05-08 - Release - 4.2.1 -### Summary -This release moves a stray symlink that can cause problems. - -## 2014-05-08 - Release - 4.2.0 -### Summary -This release adds many new functions and fixes, and continues to be backwards compatible with stdlib 3.x - -#### Features -- New `base64()` function -- New `deep_merge()` function -- New `delete_undef_values()` function -- New `delete_values()` function -- New `difference()` function -- New `intersection()` function -- New `is_bool()` function -- New `pick_default()` function -- New `union()` function -- New `validate_ipv4_address` function -- New `validate_ipv6_address` function -- Update `ensure_packages()` to take an option hash as a second parameter. -- Update `range()` to take an optional third argument for range step -- Update `validate_slength()` to take an optional third argument for minimum length -- Update `file_line` resource to take `after` and `multiple` attributes - -#### Bugfixes -- Correct `is_string`, `is_domain_name`, `is_array`, `is_float`, and `is_function_available` for parsing odd types such as bools and hashes. -- Allow facts.d facts to contain `=` in the value -- Fix `root_home` fact on darwin systems -- Fix `concat()` to work with a second non-array argument -- Fix `floor()` to work with integer strings -- Fix `is_integer()` to return true if passed integer strings -- Fix `is_numeric()` to return true if passed integer strings -- Fix `merge()` to work with empty strings -- Fix `pick()` to raise the correct error type -- Fix `uriescape()` to use the default URI.escape list -- Add/update unit & acceptance tests. - - -##2014-03-04 - Supported Release - 3.2.1 -###Summary -This is a supported release - -####Bugfixes -- Fixed `is_integer`/`is_float`/`is_numeric` for checking the value of arithmatic expressions. - -####Known bugs -* No known bugs - ---- - -##### 2013-05-06 - Jeff McCune - 4.1.0 - - * (#20582) Restore facter\_dot\_d to stdlib for PE users (3b887c8) - * (maint) Update Gemfile with GEM\_FACTER\_VERSION (f44d535) - -##### 2013-05-06 - Alex Cline - 4.1.0 - - * Terser method of string to array conversion courtesy of ethooz. (d38bce0) - -##### 2013-05-06 - Alex Cline 4.1.0 - - * Refactor ensure\_resource expectations (b33cc24) - -##### 2013-05-06 - Alex Cline 4.1.0 - - * Changed str-to-array conversion and removed abbreviation. (de253db) - -##### 2013-05-03 - Alex Cline 4.1.0 - - * (#20548) Allow an array of resource titles to be passed into the ensure\_resource function (e08734a) - -##### 2013-05-02 - Raphaël Pinson - 4.1.0 - - * Add a dirname function (2ba9e47) - -##### 2013-04-29 - Mark Smith-Guerrero - 4.1.0 - - * (maint) Fix a small typo in hash() description (928036a) - -##### 2013-04-12 - Jeff McCune - 4.0.2 - - * Update user information in gemspec to make the intent of the Gem clear. - -##### 2013-04-11 - Jeff McCune - 4.0.1 - - * Fix README function documentation (ab3e30c) - -##### 2013-04-11 - Jeff McCune - 4.0.0 - - * stdlib 4.0 drops support with Puppet 2.7 - * stdlib 4.0 preserves support with Puppet 3 - -##### 2013-04-11 - Jeff McCune - 4.0.0 - - * Add ability to use puppet from git via bundler (9c5805f) - -##### 2013-04-10 - Jeff McCune - 4.0.0 - - * (maint) Make stdlib usable as a Ruby GEM (e81a45e) - -##### 2013-04-10 - Erik Dalén - 4.0.0 - - * Add a count function (f28550e) - -##### 2013-03-31 - Amos Shapira - 4.0.0 - - * (#19998) Implement any2array (7a2fb80) - -##### 2013-03-29 - Steve Huff - 4.0.0 - - * (19864) num2bool match fix (8d217f0) - -##### 2013-03-20 - Erik Dalén - 4.0.0 - - * Allow comparisons of Numeric and number as String (ff5dd5d) - -##### 2013-03-26 - Richard Soderberg - 4.0.0 - - * add suffix function to accompany the prefix function (88a93ac) - -##### 2013-03-19 - Kristof Willaert - 4.0.0 - - * Add floor function implementation and unit tests (0527341) - -##### 2012-04-03 - Eric Shamow - 4.0.0 - - * (#13610) Add is\_function\_available to stdlib (961dcab) - -##### 2012-12-17 - Justin Lambert - 4.0.0 - - * str2bool should return a boolean if called with a boolean (5d5a4d4) - -##### 2012-10-23 - Uwe Stuehler - 4.0.0 - - * Fix number of arguments check in flatten() (e80207b) - -##### 2013-03-11 - Jeff McCune - 4.0.0 - - * Add contributing document (96e19d0) - -##### 2013-03-04 - Raphaël Pinson - 4.0.0 - - * Add missing documentation for validate\_augeas and validate\_cmd to README.markdown (a1510a1) - -##### 2013-02-14 - Joshua Hoblitt - 4.0.0 - - * (#19272) Add has\_element() function (95cf3fe) - -##### 2013-02-07 - Raphaël Pinson - 4.0.0 - - * validate\_cmd(): Use Puppet::Util::Execution.execute when available (69248df) - -##### 2012-12-06 - Raphaël Pinson - 4.0.0 - - * Add validate\_augeas function (3a97c23) - -##### 2012-12-06 - Raphaël Pinson - 4.0.0 - - * Add validate\_cmd function (6902cc5) - -##### 2013-01-14 - David Schmitt - 4.0.0 - - * Add geppetto project definition (b3fc0a3) - -##### 2013-01-02 - Jaka Hudoklin - 4.0.0 - - * Add getparam function to get defined resource parameters (20e0e07) - -##### 2013-01-05 - Jeff McCune - 4.0.0 - - * (maint) Add Travis CI Support (d082046) - -##### 2012-12-04 - Jeff McCune - 4.0.0 - - * Clarify that stdlib 3 supports Puppet 3 (3a6085f) - -##### 2012-11-30 - Erik Dalén - 4.0.0 - - * maint: style guideline fixes (7742e5f) - -##### 2012-11-09 - James Fryman - 4.0.0 - - * puppet-lint cleanup (88acc52) - -##### 2012-11-06 - Joe Julian - 4.0.0 - - * Add function, uriescape, to URI.escape strings. Redmine #17459 (fd52b8d) - -##### 2012-09-18 - Chad Metcalf - 3.2.0 - - * Add an ensure\_packages function. (8a8c09e) - -##### 2012-11-23 - Erik Dalén - 3.2.0 - - * (#17797) min() and max() functions (9954133) - -##### 2012-05-23 - Peter Meier - 3.2.0 - - * (#14670) autorequire a file\_line resource's path (dfcee63) - -##### 2012-11-19 - Joshua Harlan Lifton - 3.2.0 - - * Add join\_keys\_to\_values function (ee0f2b3) - -##### 2012-11-17 - Joshua Harlan Lifton - 3.2.0 - - * Extend delete function for strings and hashes (7322e4d) - -##### 2012-08-03 - Gary Larizza - 3.2.0 - - * Add the pick() function (ba6dd13) - -##### 2012-03-20 - Wil Cooley - 3.2.0 - - * (#13974) Add predicate functions for interface facts (f819417) - -##### 2012-11-06 - Joe Julian - 3.2.0 - - * Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e) - -##### 2012-10-25 - Jeff McCune - 3.1.1 - - * (maint) Fix spec failures resulting from Facter API changes (97f836f) - -##### 2012-10-23 - Matthaus Owens - 3.1.0 - - * Add PE facts to stdlib (cdf3b05) - -##### 2012-08-16 - Jeff McCune - 3.0.1 - - * Fix accidental removal of facts\_dot\_d.rb in 3.0.0 release - -##### 2012-08-16 - Jeff McCune - 3.0.0 - - * stdlib 3.0 drops support with Puppet 2.6 - * stdlib 3.0 preserves support with Puppet 2.7 - -##### 2012-08-07 - Dan Bode - 3.0.0 - - * Add function ensure\_resource and defined\_with\_params (ba789de) - -##### 2012-07-10 - Hailee Kenney - 3.0.0 - - * (#2157) Remove facter\_dot\_d for compatibility with external facts (f92574f) - -##### 2012-04-10 - Chris Price - 3.0.0 - - * (#13693) moving logic from local spec\_helper to puppetlabs\_spec\_helper (85f96df) - -##### 2012-10-25 - Jeff McCune - 2.5.1 - - * (maint) Fix spec failures resulting from Facter API changes (97f836f) - -##### 2012-10-23 - Matthaus Owens - 2.5.0 - - * Add PE facts to stdlib (cdf3b05) - -##### 2012-08-15 - Dan Bode - 2.5.0 - - * Explicitly load functions used by ensure\_resource (9fc3063) - -##### 2012-08-13 - Dan Bode - 2.5.0 - - * Add better docs about duplicate resource failures (97d327a) - -##### 2012-08-13 - Dan Bode - 2.5.0 - - * Handle undef for parameter argument (4f8b133) - -##### 2012-08-07 - Dan Bode - 2.5.0 - - * Add function ensure\_resource and defined\_with\_params (a0cb8cd) - -##### 2012-08-20 - Jeff McCune - 2.5.0 - - * Disable tests that fail on 2.6.x due to #15912 (c81496e) - -##### 2012-08-20 - Jeff McCune - 2.5.0 - - * (Maint) Fix mis-use of rvalue functions as statements (4492913) - -##### 2012-08-20 - Jeff McCune - 2.5.0 - - * Add .rspec file to repo root (88789e8) - -##### 2012-06-07 - Chris Price - 2.4.0 - - * Add support for a 'match' parameter to file\_line (a06c0d8) - -##### 2012-08-07 - Erik Dalén - 2.4.0 - - * (#15872) Add to\_bytes function (247b69c) - -##### 2012-07-19 - Jeff McCune - 2.4.0 - - * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88) - -##### 2012-07-10 - Hailee Kenney - 2.4.0 - - * (#2157) Make facts\_dot\_d compatible with external facts (5fb0ddc) - -##### 2012-03-16 - Steve Traylen - 2.4.0 - - * (#13205) Rotate array/string randomley based on fqdn, fqdn\_rotate() (fef247b) - -##### 2012-05-22 - Peter Meier - 2.3.3 - - * fix regression in #11017 properly (f0a62c7) - -##### 2012-05-10 - Jeff McCune - 2.3.3 - - * Fix spec tests using the new spec\_helper (7d34333) - -##### 2012-05-10 - Puppet Labs - 2.3.2 - - * Make file\_line default to ensure => present (1373e70) - * Memoize file\_line spec instance variables (20aacc5) - * Fix spec tests using the new spec\_helper (1ebfa5d) - * (#13595) initialize\_everything\_for\_tests couples modules Puppet ver (3222f35) - * (#13439) Fix MRI 1.9 issue with spec\_helper (15c5fd1) - * (#13439) Fix test failures with Puppet 2.6.x (665610b) - * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca) - * (#13494) Specify the behavior of zero padded strings (61891bb) - -##### 2012-03-29 Puppet Labs - 2.1.3 - -* (#11607) Add Rakefile to enable spec testing -* (#12377) Avoid infinite loop when retrying require json - -##### 2012-03-13 Puppet Labs - 2.3.1 - -* (#13091) Fix LoadError bug with puppet apply and puppet\_vardir fact - -##### 2012-03-12 Puppet Labs - 2.3.0 - -* Add a large number of new Puppet functions -* Backwards compatibility preserved with 2.2.x - -##### 2011-12-30 Puppet Labs - 2.2.1 - -* Documentation only release for the Forge - -##### 2011-12-30 Puppet Labs - 2.1.2 - -* Documentation only release for PE 2.0.x - -##### 2011-11-08 Puppet Labs - 2.2.0 - -* #10285 - Refactor json to use pson instead. -* Maint - Add watchr autotest script -* Maint - Make rspec tests work with Puppet 2.6.4 -* #9859 - Add root\_home fact and tests - -##### 2011-08-18 Puppet Labs - 2.1.1 - -* Change facts.d paths to match Facter 2.0 paths. -* /etc/facter/facts.d -* /etc/puppetlabs/facter/facts.d - -##### 2011-08-17 Puppet Labs - 2.1.0 - -* Add R.I. Pienaar's facts.d custom facter fact -* facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are - automatically loaded now. - -##### 2011-08-04 Puppet Labs - 2.0.0 - -* Rename whole\_line to file\_line -* This is an API change and as such motivating a 2.0.0 release according to semver.org. - -##### 2011-08-04 Puppet Labs - 1.1.0 - -* Rename append\_line to whole\_line -* This is an API change and as such motivating a 1.1.0 release. - -##### 2011-08-04 Puppet Labs - 1.0.0 - -* Initial stable release -* Add validate\_array and validate\_string functions -* Make merge() function work with Ruby 1.8.5 -* Add hash merging function -* Add has\_key function -* Add loadyaml() function -* Add append\_line native - -##### 2011-06-21 Jeff McCune - 0.1.7 - -* Add validate\_hash() and getvar() functions - -##### 2011-06-15 Jeff McCune - 0.1.6 - -* Add anchor resource type to provide containment for composite classes - -##### 2011-06-03 Jeff McCune - 0.1.5 - -* Add validate\_bool() function to stdlib - -##### 0.1.4 2011-05-26 Jeff McCune - -* Move most stages after main - -##### 0.1.3 2011-05-25 Jeff McCune - -* Add validate\_re() function - -##### 0.1.2 2011-05-24 Jeff McCune - -* Update to add annotated tag - -##### 0.1.1 2011-05-24 Jeff McCune - -* Add stdlib::stages class with a standard set of stages diff --git a/vagrant/puppet/modules/stdlib/CONTRIBUTING.md b/vagrant/puppet/modules/stdlib/CONTRIBUTING.md deleted file mode 100644 index bfeaa701c..000000000 --- a/vagrant/puppet/modules/stdlib/CONTRIBUTING.md +++ /dev/null @@ -1,220 +0,0 @@ -Checklist (and a short version for the impatient) -================================================= - - * Commits: - - - Make commits of logical units. - - - Check for unnecessary whitespace with "git diff --check" before - committing. - - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). - - - Do not check in commented out code or unneeded files. - - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. - - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". - - - The body should provide a meaningful commit message, which: - - - uses the imperative, present tense: "change", not "changed" or - "changes". - - - includes motivation for the change, and contrasts its - implementation with the previous behavior. - - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. - - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - - - When introducing a new feature, make sure it is properly - documented in the README.md - - * Submission: - - * Pre-requisites: - - - Make sure you have a [GitHub account](https://github.com/join) - - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. - - * Preferred method: - - - Fork the repository on GitHub. - - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). - - - Submit a pull request to the repository in the puppetlabs - organization. - -The long version -================ - - 1. Make separate commits for logically separate changes. - - Please break your commits down into logically consistent units - which include new or changed tests relevant to the rest of the - change. The goal of doing this is to make the diff easier to - read for whoever is reviewing your code. In general, the easier - your diff is to read, the more likely someone will be happy to - review it and get it into the code base. - - If you are going to refactor a piece of code, please do so as a - separate commit from your feature or bug fix changes. - - We also really appreciate changes that include tests to make - sure the bug is not re-introduced, and that the feature is not - accidentally broken. - - Describe the technical detail of the change(s). If your - description starts to get too long, that is a good sign that you - probably need to split up your commit into more finely grained - pieces. - - Commits which plainly describe the things which help - reviewers check the patch and future developers understand the - code are much more likely to be merged in with a minimum of - bike-shedding or requested changes. Ideally, the commit message - would include information, and be in a form suitable for - inclusion in the release notes for the version of Puppet that - includes them. - - Please also check that you are not introducing any trailing - whitespace or other "whitespace errors". You can do this by - running "git diff --check" on your changes before you commit. - - 2. Sending your patches - - To submit your changes via a GitHub pull request, we _highly_ - recommend that you have them on a topic branch, instead of - directly on "master". - It makes things much easier to keep track of, especially if - you decide to work on another thing before your first change - is merged in. - - GitHub has some pretty good - [general documentation](http://help.github.com/) on using - their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). - - In general, after pushing your topic branch up to your - repository on GitHub, you can switch to the branch in the - GitHub UI and click "Pull Request" towards the top of the page - in order to open a pull request. - - - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you - submitted, then you should update the ticket to include the - location of your branch, along with any other commentary you - may wish to make. - -Testing -======= - -Getting Started ---------------- - -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, -or Gems, are required to build, develop, and test this software. - -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running - -```shell -% bundle install -Fetching gem metadata from https://rubygems.org/........ -Fetching gem metadata from https://rubygems.org/.. -Using rake (10.1.0) -Using builder (3.2.2) --- 8><-- many more --><8 -- -Using rspec-system-puppet (2.2.0) -Using serverspec (0.6.3) -Using rspec-system-serverspec (1.0.0) -Using bundler (1.3.5) -Your bundle is complete! -Use `bundle show [gemname]` to see where a bundled gem is installed. -``` - -NOTE some systems may require you to run this command with sudo. - -If you already have those gems installed, make sure they are up-to-date: - -```shell -% bundle update -``` - -With all dependencies in place and up-to-date we can now run the tests: - -```shell -% bundle exec rake spec -``` - -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), -rspec tests define them in [.fixtures.yml](./fixtures.yml). - -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. - -You can run them by issuing the following command - -```shell -% bundle exec rake spec_clean -% bundle exec rspec spec/acceptance -``` - -This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) -and then run all the tests under [spec/acceptance](./spec/acceptance). - -Writing Tests -------------- - -XXX getting started writing tests. - -If you have commit access to the repository -=========================================== - -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. - -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. - - -Additional Resources -==================== - -* [Getting additional help](http://puppetlabs.com/community/get-help) - -* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) - -* [Patchwork](https://patchwork.puppetlabs.com) - -* [General GitHub documentation](http://help.github.com/) - -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - diff --git a/vagrant/puppet/modules/stdlib/Gemfile b/vagrant/puppet/modules/stdlib/Gemfile deleted file mode 100644 index e490bc9b9..000000000 --- a/vagrant/puppet/modules/stdlib/Gemfile +++ /dev/null @@ -1,39 +0,0 @@ -#This file is generated by ModuleSync, do not edit. - -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -def location_for(place, version = nil) - if place =~ /^(git[:@][^#]*)#(.*)/ - [version, { :git => $1, :branch => $2, :require => false}].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false}] - else - [place, version, { :require => false}].compact - end -end - -group :development, :unit_tests do - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'puppet_facts', :require => false - gem 'puppet-blacksmith', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '>= 2.3.2', :require => false - gem 'simplecov', :require => false -end -group :system_tests do - gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') - gem 'beaker', *location_for(ENV['BEAKER_VERSION']) - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'master_manipulator', :require => false - gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) -end - -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) - - -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end diff --git a/vagrant/puppet/modules/stdlib/LICENSE b/vagrant/puppet/modules/stdlib/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vagrant/puppet/modules/stdlib/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vagrant/puppet/modules/stdlib/NOTICE b/vagrant/puppet/modules/stdlib/NOTICE deleted file mode 100644 index 3c8c03ab6..000000000 --- a/vagrant/puppet/modules/stdlib/NOTICE +++ /dev/null @@ -1,23 +0,0 @@ -stdlib puppet module - -Copyright (C) 2011-2016 Puppet Labs, Inc. - -and some parts: - -Copyright (C) 2011 Krzysztof Wilczynski - - -Puppet Labs can be contacted at: info@puppetlabs.com - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vagrant/puppet/modules/stdlib/README.markdown b/vagrant/puppet/modules/stdlib/README.markdown deleted file mode 100644 index ba1f5f8ba..000000000 --- a/vagrant/puppet/modules/stdlib/README.markdown +++ /dev/null @@ -1,1400 +0,0 @@ -#stdlib - -####Table of Contents - -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with stdlib](#setup) -4. [Usage - Configuration options and additional functionality](#usage) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) - -##Overview - -Adds a standard library of resources for Puppet modules. - -##Module Description - -This module provides a standard library of resources for the development of Puppet modules. Puppet modules make heavy use of this standard library. The stdlib module adds the following resources to Puppet: - - * Stages - * Facts - * Functions - * Defined resource types - * Types - * Providers - -> *Note:* As of version 3.7, Puppet Enterprise no longer includes the stdlib module. If you're running Puppet Enterprise, you should install the most recent release of stdlib for compatibility with Puppet modules. - -##Setup - -Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet. - -##Usage - -After you've installed stdlib, all of its functions, facts, and resources are available for module use or development. - -If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest. - -* `stdlib`: Most of stdlib's features are automatically loaded by Puppet. To use standardized run stages in Puppet, declare this class in your manifest with `include stdlib`. - - When declared, stdlib declares all other classes in the module. The only other class currently included in the module is `stdlib::stages`. - -The `stdlib::stages` class declares various run stages for deploying infrastructure, language runtimes, and application layers. The high level stages are (in order): - - * setup - * main - * runtime - * setup_infra - * deploy_infra - * setup_app - * deploy_app - * deploy - - Sample usage: - - ~~~ - node default { - include stdlib - class { java: stage => 'runtime' } - } - ~~~ - -## Reference - -### Classes - -#### Public Classes - - The stdlib class has no parameters. - -#### Private Classes - -* `stdlib::stages`: Manages a standard set of run stages for Puppet. It is managed by the stdlib class and should not be declared independently. - -### Types - -#### `file_line` - -Ensures that a given line is contained within a file. The implementation matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet appends the line to the end of the file to ensure the desired state. Multiple resources can be declared to manage multiple lines in the same file. - -Example: - - file_line { 'sudo_rule': - path => '/etc/sudoers', - line => '%sudo ALL=(ALL) ALL', - } - - file_line { 'sudo_rule_nopw': - path => '/etc/sudoers', - line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', - } - -In this example, Puppet ensures that both of the specified lines are contained in the file `/etc/sudoers`. - -Match Example: - - file_line { 'bashrc_proxy': - ensure => present, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - } - -In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line. - -Match Example With `ensure => absent`: - - file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - match_for_absence => true, - } - -In this code example, `match` looks for a line beginning with export -followed by HTTP_PROXY and delete it. If multiple lines match, an -error will be raised unless the `multiple => true` parameter is set. - -**Autorequires:** If Puppet is managing the file that contains the line being managed, the `file_line` resource autorequires that file. - -##### Parameters - -All parameters are optional, unless otherwise noted. - -* `after`: Specifies the line after which Puppet adds any new lines. (Existing lines are added in place.) Valid options: String. Default: Undefined. -* `ensure`: Ensures whether the resource is present. Valid options: 'present', 'absent'. Default: 'present'. -* `line`: **Required.** Sets the line to be added to the file located by the `path` parameter. Valid options: String. Default: Undefined. -* `match`: Specifies a regular expression to run against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value, and if it does not match, an exception is raised. Valid options: String containing a regex. Default: Undefined. -* `match_for_absence`: An optional value to determine if match should be applied when `ensure => absent`. If set to true and match is set, the line that matches match will be deleted. If set to false (the default), match is ignored when `ensure => absent` and the value of `line` is used instead. Default: false. -* `multiple`: Determines if `match` and/or `after` can change multiple lines. If set to false, an exception will be raised if more than one line matches. Valid options: 'true', 'false'. Default: Undefined. -* `name`: Sets the name to use as the identity of the resource. This is necessary if you want the resource namevar to differ from the supplied `title` of the resource. Valid options: String. Default: Undefined. -* `path`: **Required.** Defines the file in which Puppet will ensure the line specified by `line`. Must be an absolute path to the file. -* `replace`: Defines whether the resource will overwrite an existing line that matches the `match` parameter. If set to false and a line is found matching the `match` param, the line will not be placed in the file. Valid options: true, false, yes, no. Default: true - -### Functions - -#### `abs` - -Returns the absolute value of a number; for example, '-34.56' becomes '34.56'. Takes a single integer and float value as an argument. *Type*: rvalue. - -#### `any2array` - -Converts any object to an array containing that object. Empty argument lists are converted to an empty array. Arrays are left untouched. Hashes are converted to arrays of alternating keys and values. *Type*: rvalue. - -#### `base64` - -Converts a string to and from base64 encoding. Requires an `action` ('encode', 'decode') and either a plain or base64-encoded `string`, and an optional `method` ('default', 'strict', 'urlsafe') - -For backward compatibility, `method` will be set as `default` if not specified. - -*Examples:* -~~~ -base64('encode', 'hello') -base64('encode', 'hello', 'default') -# return: "aGVsbG8=\n" - -base64('encode', 'hello', 'strict') -# return: "aGVsbG8=" - -base64('decode', 'aGVsbG8=') -base64('decode', 'aGVsbG8=\n') -base64('decode', 'aGVsbG8=', 'default') -base64('decode', 'aGVsbG8=\n', 'default') -base64('decode', 'aGVsbG8=', 'strict') -# return: "hello" - -base64('encode', 'https://puppetlabs.com', 'urlsafe') -# return: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==" - -base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe') -# return: "https://puppetlabs.com" -~~~ - -*Type*: rvalue. - -#### `basename` - -Returns the `basename` of a path (optionally stripping an extension). For example: - * ('/path/to/a/file.ext') returns 'file.ext' - * ('relative/path/file.ext') returns 'file.ext' - * ('/path/to/a/file.ext', '.ext') returns 'file' - -*Type*: rvalue. - -#### `bool2num` - -Converts a boolean to a number. Converts values: - * 'false', 'f', '0', 'n', and 'no' to 0. - * 'true', 't', '1', 'y', and 'yes' to 1. - Requires a single boolean or string as an input. *Type*: rvalue. - -#### `bool2str` - -Converts a boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false are converted to respectively. If only one argument is given, it is converted from a boolean to a string containing 'true' or 'false'. - -*Examples:* -~~~ -bool2str(true) => 'true' -bool2str(true, 'yes', 'no') => 'yes' -bool2str(false, 't', 'f') => 'f' -~~~ - -Requires a single boolean as input. *Type*: rvalue. - -#### `capitalize` - -Capitalizes the first character of a string or array of strings and lowercases the remaining characters of each string. Requires either a single string or an array as an input. *Type*: rvalue. - -#### `ceiling` - -Returns the smallest integer greater than or equal to the argument. Takes a single numeric value as an argument. *Type*: rvalue. - -#### `chomp` - -Removes the record separator from the end of a string or an array of strings; for example, 'hello\n' becomes 'hello'. Requires a single string or array as an input. *Type*: rvalue. - -#### `chop` - -Returns a new string with the last character removed. If the string ends with '\r\n', both characters are removed. Applying `chop` to an empty string returns an empty string. If you want to merely remove record separators, then you should use the `chomp` function. Requires a string or an array of strings as input. *Type*: rvalue. - -#### `clamp` - -Keeps value within the range [Min, X, Max] by sort based on integer value (order of params doesn't matter). Takes strings, arrays or numerics. Strings are converted and compared numerically. Arrays of values are flattened into a list for further handling. For example: - * `clamp('24', [575, 187])` returns 187. - * `clamp(16, 88, 661)` returns 88. - * `clamp([4, 3, '99'])` returns 4. - *Type*: rvalue. - -#### `concat` - -Appends the contents of multiple arrays onto the first array given. For example: - * `concat(['1','2','3'],'4')` returns ['1','2','3','4']. - * `concat(['1','2','3'],'4',['5','6','7'])` returns ['1','2','3','4','5','6','7']. - *Type*: rvalue. - -#### `convert_base` - -Converts a given integer or base 10 string representing an integer to a specified base, as a string. For example: - * `convert_base(5, 2)` results in: '101' - * `convert_base('254', '16')` results in: 'fe' - -#### `count` - -If called with only an array, it counts the number of elements that are **not** nil/undef. If called with a second argument, counts the number of elements in an array that matches the second argument. *Type*: rvalue. - -#### `defined_with_params` - -Takes a resource reference and an optional hash of attributes. Returns 'true' if a resource with the specified attributes has already been added to the catalog. Returns 'false' otherwise. - - ~~~ - user { 'dan': - ensure => present, - } - - if ! defined_with_params(User[dan], {'ensure' => 'present' }) { - user { 'dan': ensure => present, } - } - ~~~ - -*Type*: rvalue. - -#### `delete` - -Deletes all instances of a given element from an array, substring from a string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}. *Type*: rvalue. - -#### `delete_at` - -Deletes a determined indexed value from an array. For example, `delete_at(['a','b','c'], 1)` returns ['a','c']. *Type*: rvalue. - -#### `delete_values` - -Deletes all instances of a given value from a hash. For example, `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')` returns {'a'=>'A','c'=>'C','B'=>'D'} *Type*: rvalue. - -#### `delete_undef_values` - -Deletes all instances of the undef value from an array or hash. For example, `$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})` returns {a => 'A', b => '', d => false}. *Type*: rvalue. - -#### `difference` - -Returns the difference between two arrays. The returned array is a copy of the original array, removing any items that also appear in the second array. For example, `difference(["a","b","c"],["b","c","d"])` returns ["a"]. *Type*: rvalue. - -#### `dig` - -*Type*: rvalue. - -Retrieves a value within multiple layers of hashes and arrays via an array of keys containing a path. The function goes through the structure by each path component and tries to return the value at the end of the path. - -In addition to the required path argument, the function accepts the default argument. It is returned if the path is not correct, if no value was found, or if any other error has occurred. - -~~~ruby -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = dig($data, ['a', 'b', 2]) -# $value = 'b3' - -# with all possible options -$value = dig($data, ['a', 'b', 2], 'not_found') -# $value = 'b3' - -# using the default value -$value = dig($data, ['a', 'b', 'c', 'd'], 'not_found') -# $value = 'not_found' -~~~ - -1. **$data** The data structure we are working with. -2. **['a', 'b', 2]** The path array. -3. **'not_found'** The default value. It will be returned if nothing is found. - (optional, defaults to *undef*) - -#### `dirname` - -Returns the `dirname` of a path. For example, `dirname('/path/to/a/file.ext')` returns '/path/to/a'. *Type*: rvalue. - -#### `dos2unix` - -Returns the Unix version of the given string. Very useful when using a File resource with a cross-platform template. *Type*: rvalue. - -~~~ -file{$config_file: - ensure => file, - content => dos2unix(template('my_module/settings.conf.erb')), -} -~~~ - -See also [unix2dos](#unix2dos). - -#### `downcase` - -Converts the case of a string or of all strings in an array to lowercase. *Type*: rvalue. - -#### `empty` - -Returns true if the argument is an array or hash that contains no elements, or an empty string. Returns false when the argument is a numerical value. *Type*: rvalue. - -#### `enclose_ipv6` - -Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. *Type*: rvalue. - -#### `ensure_packages` - -Takes a list of packages array/hash and only installs them if they don't already exist. It optionally takes a hash as a second parameter to be passed as the third argument to the `ensure_resource()` or `ensure_resources()` function. *Type*: statement. - -For Array: - - ensure_packages(['ksh','openssl'], {'ensure' => 'present'}) - -For Hash: - - ensure_packages({'ksh' => { enure => '20120801-1' } , 'mypackage' => { source => '/tmp/myrpm-1.0.0.x86_64.rpm', provider => "rpm" }}, {'ensure' => 'present'}) - -#### `ensure_resource` - -Takes a resource type, title, and a hash of attributes that describe the resource(s). - -~~~ -user { 'dan': - ensure => present, -} -~~~ - -This example only creates the resource if it does not already exist: - - `ensure_resource('user', 'dan', {'ensure' => 'present' })` - -If the resource already exists, but does not match the specified parameters, this function attempts to recreate the resource, leading to a duplicate resource definition error. - -An array of resources can also be passed in, and each will be created with the type and parameters specified if it doesn't already exist. - - `ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})` - -*Type*: statement. - -#### `ensure_resources` - -Takes a resource type, title (only hash), and a hash of attributes that describe the resource(s). - -~~~ -user { 'dan': - gid => 'mygroup', - ensure => present, -} - -ensure_resources($user) -~~~ - -An hash of resources should be passed in and each will be created with the type and parameters specified if it doesn't already exist: - - ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } , 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) - -From Hiera Backend: - -~~~ -userlist: -dan: - gid: 'mygroup' -uid: '600' -alex: -gid: 'mygroup' - -ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) -~~~ - -### `flatten` - -Flattens deeply nested arrays and returns a single flat array as a result. For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c']. *Type*: rvalue. - -#### `floor` - -Takes a single numeric value as an argument, and returns the largest integer less than or equal to the argument. *Type*: rvalue. - -#### `fqdn_rand_string` - -Generates a random alphanumeric string using an optionally-specified character set (default is alphanumeric), combining the `$fqdn` fact and an optional seed for repeatable randomness. - -*Usage:* -~~~ -fqdn_rand_string(LENGTH, [CHARSET], [SEED]) -~~~ -*Examples:* -~~~ -fqdn_rand_string(10) -fqdn_rand_string(10, 'ABCDEF!@#$%^') -fqdn_rand_string(10, '', 'custom seed') -~~~ - -*Type*: rvalue. - -#### `fqdn_rotate` - -Rotates an array or string a random number of times, combining the `$fqdn` fact and an optional seed for repeatable randomness. - -*Usage:* - -~~~ -fqdn_rotate(VALUE, [SEED]) -~~~ - -*Examples:* - -~~~ -fqdn_rotate(['a', 'b', 'c', 'd']) -fqdn_rotate('abcd') -fqdn_rotate([1, 2, 3], 'custom seed') -~~~ - -*Type*: rvalue. - -#### `get_module_path` - -Returns the absolute path of the specified module for the current environment. - - `$module_path = get_module_path('stdlib')` - -*Type*: rvalue. - -#### `getparam` - -Takes a resource reference and the name of the parameter, and returns the value of the resource's parameter. - -For example, the following returns 'param_value': - - ~~~ - define example_resource($param) { - } - - example_resource { "example_resource_instance": - param => "param_value" - } - - getparam(Example_resource["example_resource_instance"], "param") - ~~~ - -*Type*: rvalue. - -#### `getvar` - -Looks up a variable in a remote namespace. - -For example: - - ~~~ - $foo = getvar('site::data::foo') - # Equivalent to $foo = $site::data::foo - ~~~ - -This is useful if the namespace itself is stored in a string: - - ~~~ - $datalocation = 'site::data' - $bar = getvar("${datalocation}::bar") - # Equivalent to $bar = $site::data::bar - ~~~ - -*Type*: rvalue. - -#### `grep` - -Searches through an array and returns any elements that match the provided regular expression. For example, `grep(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['aaa','aaaddd']. *Type*: rvalue. - -#### `has_interface_with` - -Returns a boolean based on kind and value: - * macaddress - * netmask - * ipaddress - * network - -*Examples:* - - ~~~ - has_interface_with("macaddress", "x:x:x:x:x:x") - has_interface_with("ipaddress", "127.0.0.1") => true - ~~~ - -If no kind is given, then the presence of the interface is checked: - - ~~~ - has_interface_with("lo") => true - ~~~ - -*Type*: rvalue. - -#### `has_ip_address` - -Returns 'true' if the client has the requested IP address on some interface. This function iterates through the `interfaces` fact and checks the `ipaddress_IFACE` facts, performing a simple string comparison. *Type*: rvalue. - -#### `has_ip_network` - -Returns 'true' if the client has an IP address within the requested network. This function iterates through the `interfaces` fact and checks the `network_IFACE` facts, performing a simple string comparision. *Type*: rvalue. - -#### `has_key` - -Determines if a hash has a certain key value. - -*Example*: - - ~~~ - $my_hash = {'key_one' => 'value_one'} - if has_key($my_hash, 'key_two') { - notice('we will not reach here') - } - if has_key($my_hash, 'key_one') { - notice('this will be printed') - } - ~~~ - -*Type*: rvalue. - -#### `hash` - -Converts an array into a hash. For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. *Type*: rvalue. - -#### `intersection` - -Returns an array an intersection of two. For example, `intersection(["a","b","c"],["b","c","d"])` returns ["b","c"]. *Type*: rvalue. - -#### `is_a` - -Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. This function is available only in Puppet 4 or in Puppet 3 with the "future" parser. - - ~~~ - foo = 3 - $bar = [1,2,3] - $baz = 'A string!' - - if $foo.is_a(Integer) { - notify { 'foo!': } - } - if $bar.is_a(Array) { - notify { 'bar!': } - } - if $baz.is_a(String) { - notify { 'baz!': } - } - ~~~ - -See the [the Puppet type system](https://docs.puppetlabs.com/references/latest/type.html#about-resource-types) for more information about types. -See the [`assert_type()`](https://docs.puppetlabs.com/references/latest/function.html#asserttype) function for flexible ways to assert the type of a value. - -#### `is_absolute_path` - -Returns 'true' if the given path is absolute. *Type*: rvalue. - -#### `is_array` - -Returns 'true' if the variable passed to this function is an array. *Type*: rvalue. - -#### `is_bool` - -Returns 'true' if the variable passed to this function is a boolean. *Type*: rvalue. - -#### `is_domain_name` - -Returns 'true' if the string passed to this function is a syntactically correct domain name. *Type*: rvalue. - -#### `is_float` - -Returns 'true' if the variable passed to this function is a float. *Type*: rvalue. - -#### `is_function_available` - -Accepts a string as an argument and determines whether the Puppet runtime has access to a function by that name. It returns 'true' if the function exists, 'false' if not. *Type*: rvalue. - -#### `is_hash` - -Returns 'true' if the variable passed to this function is a hash. *Type*: rvalue. - -#### `is_integer` - -Returns 'true' if the variable returned to this string is an integer. *Type*: rvalue. - -#### `is_ip_address` - -Returns 'true' if the string passed to this function is a valid IP address. *Type*: rvalue. - -#### `is_ipv6_address` - -Returns 'true' if the string passed to this function is a valid IPv6 address. *Type*: rvalue. - -#### `is_ipv4_address` - -Returns 'true' if the string passed to this function is a valid IPv4 address. *Type*: rvalue. - -#### `is_mac_address` - -Returns 'true' if the string passed to this function is a valid MAC address. *Type*: rvalue. - -#### `is_numeric` - -Returns 'true' if the variable passed to this function is a number. *Type*: rvalue. - -#### `is_string` - -Returns 'true' if the variable passed to this function is a string. *Type*: rvalue. - -#### `join` - -Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c". *Type*: rvalue. - -#### `join_keys_to_values` - -Joins each key of a hash to that key's corresponding value with a separator. Keys and values are cast to strings. The return value is an array in which each element is one joined key/value pair. For example, `join_keys_to_values({'a'=>1,'b'=>2}, " is ")` results in ["a is 1","b is 2"]. *Type*: rvalue. - -#### `keys` - -Returns the keys of a hash as an array. *Type*: rvalue. - -#### `loadyaml` - -Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type. For example: - - ~~~ - $myhash = loadyaml('/etc/puppet/data/myhash.yaml') - ~~~ - -*Type*: rvalue. - -#### `load_module_metadata` - -Loads the metadata.json of a target module. Can be used to determine module version and authorship for dynamic support of modules. - - ~~~ - $metadata = load_module_metadata('archive') - notify { $metadata['author']: } - ~~~ - -If you do not want to fail the catalog compilation when a module's metadata file is absent: - - ~~~ - $metadata = load_module_metadata('mysql', true) - if empty($metadata) { - notify { "This module does not have a metadata.json file.": } - } - ~~~ - -*Type*: rvalue. - -#### `lstrip` - -Strips spaces to the left of a string. *Type*: rvalue. - -#### `max` - -Returns the highest value of all arguments. Requires at least one argument. *Type*: rvalue. - -#### `member` - -This function determines if a variable is a member of an array. The variable can be either a string, array, or fixnum. For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` return 'true', while `member(['a','b'], 'c')` and `member(['a','b','c'], ['c','d'])` return 'false'. *Note*: This function does not support nested arrays. If the first argument contains nested arrays, it will not recurse through them. - -*Type*: rvalue. - -#### `merge` - -Merges two or more hashes together and returns the resulting hash. - -*Example*: - - ~~~ - $hash1 = {'one' => 1, 'two' => 2} - $hash2 = {'two' => 'dos', 'three' => 'tres'} - $merged_hash = merge($hash1, $hash2) - # The resulting hash is equivalent to: - # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} - ~~~ - -When there is a duplicate key, the key in the rightmost hash "wins." *Type*: rvalue. - -#### `min` - -Returns the lowest value of all arguments. Requires at least one argument. *Type*: rvalue. - -#### `num2bool` - -Converts a number or a string representation of a number into a true boolean. Zero or anything non-numeric becomes 'false'. Numbers greater than 0 become 'true'. *Type*: rvalue. - -#### `parsejson` - -Converts a string of JSON into the correct Puppet structure. *Type*: rvalue. The optional second argument is returned if the data was not correct. - -#### `parseyaml` - -Converts a string of YAML into the correct Puppet structure. *Type*: rvalue. The optional second argument is returned if the data was not correct. - -#### `pick` - -From a list of values, returns the first value that is not undefined or an empty string. Takes any number of arguments, and raises an error if all values are undefined or empty. - - ~~~ - $real_jenkins_version = pick($::jenkins_version, '1.449') - ~~~ - -*Type*: rvalue. - -#### `pick_default` - -Returns the first value in a list of values. Contrary to the `pick()` function, the `pick_default()` does not fail if all arguments are empty. This allows it to use an empty value as default. *Type*: rvalue. - -#### `prefix` - -Applies a prefix to all elements in an array, or to the keys in a hash. -For example: -* `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc'] -* `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'pa'=>'b','pb'=>'c','pc'=>'d'}. - -*Type*: rvalue. - -#### `assert_private` - -Sets the current class or definition as private. Calling the class or definition from outside the current module will fail. - -For example, `assert_private()` called in class `foo::bar` outputs the following message if class is called from outside module `foo`: - - ~~~ - Class foo::bar is private - ~~~ - - To specify the error message you want to use: - - ~~~ - assert_private("You're not supposed to do that!") - ~~~ - -*Type*: statement. - -#### `pw_hash` - -Hashes a password using the crypt function. Provides a hash usable on most POSIX systems. - -The first argument to this function is the password to hash. If it is undef or an empty string, this function returns undef. - -The second argument to this function is which type of hash to use. It will be converted into the appropriate crypt(3) hash specifier. Valid hash types are: - -|Hash type |Specifier| -|---------------------|---------| -|MD5 |1 | -|SHA-256 |5 | -|SHA-512 (recommended)|6 | - -The third argument to this function is the salt to use. - -*Type*: rvalue. - -**Note:** this uses the Puppet master's implementation of crypt(3). If your environment contains several different operating systems, ensure that they are compatible before using this function. - -#### `range` - -Extrapolates a range as an array when given in the form of '(start, stop)'. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9]. - -Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"]. - -Passing a third argument will cause the generated range to step by that interval, e.g. `range("0", "9", "2")` returns ["0","2","4","6","8"]. - -*Type*: rvalue. - -#### `reject` - -Searches through an array and rejects all elements that match the provided regular expression. For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc']. *Type*: rvalue. - -#### `reverse` - -Reverses the order of a string or array. *Type*: rvalue. - -#### `rstrip` - -Strips spaces to the right of the string. *Type*: rvalue. - -#### `seeded_rand` - -Takes an integer max value and a string seed value and returns a repeatable random integer smaller than max. Like `fqdn_rand`, but does not add node specific data to the seed. *Type*: rvalue. - -#### `shuffle` - -Randomizes the order of a string or array elements. *Type*: rvalue. - -#### `size` - -Returns the number of elements in a string, an array or a hash. *Type*: rvalue. - -#### `sort` - -Sorts strings and arrays lexically. *Type*: rvalue. - -#### `squeeze` - -Returns a new string where runs of the same character that occur in this set are replaced by a single character. *Type*: rvalue. - -#### `str2bool` - -Converts certain strings to a boolean. This attempts to convert strings that contain the values '1', 't', 'y', or 'yes' to true. Strings that contain values '0', 'f', 'n', or 'no', or that are an empty string or undefined are converted to false. Any other value causes an error. *Type*: rvalue. - -#### `str2saltedsha512` - -Converts a string to a salted-SHA512 password hash, used for OS X versions >= 10.7. Given any string, this function returns a hex version of a salted-SHA512 password hash, which can be inserted into your Puppet -manifests as a valid password attribute. *Type*: rvalue. - -#### `strftime` - -Returns formatted time. For example, `strftime("%s")` returns the time since Unix epoch, and `strftime("%Y-%m-%d")` returns the date. *Type*: rvalue. - - *Format:* - - * `%a`: The abbreviated weekday name ('Sun') - * `%A`: The full weekday name ('Sunday') - * `%b`: The abbreviated month name ('Jan') - * `%B`: The full month name ('January') - * `%c`: The preferred local date and time representation - * `%C`: Century (20 in 2009) - * `%d`: Day of the month (01..31) - * `%D`: Date (%m/%d/%y) - * `%e`: Day of the month, blank-padded ( 1..31) - * `%F`: Equivalent to %Y-%m-%d (the ISO 8601 date format) - * `%h`: Equivalent to %b - * `%H`: Hour of the day, 24-hour clock (00..23) - * `%I`: Hour of the day, 12-hour clock (01..12) - * `%j`: Day of the year (001..366) - * `%k`: Hour, 24-hour clock, blank-padded ( 0..23) - * `%l`: Hour, 12-hour clock, blank-padded ( 0..12) - * `%L`: Millisecond of the second (000..999) - * `%m`: Month of the year (01..12) - * `%M`: Minute of the hour (00..59) - * `%n`: Newline (\n) - * `%N`: Fractional seconds digits, default is 9 digits (nanosecond) - * `%3N`: Millisecond (3 digits) - * `%6N`: Microsecond (6 digits) - * `%9N`: Nanosecond (9 digits) - * `%p`: Meridian indicator ('AM' or 'PM') - * `%P`: Meridian indicator ('am' or 'pm') - * `%r`: Time, 12-hour (same as %I:%M:%S %p) - * `%R`: Time, 24-hour (%H:%M) - * `%s`: Number of seconds since the Unix epoch, 1970-01-01 00:00:00 UTC. - * `%S`: Second of the minute (00..60) - * `%t`: Tab character ( ) - * `%T`: Time, 24-hour (%H:%M:%S) - * `%u`: Day of the week as a decimal, Monday being 1. (1..7) - * `%U`: Week number of the current year, starting with the first Sunday as the first day of the first week (00..53) - * `%v`: VMS date (%e-%b-%Y) - * `%V`: Week number of year according to ISO 8601 (01..53) - * `%W`: Week number of the current year, starting with the first Monday as the first day of the first week (00..53) - * `%w`: Day of the week (Sunday is 0, 0..6) - * `%x`: Preferred representation for the date alone, no time - * `%X`: Preferred representation for the time alone, no date - * `%y`: Year without a century (00..99) - * `%Y`: Year with century - * `%z`: Time zone as hour offset from UTC (e.g. +0900) - * `%Z`: Time zone name - * `%%`: Literal '%' character - -#### `strip` - -Removes leading and trailing whitespace from a string or from every string inside an array. For example, `strip(" aaa ")` results in "aaa". *Type*: rvalue. - -#### `suffix` - -Applies a suffix to all elements in an array, or to the keys in a hash. -For example: -* `suffix(['a','b','c'], 'p')` returns ['ap','bp','cp'] -* `suffix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'ap'=>'b','bp'=>'c','cp'=>'d'}. - -*Type*: rvalue. - -#### `swapcase` - -Swaps the existing case of a string. For example, `swapcase("aBcD")` results in "AbCd". *Type*: rvalue. - -#### `time` - -Returns the current Unix epoch time as an integer. For example, `time()` returns something like '1311972653'. *Type*: rvalue. - -#### `to_bytes` - -Converts the argument into bytes, for example "4 kB" becomes "4096". Takes a single string value as an argument. *Type*: rvalue. - -#### `try_get_value` - -*Type*: rvalue. - -DEPRECATED: replaced by `dig()`. - -Retrieves a value within multiple layers of hashes and arrays via a string containing a path. The path is a string of hash keys or array indexes starting with zero, separated by the path separator character (default "/"). The function goes through the structure by each path component and tries to return the value at the end of the path. - -In addition to the required path argument, the function accepts the default argument. It is returned if the path is not correct, if no value was found, or if any other error has occurred. The last argument can set the path separator character. - -~~~ruby -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = try_get_value($data, 'a/b/2') -# $value = 'b3' - -# with all possible options -$value = try_get_value($data, 'a/b/2', 'not_found', '/') -# $value = 'b3' - -# using the default value -$value = try_get_value($data, 'a/b/c/d', 'not_found') -# $value = 'not_found' - -# using custom separator -$value = try_get_value($data, 'a|b', [], '|') -# $value = ['b1','b2','b3'] -~~~ - -1. **$data** The data structure we are working with. -2. **'a/b/2'** The path string. -3. **'not_found'** The default value. It will be returned if nothing is found. - (optional, defaults to *undef*) -4. **'/'** The path separator character. - (optional, defaults to *'/'*) - -#### `type3x` - -Returns a string description of the type when passed a value. Type can be a string, array, hash, float, integer, or boolean. This function will be removed when Puppet 3 support is dropped and the new type system can be used. *Type*: rvalue. - -#### `type_of` - -Returns the literal type when passed a value. Requires the new parser. Useful for comparison of types with `<=` such as in `if type_of($some_value) <= Array[String] { ... }` (which is equivalent to `if $some_value =~ Array[String] { ... }`) *Type*: rvalue. - -#### `union` - -Returns a union of two or more arrays, without duplicates. For example, `union(["a","b","c"],["b","c","d"])` returns ["a","b","c","d"]. *Type*: rvalue. - -#### `unique` - -Removes duplicates from strings and arrays. For example, `unique("aabbcc")` returns 'abc', and `unique(["a","a","b","b","c","c"])` returns ["a","b","c"]. *Type*: rvalue. - -#### `unix2dos` - -Returns the DOS version of the given string. Very useful when using a File resource with a cross-platform template. *Type*: rvalue. - -~~~ -file{$config_file: - ensure => file, - content => unix2dos(template('my_module/settings.conf.erb')), -} -~~~ - -See also [dos2unix](#dos2unix). - -#### `upcase` - -Converts an object, array or hash of objects that respond to upcase to uppercase. For example, `upcase('abcd')` returns 'ABCD'. *Type*: rvalue. - -#### `uriescape` - -URLEncodes a string or array of strings. Requires either a single string or an array as an input. *Type*: rvalue. - -#### `validate_absolute_path` - -Validates that a given string represents an absolute path in the filesystem. Works for Windows and Unix style paths. - -The following values pass: - -~~~ -$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' -validate_absolute_path($my_path) -$my_path2 = '/var/lib/puppet' -validate_absolute_path($my_path2) -$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] -validate_absolute_path($my_path3) -$my_path4 = ['/var/lib/puppet','/usr/share/puppet'] -validate_absolute_path($my_path4) -~~~ - -The following values fail, causing compilation to abort: - -~~~ -validate_absolute_path(true) -validate_absolute_path('../var/lib/puppet') -validate_absolute_path('var/lib/puppet') -validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) -validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) -$undefined = undef -validate_absolute_path($undefined) -~~~ - -*Type*: statement. - -#### `validate_array` - -Validates that all passed values are array data structures. Aborts catalog compilation if any value fails this check. - -The following values pass: - -~~~ -$my_array = [ 'one', 'two' ] -validate_array($my_array) -~~~ - -The following values fail, causing compilation to abort: - -~~~ -validate_array(true) -validate_array('some_string') -$undefined = undef -validate_array($undefined) -~~~ - -*Type*: statement. - -#### `validate_augeas` - -Performs validation of a string using an Augeas lens. The first argument of this function should be the string to test, and the second argument should be the name of the Augeas lens to use. If Augeas fails to parse the string with the lens, the compilation aborts with a parse error. - -A third optional argument lists paths which should **not** be found in the file. The `$file` variable points to the location of the temporary file being tested in the Augeas tree. - -For example, to make sure your $passwdcontent never contains user `foo`: - -~~~ -validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) -~~~ - -To ensure that no users use the '/bin/barsh' shell: - -~~~ -validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] -~~~ - -You can pass a fourth argument as the error message raised and shown to the user: - -~~~ -validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') -~~~ - -*Type*: statement. - -#### `validate_bool` - -Validates that all passed values are either true or false. Aborts catalog compilation if any value fails this check. - -The following values will pass: - -~~~ -$iamtrue = true -validate_bool(true) -validate_bool(true, true, false, $iamtrue) -~~~ - -The following values will fail, causing compilation to abort: - -~~~ -$some_array = [ true ] -validate_bool("false") -validate_bool("true") -validate_bool($some_array) -~~~ - -*Type*: statement. - -#### `validate_cmd` - -Performs validation of a string with an external command. The first argument of this function should be a string to test, and the second argument should be a path to a test command taking a % as a placeholder for the file path (will default to the end of the command if no % placeholder given). If the command is launched against a tempfile containing the passed string, or returns a non-null value, compilation will abort with a parse error. - -If a third argument is specified, this will be the error message raised and seen by the user. - -~~~ -# Defaults to end of path -validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') -~~~ -~~~ -# % as file location -validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') -~~~ - -*Type*: statement. - -#### `validate_hash` - -Validates that all passed values are hash data structures. Aborts catalog compilation if any value fails this check. - - The following values will pass: - - ~~~ - $my_hash = { 'one' => 'two' } - validate_hash($my_hash) - ~~~ - - The following values will fail, causing compilation to abort: - - ~~~ - validate_hash(true) - validate_hash('some_string') - $undefined = undef - validate_hash($undefined) - ~~~ - -*Type*: statement. - -#### `validate_integer` - -Validates that the first argument is an integer (or an array of integers). Aborts catalog compilation if any of the checks fail. - - The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. - If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check - if (all elements of) the first argument are greater or equal to the given minimum. - - It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer. - - The following values will pass: - - ~~~ - validate_integer(1) - validate_integer(1, 2) - validate_integer(1, 1) - validate_integer(1, 2, 0) - validate_integer(2, 2, 2) - validate_integer(2, '', 0) - validate_integer(2, undef, 0) - $foo = undef - validate_integer(2, $foo, 0) - validate_integer([1,2,3,4,5], 6) - validate_integer([1,2,3,4,5], 6, 0) - ~~~ - - * Plus all of the above, but any combination of values passed as strings ('1' or "1"). - * Plus all of the above, but with (correct) combinations of negative integer values. - - The following values will fail, causing compilation to abort: - - ~~~ - validate_integer(true) - validate_integer(false) - validate_integer(7.0) - validate_integer({ 1 => 2 }) - $foo = undef - validate_integer($foo) - validate_integer($foobaridontexist) - - validate_integer(1, 0) - validate_integer(1, true) - validate_integer(1, '') - validate_integer(1, undef) - validate_integer(1, , 0) - validate_integer(1, 2, 3) - validate_integer(1, 3, 2) - validate_integer(1, 3, true) - ~~~ - - * Plus all of the above, but any combination of values passed as strings ('false' or "false"). - * Plus all of the above, but with incorrect combinations of negative integer values. - * Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. - - *Type*: statement. - -#### `validate_ip_address` - -Validates that the argument is an IP address, regardless of it is an IPv4 or an IPv6 -address. It also validates IP address with netmask. The argument must be given as a string. - -The following values will pass: - - ~~~ - validate_ip_address('0.0.0.0') - validate_ip_address('8.8.8.8') - validate_ip_address('127.0.0.1') - validate_ip_address('194.232.104.150') - validate_ip_address('3ffe:0505:0002::') - validate_ip_address('::1/64') - validate_ip_address('fe80::a00:27ff:fe94:44d6/64') - validate_ip_address('8.8.8.8/32') - ~~~ - -The following values will fail, causing compilation to abort: - - ~~~ - validate_ip_address(1) - validate_ip_address(true) - validate_ip_address(0.0.0.256) - validate_ip_address('::1', {}) - validate_ip_address('0.0.0.0.0') - validate_ip_address('3.3.3') - validate_ip_address('23.43.9.22/64') - validate_ip_address('260.2.32.43') - ~~~ - - -#### `validate_numeric` - -Validates that the first argument is a numeric value (or an array of numeric values). Aborts catalog compilation if any of the checks fail. - - The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. - If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check - if (all elements of) the first argument are greater or equal to the given minimum. - - It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric. - - For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. - -*Type*: statement. - -#### `validate_re` - -Performs simple validation of a string against one or more regular expressions. The first argument of this function should be the string to -test, and the second argument should be a stringified regular expression (without the // delimiters) or an array of regular expressions. If none of the regular expressions match the string passed in, compilation aborts with a parse error. - - You can pass a third argument as the error message raised and shown to the user. - - The following strings validate against the regular expressions: - - ~~~ - validate_re('one', '^one$') - validate_re('one', [ '^one', '^two' ]) - ~~~ - - The following string fails to validate, causing compilation to abort: - - ~~~ - validate_re('one', [ '^two', '^three' ]) - ~~~ - - To set the error message: - - ~~~ - validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') - ~~~ - - Note: Compilation terminates if the first argument is not a string. Always use quotes to force stringification: - - ~~~ - validate_re("${::operatingsystemmajrelease}", '^[57]$') - ~~~ - -*Type*: statement. - -#### `validate_slength` - -Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if the second argument is not convertable to a number. Optionally, a minimum string length can be given as the third argument. - - The following values pass: - - ~~~ - validate_slength("discombobulate",17) - validate_slength(["discombobulate","moo"],17) - validate_slength(["discombobulate","moo"],17,3) - ~~~ - - The following values fail: - - ~~~ - validate_slength("discombobulate",1) - validate_slength(["discombobulate","thermometer"],5) - validate_slength(["discombobulate","moo"],17,10) - ~~~ - -*Type*: statement. - -#### `validate_string` - -Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check. - -The following values pass: - - ~~~ - $my_string = "one two" - validate_string($my_string, 'three') - ~~~ - - The following values fail, causing compilation to abort: - - ~~~ - validate_string(true) - validate_string([ 'some', 'array' ]) - ~~~ - -*Note:* validate_string(undef) will not fail in this version of the functions API (incl. current and future parser). - -Instead, use: - - ~~~ - if $var == undef { - fail('...') - } - ~~~ - -*Type*: statement. - -#### `validate_x509_rsa_key_pair` - -Validates a PEM-formatted X.509 certificate and private key using OpenSSL. -Verifies that the certficate's signature was created from the supplied key. - -Fails catalog compilation if any value fails this check. - -Takes two arguments, the first argument must be a X.509 certificate and the -second must be an RSA private key: - - ~~~ - validate_x509_rsa_key_pair($cert, $key) - ~~~ - -*Type*: statement. - -#### `values` - -Returns the values of a given hash. For example, given `$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)` returns [1,2,3]. - -*Type*: rvalue. - -#### `values_at` - -Finds values inside an array based on location. The first argument is the array you want to analyze, and the second argument can be a combination of: - - * A single numeric index - * A range in the form of 'start-stop' (eg. 4-9) - * An array combining the above - - For example, `values_at(['a','b','c'], 2)` returns ['c']; `values_at(['a','b','c'], ["0-1"])` returns ['a','b']; and `values_at(['a','b','c','d','e'], [0, "2-3"])` returns ['a','c','d']. - -*Type*: rvalue. - -#### `zip` - -Takes one element from first array given and merges corresponding elements from second array given. This generates a sequence of n-element arrays, where *n* is one more than the count of arguments. For example, `zip(['1','2','3'],['4','5','6'])` results in ["1", "4"], ["2", "5"], ["3", "6"]. *Type*: rvalue. - -## Limitations - -As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules. - -###Version Compatibility - -Versions | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x | -:---------------|:-----:|:---:|:---:|:----: -**stdlib 2.x** | **yes** | **yes** | no | no -**stdlib 3.x** | no | **yes** | **yes** | no -**stdlib 4.x** | no | **yes** | **yes** | no -**stdlib 4.6+** | no | **yes** | **yes** | **yes** -**stdlib 5.x** | no | no | **yes** | **yes** - -**stdlib 5.x**: When released, stdlib 5.x will drop support for Puppet 2.7.x. Please see [this discussion](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414). - -## Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html). - -To report or research a bug with any part of this module, please go to -[http://tickets.puppetlabs.com/browse/PUP](http://tickets.puppetlabs.com/browse/PUP). - -## Contributors - -The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors). diff --git a/vagrant/puppet/modules/stdlib/README_DEVELOPER.markdown b/vagrant/puppet/modules/stdlib/README_DEVELOPER.markdown deleted file mode 100644 index 04349ed79..000000000 --- a/vagrant/puppet/modules/stdlib/README_DEVELOPER.markdown +++ /dev/null @@ -1,35 +0,0 @@ -Puppet Specific Facts -===================== - -Facter is meant to stand alone and apart from Puppet. However, Facter often -runs inside Puppet and all custom facts included in the stdlib module will -almost always be evaluated in the context of Puppet and Facter working -together. - -Still, we don't want to write custom facts that blow up in the users face if -Puppet is not loaded in memory. This is often the case if the user runs -`facter` without also supplying the `--puppet` flag. - -Ah! But Jeff, the custom fact won't be in the `$LOAD_PATH` unless the user -supplies `--facter`! You might say... - -Not (always) true I say! If the user happens to have a CWD of -`/stdlib/lib` then the facts will automatically be evaluated and -blow up. - -In any event, it's pretty easy to write a fact that has no value if Puppet is -not loaded. Simply do it like this: - - Facter.add(:node_vardir) do - setcode do - # This will be nil if Puppet is not available. - Facter::Util::PuppetSettings.with_puppet do - Puppet[:vardir] - end - end - end - -The `Facter::Util::PuppetSettings.with_puppet` method accepts a block and -yields to it only if the Puppet library is loaded. If the Puppet library is -not loaded, then the method silently returns `nil` which Facter interprets as -an undefined fact value. The net effect is that the fact won't be set. diff --git a/vagrant/puppet/modules/stdlib/README_SPECS.markdown b/vagrant/puppet/modules/stdlib/README_SPECS.markdown deleted file mode 100644 index 917b6310d..000000000 --- a/vagrant/puppet/modules/stdlib/README_SPECS.markdown +++ /dev/null @@ -1,7 +0,0 @@ -NOTE -==== - -This project's specs depend on puppet core, and thus they require the -`puppetlabs_spec_helper` project. For more information please see the README -in that project, which can be found here: [puppetlabs spec -helper](https://github.com/puppetlabs/puppetlabs_spec_helper) diff --git a/vagrant/puppet/modules/stdlib/RELEASE_PROCESS.markdown b/vagrant/puppet/modules/stdlib/RELEASE_PROCESS.markdown deleted file mode 100644 index 0f9328ed0..000000000 --- a/vagrant/puppet/modules/stdlib/RELEASE_PROCESS.markdown +++ /dev/null @@ -1,24 +0,0 @@ -# Contributing to this module # - - * Work in a topic branch - * Submit a github pull request - * Address any comments / feeback - * Merge into master using --no-ff - -# Releasing this module # - - * This module adheres to http://semver.org/ - * Look for API breaking changes using git diff vX.Y.Z..master - * If no API breaking changes, the minor version may be bumped. - * If there are API breaking changes, the major version must be bumped. - * If there are only small minor changes, the patch version may be bumped. - * Update the CHANGELOG - * Update the Modulefile - * Commit these changes with a message along the lines of "Update CHANGELOG and - Modulefile for release" - * Create an annotated tag with git tag -a vX.Y.Z -m 'version X.Y.Z' (NOTE the - leading v as per semver.org) - * Push the tag with git push origin --tags - * Build a new package with puppet-module or the rake build task if it exists - * Publish the new package to the forge - * Bonus points for an announcement to puppet-users. diff --git a/vagrant/puppet/modules/stdlib/Rakefile b/vagrant/puppet/modules/stdlib/Rakefile deleted file mode 100644 index 7e9a13d5d..000000000 --- a/vagrant/puppet/modules/stdlib/Rakefile +++ /dev/null @@ -1,42 +0,0 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppetlabs_spec_helper/rake_tasks' - -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end - - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end - - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) - end - puts nodeset -end diff --git a/vagrant/puppet/modules/stdlib/checksums.json b/vagrant/puppet/modules/stdlib/checksums.json deleted file mode 100644 index 3d2f24033..000000000 --- a/vagrant/puppet/modules/stdlib/checksums.json +++ /dev/null @@ -1,413 +0,0 @@ -{ - "CHANGELOG.md": "62822f2fe9d7362a4b99156d01c846c4", - "CONTRIBUTING.md": "ad65d271f183b5adb9fdd58207939f5f", - "Gemfile": "a5493d10f1c1fec87972b13a9fe1afcf", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "NOTICE": "b2e552587e5969886fdd60481e8b0351", - "README.markdown": "9ff8d7869c0139409311df63f3bb0361", - "README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165", - "README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1", - "RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9", - "Rakefile": "ab91824042ec3fd085a41cab7e0e90d4", - "examples/file_line.pp": "48f7f162127beffea8f8e3e58db2355a", - "examples/has_interface_with.pp": "d69d520cf3ff4d0b495480afaca359ef", - "examples/has_ip_address.pp": "32f42575e49aa66f0f2398a70ae2a9f4", - "examples/has_ip_network.pp": "bfb8db068c58d77c4dd7ae9697536537", - "examples/init.pp": "b52fd907330ddbd9c3e070cf39f7b317", - "lib/facter/facter_dot_d.rb": "d71e93183a680ac78bc0389fd50470a0", - "lib/facter/package_provider.rb": "539766a71dfb2f65e94a7c91bf413fcf", - "lib/facter/pe_version.rb": "60d47406026c8201e51394227ddf780d", - "lib/facter/puppet_vardir.rb": "c7ddc97e8a84ded3dd93baa5b9b3283d", - "lib/facter/root_home.rb": "35702ae0c7410ec4d2101113e2f697fa", - "lib/facter/service_provider.rb": "66cc42526eae631e306b397391f1f01c", - "lib/facter/util/puppet_settings.rb": "9f1d2593d0ae56bfca89d4b9266aeee1", - "lib/puppet/functions/is_a.rb": "9dad7f8c9b75348cd97aca986ac0b29a", - "lib/puppet/functions/type_of.rb": "71e19f89e167c45ec691ea6c7d319625", - "lib/puppet/parser/functions/abs.rb": "32161bd0435fdfc2aec2fc559d2b454b", - "lib/puppet/parser/functions/any2array.rb": "a81e71d6b67a551d38770ba9a1948a75", - "lib/puppet/parser/functions/assert_private.rb": "1365284f9e474ecec24cfe43ee8e7cf4", - "lib/puppet/parser/functions/base64.rb": "ac8d0565df2931470447effa502c9ad3", - "lib/puppet/parser/functions/basename.rb": "c61952b3f68fd86408c84fca2c3febb1", - "lib/puppet/parser/functions/bool2num.rb": "f953f5fc094c2ae3908a72d8840ba291", - "lib/puppet/parser/functions/bool2str.rb": "6334ac6d24a8aa49a2243fb425f47311", - "lib/puppet/parser/functions/camelcase.rb": "71c67b71eac4b7f46a0dd22cb915d2e6", - "lib/puppet/parser/functions/capitalize.rb": "da131748a9d32da9eb0b6438e39377eb", - "lib/puppet/parser/functions/ceiling.rb": "dfa9b1c75ce89344026b3b5aed2d190f", - "lib/puppet/parser/functions/chomp.rb": "2b7dc42f9967edd34cfa0ba9a97229ca", - "lib/puppet/parser/functions/chop.rb": "0ec76f54afd94201f35785dfeb2092b5", - "lib/puppet/parser/functions/clamp.rb": "d19b8dfc573ed2eff7e3536ae1e5d596", - "lib/puppet/parser/functions/concat.rb": "a1b0233e58f1f8095a74fe9300c74a9b", - "lib/puppet/parser/functions/convert_base.rb": "c3b3e59a49318af98dcb88aed7156629", - "lib/puppet/parser/functions/count.rb": "9eb74eccd93e2b3c87fd5ea14e329eba", - "lib/puppet/parser/functions/deep_merge.rb": "d83696855578fb81b64b9e92b9c7cc7c", - "lib/puppet/parser/functions/defined_with_params.rb": "ffab4433d03f32b551f2ea024a2948fc", - "lib/puppet/parser/functions/delete.rb": "cec92c5de6d748c8dc93ca7d25ac1c68", - "lib/puppet/parser/functions/delete_at.rb": "6bc24b79390d463d8be95396c963381a", - "lib/puppet/parser/functions/delete_undef_values.rb": "b32d4a3925753b2eb2c318cbd7f14404", - "lib/puppet/parser/functions/delete_values.rb": "39b147f7d369bb5f809044b6341954a2", - "lib/puppet/parser/functions/difference.rb": "e31b95fbaf974cf853a510177368bfb9", - "lib/puppet/parser/functions/dig.rb": "54a993e69c2673d999876cb3349984b7", - "lib/puppet/parser/functions/dirname.rb": "8a5579f9a9a13fd737ba65eccf8e6d5a", - "lib/puppet/parser/functions/dos2unix.rb": "be8359a5106a7832be4180e8207dd586", - "lib/puppet/parser/functions/downcase.rb": "73121616d73339cf8dd10e0de61a6c50", - "lib/puppet/parser/functions/empty.rb": "b4ad0c3c00cbc56f745fbc05af1efa00", - "lib/puppet/parser/functions/enclose_ipv6.rb": "581bc163291824909d1700909db96512", - "lib/puppet/parser/functions/ensure_packages.rb": "81a8edbd7b6f85fc90e458568184c356", - "lib/puppet/parser/functions/ensure_resource.rb": "de703fe63392b939fc2b4392975263de", - "lib/puppet/parser/functions/ensure_resources.rb": "e9543e167972dd6a9a88aa5e02a9b4a5", - "lib/puppet/parser/functions/flatten.rb": "25777b76f9719162a8bab640e5595b7a", - "lib/puppet/parser/functions/floor.rb": "42cad4c689231a51526c55a6f0985d1f", - "lib/puppet/parser/functions/fqdn_rand_string.rb": "9ac5f18e563094aee62ef7586267025d", - "lib/puppet/parser/functions/fqdn_rotate.rb": "770d510a2e50d19b2dd42b6edef3fb1f", - "lib/puppet/parser/functions/get_module_path.rb": "d4bf50da25c0b98d26b75354fa1bcc45", - "lib/puppet/parser/functions/getparam.rb": "4dd7a0e35f4a3780dcfc9b19b4e0006e", - "lib/puppet/parser/functions/getvar.rb": "344f1ce85dcb7512d37e8702ccbabb66", - "lib/puppet/parser/functions/grep.rb": "5682995af458b05f3b53dd794c4bf896", - "lib/puppet/parser/functions/has_interface_with.rb": "e135f09dbecc038c3aa9ae03127617ef", - "lib/puppet/parser/functions/has_ip_address.rb": "ee207f47906455a5aa49c4fb219dd325", - "lib/puppet/parser/functions/has_ip_network.rb": "b4d726c8b2a0afac81ced8a3a28aa731", - "lib/puppet/parser/functions/has_key.rb": "7cd9728c38f0b0065f832dabd62b0e7e", - "lib/puppet/parser/functions/hash.rb": "784f8d2d114eb4c9414ebd8a6868f82f", - "lib/puppet/parser/functions/intersection.rb": "c8f4f8b861c9c297c87b08bdbfb94caa", - "lib/puppet/parser/functions/is_absolute_path.rb": "94ea1869c438d23f7f659c87ced8080a", - "lib/puppet/parser/functions/is_array.rb": "875ca4356cb0d7a10606fb146b4a3d11", - "lib/puppet/parser/functions/is_bool.rb": "e693b7c4b5366cff1380b6e0c7dd7b11", - "lib/puppet/parser/functions/is_domain_name.rb": "6ca1f2708add756a6803b29d593d5830", - "lib/puppet/parser/functions/is_email_address.rb": "82573a431edf5a0bf9847393af27566a", - "lib/puppet/parser/functions/is_float.rb": "10e0d3ecf75fac15e415aee79acf70dc", - "lib/puppet/parser/functions/is_function_available.rb": "628428bbcd9313ce09783d9484330e09", - "lib/puppet/parser/functions/is_hash.rb": "8c7d9a05084dab0389d1b779c8a05b1a", - "lib/puppet/parser/functions/is_integer.rb": "c665be82686aa4729959bb42c66a7510", - "lib/puppet/parser/functions/is_ip_address.rb": "a714a736c1560e8739aaacd9030cca00", - "lib/puppet/parser/functions/is_ipv4_address.rb": "3df98fc55d9d59e0706ff83f607bb2a8", - "lib/puppet/parser/functions/is_ipv6_address.rb": "16e88af742f8ac93f1e8bb562eebc593", - "lib/puppet/parser/functions/is_mac_address.rb": "6dd3c96437d49e68630869b0b464e7f2", - "lib/puppet/parser/functions/is_numeric.rb": "93ddc9d4c0834a5e5e0562d7b3cdce91", - "lib/puppet/parser/functions/is_string.rb": "2bd9a652bbb2668323eee6c57729ff64", - "lib/puppet/parser/functions/join.rb": "a285a05c015ae278608f6454aef211ea", - "lib/puppet/parser/functions/join_keys_to_values.rb": "f29da49531228f6ca5b3aa0df00a14c2", - "lib/puppet/parser/functions/keys.rb": "eb6ac815ea14fbf423580ed903ef7bad", - "lib/puppet/parser/functions/load_module_metadata.rb": "805c5476a6e7083d133e167129885924", - "lib/puppet/parser/functions/loadyaml.rb": "6da5dc9256c9e7a6549bb15c72cb9f9d", - "lib/puppet/parser/functions/lstrip.rb": "20a9b1fa077c16f34e0ef5448b895698", - "lib/puppet/parser/functions/max.rb": "f652fd0b46ef7d2fbdb42b141f8fdd1d", - "lib/puppet/parser/functions/member.rb": "2b5d7fb8f87f1c7d195933c57ca32e91", - "lib/puppet/parser/functions/merge.rb": "f3dcc5c83440cdda2036cce69b61a14b", - "lib/puppet/parser/functions/min.rb": "0d2a1b7e735ab251c5469e735fa3f4c6", - "lib/puppet/parser/functions/num2bool.rb": "605c12fa518c87ed2c66ae153e0686ce", - "lib/puppet/parser/functions/parsejson.rb": "15165fd3807d9f3d657697fa854d643d", - "lib/puppet/parser/functions/parseyaml.rb": "db54578d9d798ced75952217cf11b737", - "lib/puppet/parser/functions/pick.rb": "bf01f13bbfe2318e7f6a302ac7c4433f", - "lib/puppet/parser/functions/pick_default.rb": "ad3ea60262de408767786d37a54d45dc", - "lib/puppet/parser/functions/prefix.rb": "e377fd64bd63dde6c9660aa75aca4942", - "lib/puppet/parser/functions/private.rb": "1500a21d5cf19961c5b1d476df892d92", - "lib/puppet/parser/functions/pw_hash.rb": "d82221f667050026cd6d155432a31802", - "lib/puppet/parser/functions/range.rb": "76f693d1dd50ffee409e58ff6d9a58bb", - "lib/puppet/parser/functions/reject.rb": "689f6a7c961a55fe9dcd240921f4c7f9", - "lib/puppet/parser/functions/reverse.rb": "b234b54b8cd62b2d67ccd70489ffdccf", - "lib/puppet/parser/functions/rstrip.rb": "b4e4ada41f7c1d2fcad073ce6344980f", - "lib/puppet/parser/functions/seeded_rand.rb": "2ad22e7613d894ae779c0c5b0e65dade", - "lib/puppet/parser/functions/shuffle.rb": "d50f72b0aeb921e64d2482f62488e2f3", - "lib/puppet/parser/functions/size.rb": "ab3b5b8cf2369d76969a7cb2564e018f", - "lib/puppet/parser/functions/sort.rb": "504b033b438461ca4f9764feeb017833", - "lib/puppet/parser/functions/squeeze.rb": "541f85b4203b55c9931d3d6ecd5c75f8", - "lib/puppet/parser/functions/str2bool.rb": "e380cfbc3395404ac8232ff960b22bca", - "lib/puppet/parser/functions/str2saltedsha512.rb": "49afad7b386be38ce53deaefef326e85", - "lib/puppet/parser/functions/strftime.rb": "e02e01a598ca5d7d6eee0ba22440304a", - "lib/puppet/parser/functions/strip.rb": "85d70ab95492e3e4ca5f0b5ec3f284a9", - "lib/puppet/parser/functions/suffix.rb": "082519722ed6f237dd3a9a7e316ab2e4", - "lib/puppet/parser/functions/swapcase.rb": "b17a9f3cb0271451d309e4b4f52dd651", - "lib/puppet/parser/functions/time.rb": "8cb0b8320c60b4a21725634154a9f1db", - "lib/puppet/parser/functions/to_bytes.rb": "65437027687b6172173b3a211a799e37", - "lib/puppet/parser/functions/try_get_value.rb": "09cd079ec5f0e5e2ac862c9ebe0f54fe", - "lib/puppet/parser/functions/type.rb": "4709f7ab8a8aad62d77a3c5d91a3aa08", - "lib/puppet/parser/functions/type3x.rb": "f9bf4de8341afb0c677c26b40ec8a2b2", - "lib/puppet/parser/functions/union.rb": "3cf57ea53f2522f586264feb67293cd6", - "lib/puppet/parser/functions/unique.rb": "c1bb4a8aeebd09ba3e4c8bc3702cfd60", - "lib/puppet/parser/functions/unix2dos.rb": "b1f5087fcaca69d9395094204cce887a", - "lib/puppet/parser/functions/upcase.rb": "8decededec9eb33e58f961eb86f0888f", - "lib/puppet/parser/functions/uriescape.rb": "d912ba09ba3f58c70988e662e05ffbe8", - "lib/puppet/parser/functions/validate_absolute_path.rb": "51c81d562fcc6c2df49ce5cfefd721ff", - "lib/puppet/parser/functions/validate_array.rb": "72b29289b8af1cfc3662ef9be78911b8", - "lib/puppet/parser/functions/validate_augeas.rb": "61e828e7759ba3e1e563e1fdd68aa80f", - "lib/puppet/parser/functions/validate_bool.rb": "a712634a000024398b3c6cd4ecc46463", - "lib/puppet/parser/functions/validate_cmd.rb": "7df12370db442eddddcf4dd7a5364b5e", - "lib/puppet/parser/functions/validate_email_address.rb": "e74fe9695ae0219d95f1595978267e48", - "lib/puppet/parser/functions/validate_hash.rb": "e9cfaca68751524efe16ecf2f958a9a0", - "lib/puppet/parser/functions/validate_integer.rb": "438c7fdd25f7f6a208ac48c9b75a390f", - "lib/puppet/parser/functions/validate_ip_address.rb": "8d1f23b4fb623e9ce2a6bfa59c6c1266", - "lib/puppet/parser/functions/validate_ipv4_address.rb": "ea5a7e87f51fc5a961cdc7369b3c9d00", - "lib/puppet/parser/functions/validate_ipv6_address.rb": "4699238e4cad60e7e1428905523eaeb7", - "lib/puppet/parser/functions/validate_numeric.rb": "60b0c6d5b8b170ea77498a8580bd3158", - "lib/puppet/parser/functions/validate_re.rb": "53613813ba02914f2692f0edd7e12fab", - "lib/puppet/parser/functions/validate_slength.rb": "5f0db124caae4866f474a60c589ba632", - "lib/puppet/parser/functions/validate_string.rb": "cf6a20877a27b1073d63fdd522af50bb", - "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "f17427dfc42128dc1df0ab04f37942e5", - "lib/puppet/parser/functions/values.rb": "066a6e4170e5034edb9a80463dff2bb5", - "lib/puppet/parser/functions/values_at.rb": "325a899e0201e8df5bd483fec6f12d76", - "lib/puppet/parser/functions/zip.rb": "a89d5e802bc1e63e52020c2ddbaaca2c", - "lib/puppet/provider/file_line/ruby.rb": "0b7ed2917e70902b5c40362370edcbb0", - "lib/puppet/type/anchor.rb": "bbd36bb49c3b554f8602d8d3df366c0c", - "lib/puppet/type/file_line.rb": "21214f23b82b909dba6d7a57dd6464b6", - "manifests/init.pp": "9560a09f657d7eebbfdb920cefcc1d4f", - "manifests/stages.pp": "72eb4fa624474faf23b39e57cf1590bd", - "metadata.json": "cab692227f5bbcc300d1512b4c8600dd", - "spec/acceptance/abs_spec.rb": "538db8d037db814b455a6d741e91bb8d", - "spec/acceptance/anchor_spec.rb": "3a366ecab2fda6c20acd70eeb57c5080", - "spec/acceptance/any2array_spec.rb": "de86ead0205acbb3eca3a8a4792bdac8", - "spec/acceptance/base64_spec.rb": "1684d5dd176dd5bbd4c3c6b1e64fbcea", - "spec/acceptance/bool2num_spec.rb": "bf53ceac40d0a67551c618b11809f3f8", - "spec/acceptance/build_csv.rb": "f28ef587de764ade1513091c4906412c", - "spec/acceptance/capitalize_spec.rb": "e77ea2c37144a75a67969c0d0839adfd", - "spec/acceptance/ceiling_spec.rb": "b2718dc74a39399e342ef96fe0d00fdc", - "spec/acceptance/chomp_spec.rb": "fb0862a6b7eeb3c290e280788e705061", - "spec/acceptance/chop_spec.rb": "4e7ab2d3a441b88b667a0d8ea5b174c1", - "spec/acceptance/clamp_spec.rb": "7513fd2a6701206b4673f40728eae835", - "spec/acceptance/concat_spec.rb": "73ce39ffec7184d8ed5f0b5656ed9557", - "spec/acceptance/count_spec.rb": "d82cfcad2461b16872455d6347a8b114", - "spec/acceptance/deep_merge_spec.rb": "c335a947f1666e185e0210e661f1c78a", - "spec/acceptance/defined_with_params_spec.rb": "f27c54ade9872c63c69316f62b03c119", - "spec/acceptance/delete_at_spec.rb": "9c028b703ee0286565c9877757678f3f", - "spec/acceptance/delete_spec.rb": "31e6dfcb9cc7c16b20d47c00e6a85a1d", - "spec/acceptance/delete_undef_values_spec.rb": "6e6a66aee0c383c843b5f92ef8c8410c", - "spec/acceptance/delete_values_spec.rb": "22c9b4914d4cbc0153aa3862cb4fb50e", - "spec/acceptance/difference_spec.rb": "289f4f1788feaacb304ffd54971c7e7e", - "spec/acceptance/dirname_spec.rb": "84db53878c4400a6c684c924cff05cfc", - "spec/acceptance/downcase_spec.rb": "0f094849b94a94df491ee01186473104", - "spec/acceptance/empty_spec.rb": "e5094267eb1eae007addc5e76b6d43d1", - "spec/acceptance/ensure_resource_spec.rb": "c0193d79f1db1985d313bedb93a4c7ae", - "spec/acceptance/flatten_spec.rb": "83fb08cc168a105c1d5d0df66b1d9e84", - "spec/acceptance/floor_spec.rb": "d7267b2914b1da6406224abb7489ca86", - "spec/acceptance/fqdn_rand_string_spec.rb": "45982bd0062e3ffe2dbdd5ef0359d869", - "spec/acceptance/fqdn_rotate_spec.rb": "b00226e2ae28acf4ffea8a96b6e64f01", - "spec/acceptance/get_module_path_spec.rb": "2658cdcd1abd4b7d20f53c4aced3c72a", - "spec/acceptance/getparam_spec.rb": "4d32dc5a0ee34d045242c36d77a3b482", - "spec/acceptance/getvar_spec.rb": "ba2f081a88be97c0e7004a6296294f23", - "spec/acceptance/grep_spec.rb": "98818b8b0557b80d6ff519f70ea7617c", - "spec/acceptance/has_interface_with_spec.rb": "30e27096050c43b7efdb5e6c0d54f53b", - "spec/acceptance/has_ip_address_spec.rb": "2812117ec4b88556039e8488d53c0cb0", - "spec/acceptance/has_ip_network_spec.rb": "ca75b43ff1256ead9052f2db7620db99", - "spec/acceptance/has_key_spec.rb": "6509a26a0886f7d591eaa926b2f92407", - "spec/acceptance/hash_spec.rb": "1c626457ba056bdd3936e28aa5bf503e", - "spec/acceptance/intersection_spec.rb": "40f586af7f95408a5d4a2882a4aa98f1", - "spec/acceptance/is_a_spec.rb": "03e612e76d9004ec625d9e30bb17af04", - "spec/acceptance/is_array_spec.rb": "c2ff70ce59b90b50a5aed67abaa5399d", - "spec/acceptance/is_bool_spec.rb": "c001fdecff6b0a3c9dc78774987a0b15", - "spec/acceptance/is_domain_name_spec.rb": "63e84285c26d8717fd5d4dda01e3f432", - "spec/acceptance/is_float_spec.rb": "2f0164b4d732166aa46055a2cf7b4ea9", - "spec/acceptance/is_function_available_spec.rb": "7745eba89f8719c9ca7ebf04d5b005f7", - "spec/acceptance/is_hash_spec.rb": "cff723cd8fddac45033af5dc8406d4e4", - "spec/acceptance/is_integer_spec.rb": "c09201d17d3914bba197872897fa3413", - "spec/acceptance/is_ip_address_spec.rb": "aa14cf9abf404c3fe1e761ea957871fe", - "spec/acceptance/is_ipv4_address_spec.rb": "b787114912487987801bc68d7cb15142", - "spec/acceptance/is_ipv6_address_spec.rb": "c99785448a72f9a2cfa7cd52a392b5e7", - "spec/acceptance/is_mac_address_spec.rb": "30ff4c6a63be58daa3568305617ca2a7", - "spec/acceptance/is_numeric_spec.rb": "fb9829c7a1a8d4a58836df6ff4c3386d", - "spec/acceptance/is_string_spec.rb": "df3022de123b72f0022728eb2d8ce857", - "spec/acceptance/join_keys_to_values_spec.rb": "8aa128bbaeea65aab8d92badee3ca2b5", - "spec/acceptance/join_spec.rb": "c6378ed481265152bba9871fc5501ee6", - "spec/acceptance/keys_spec.rb": "20486e3ebee53e50dc9de3b78b9d6ae6", - "spec/acceptance/loadyaml_spec.rb": "bd440cb6779026bd07d83f1aceb2781b", - "spec/acceptance/lstrip_spec.rb": "e29ab4039b65660ec2bd76a298adcae0", - "spec/acceptance/max_spec.rb": "209cda4b83d677743afb1a8870330618", - "spec/acceptance/member_spec.rb": "d6088a4fa6321791a3067d9b9cf8914a", - "spec/acceptance/merge_spec.rb": "5f168188fa0d6b31ba5b3dac49fb609c", - "spec/acceptance/min_spec.rb": "152a7db28434a0d0378561d4f64cddcc", - "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151", - "spec/acceptance/nodesets/centos-6-vcloud.yml": "bdf9ce9d3b0f0b4995666ae9d64d878d", - "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b", - "spec/acceptance/nodesets/centos-64-x64.yml": "092dd2c588a9f87fa1fb12997c0723ef", - "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af", - "spec/acceptance/nodesets/default.yml": "3e5c36e6aa5a690229e720f4048bb8af", - "spec/acceptance/nodesets/fedora-18-x64.yml": "80e41b1ee16ea489f53164bfdae58855", - "spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66", - "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297", - "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269", - "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0", - "spec/acceptance/nodesets/windows-2003-i386.yml": "b518fc01fab99ee6a9afccec5bc0c1c4", - "spec/acceptance/nodesets/windows-2003-x86_64.yml": "5c783eaa8ea4734edc836e89e923dfa1", - "spec/acceptance/nodesets/windows-2008-x86_64.yml": "3082234eafcfaf7a9579d9ebdb8bc409", - "spec/acceptance/nodesets/windows-2008r2-x86_64.yml": "dfeff32a4cc3fffa872c8281d990a840", - "spec/acceptance/nodesets/windows-2012-x86_64.yml": "8bed73362ee1f43d21ea1903a729f955", - "spec/acceptance/nodesets/windows-2012r2-x86_64.yml": "3f4f6112d24db02989b8ab79d3a1256f", - "spec/acceptance/num2bool_spec.rb": "e4a00b913b08c68a689837e9f9336cb2", - "spec/acceptance/parsejson_spec.rb": "5753b9dd66e4fd464c132b39487b922c", - "spec/acceptance/parseyaml_spec.rb": "991f6f7b729812535155643c11846bcb", - "spec/acceptance/pick_default_spec.rb": "1bc2562380ef6f6cded5ec90a03922be", - "spec/acceptance/pick_spec.rb": "272c54c8f9398f499768331bdb4276ee", - "spec/acceptance/prefix_spec.rb": "da620568c6771e7d492ec1ff697c531c", - "spec/acceptance/pw_hash_spec.rb": "721fe0da04d798a353799fd651bcd0fc", - "spec/acceptance/range_spec.rb": "65e5b98ceca257658604d988fbec7d03", - "spec/acceptance/reject_spec.rb": "b5185f1a6071c9bdc7aca92e6f899c3e", - "spec/acceptance/reverse_spec.rb": "7bdee543e82532e97bbf7a067140031c", - "spec/acceptance/rstrip_spec.rb": "28a64ceb7cb5ae8a93d31f49816190ab", - "spec/acceptance/shuffle_spec.rb": "8a8652e57d56f2b4946cdf4d20052b7a", - "spec/acceptance/size_spec.rb": "ae17d8a55921a0570972200c7c9327e1", - "spec/acceptance/sort_spec.rb": "d44b1b8c090f0f00a2f38515fda431ea", - "spec/acceptance/squeeze_spec.rb": "adcd65fa4e72203b97f1f14c8835c2cd", - "spec/acceptance/str2bool_spec.rb": "55ad165ceef6b9ba32bf20ca3b53b44c", - "spec/acceptance/str2saltedsha512_spec.rb": "b684c4214d06ae3d5bae055262a5ccaa", - "spec/acceptance/strftime_spec.rb": "0f4eadbd74445b35de4a42c9790fbcc1", - "spec/acceptance/strip_spec.rb": "6767da5bc735beb5362aeee6ff692c9e", - "spec/acceptance/suffix_spec.rb": "07dfc7eed48b75fcc1b93d0308243eda", - "spec/acceptance/swapcase_spec.rb": "5c3c1bc19a09fed6e01881f79b0b4ea5", - "spec/acceptance/time_spec.rb": "044b2f634a1fa6ecc735998d68a93b73", - "spec/acceptance/to_bytes_spec.rb": "f9df1f234b9409f5eaf56ef24e651c36", - "spec/acceptance/try_get_value_spec.rb": "db7c47f372f9d9725987ebe13e6039eb", - "spec/acceptance/type_spec.rb": "4297e038a8ff7e6ecb859b8b68c7b3a6", - "spec/acceptance/union_spec.rb": "f24e166bc838c9c8cbd75ad3f8f9d15b", - "spec/acceptance/unique_spec.rb": "9b00b21cefde3b5391f50eeb9cd2493b", - "spec/acceptance/unsupported_spec.rb": "09b9265ecb05252cd5e5a18327c7ae97", - "spec/acceptance/upcase_spec.rb": "ffd1d6f9e6ec24131fb78983c53a75f9", - "spec/acceptance/uriescape_spec.rb": "13daa387714cbfc63b587aaa8dbf7fcd", - "spec/acceptance/validate_absolute_path_spec.rb": "8b9ebfae80329231d84fcab606a3eeaf", - "spec/acceptance/validate_array_spec.rb": "382641719e754622ffae562d10e38bf7", - "spec/acceptance/validate_augeas_spec.rb": "c26b8ca2184a9dd87033a0c6f0553093", - "spec/acceptance/validate_bool_spec.rb": "08bc139459204cf0a35098a5bc30ab95", - "spec/acceptance/validate_cmd_spec.rb": "e9260c49d880e4de54f77bf4fd70cff4", - "spec/acceptance/validate_hash_spec.rb": "70ceacc18a0dee97b26ab2e50f925706", - "spec/acceptance/validate_ipv4_address_spec.rb": "dc901bbd05c3764a93cb49154cea6e4b", - "spec/acceptance/validate_ipv6_address_spec.rb": "c0872c56230ac2800cd5723eaa5bc53a", - "spec/acceptance/validate_re_spec.rb": "b289909078d6ae0d015419f518566698", - "spec/acceptance/validate_slength_spec.rb": "f0a05c1c2b895b096cb7326df4821594", - "spec/acceptance/validate_string_spec.rb": "6c9ced99fb1e263e66e25427d24f8f7b", - "spec/acceptance/values_at_spec.rb": "669b26c4d47742051472003518c3aa61", - "spec/acceptance/values_spec.rb": "9681223bb1bd755c28946ef0bcd6ece9", - "spec/acceptance/zip_spec.rb": "86d1b555745ee873da68c71f1e46ed21", - "spec/functions/abs_spec.rb": "7c0ebbd787b788d32b9bb21fe9061a2f", - "spec/functions/any2array_spec.rb": "c5990164adbaaf4f6536df4022309176", - "spec/functions/assert_private_spec.rb": "3bf58bd53467248cc221b9f846b13d98", - "spec/functions/base64_spec.rb": "fa279d9a4f3060ee3f467e35b050d528", - "spec/functions/basename_spec.rb": "84a6567266725376d7ab518ab7dc5fe8", - "spec/functions/bool2num_spec.rb": "6609136ff067b90d41cf27bf8838c3ea", - "spec/functions/bool2str_spec.rb": "52560617234393f960aedb496b49a628", - "spec/functions/camelcase_spec.rb": "4a13d3323535291fef3f40a96710acdb", - "spec/functions/capitalize_spec.rb": "31a8d497b274653d5ede70a0187d4053", - "spec/functions/ceiling_spec.rb": "47bd74569f8979d9195df06a863de93b", - "spec/functions/chomp_spec.rb": "6749a0b358b34e73843e1a284cead44a", - "spec/functions/chop_spec.rb": "6e33e61f50459191387c87e474d3d127", - "spec/functions/clamp_spec.rb": "65dab1e9aceb2cb4e41ef9c0c65a7ba3", - "spec/functions/concat_spec.rb": "d217a63169e819e1ae2445083c248aa6", - "spec/functions/convert_base_spec.rb": "f031e84b18cb010bc6233be3e4bcff83", - "spec/functions/count_spec.rb": "d91a084665ecd902586d26c99d45beed", - "spec/functions/deep_merge_spec.rb": "d70a71c7e9363c75224fffd40fc5efdd", - "spec/functions/defined_with_params_spec.rb": "9185955113fd14a7b2fbaa0228669d00", - "spec/functions/delete_at_spec.rb": "a5443ac5879992af9c4470e59f0355cf", - "spec/functions/delete_spec.rb": "2352787d3a93bf863bd6db186d4bcf4f", - "spec/functions/delete_undef_values_spec.rb": "6bee6b89a507130a009a9e8b5ef3e130", - "spec/functions/delete_values_spec.rb": "0d2d17c0cacd7f3871ea7ab2f5b96d93", - "spec/functions/difference_spec.rb": "2caaab5edb42ddc426e65348b12ebcc3", - "spec/functions/dig_spec.rb": "60ef76a16c557e7580cd8747c3476f1e", - "spec/functions/dirname_spec.rb": "5c905655d551b1956b6c9eda4ee96569", - "spec/functions/dos2unix_spec.rb": "95c13597be9e67e79e69ed0e6c3d325a", - "spec/functions/downcase_spec.rb": "e2c24d41c6fb840f7b66c5205c942780", - "spec/functions/empty_spec.rb": "e6d06c193869ce8c97d3e67d5c5c5b4f", - "spec/functions/ensure_packages_spec.rb": "76e89bf81ae98e52d2a07263c0e8d4f4", - "spec/functions/ensure_resource_spec.rb": "57634d7b6f86ac77dc47fb5da36410c2", - "spec/functions/flatten_spec.rb": "6fb563c36daf40599a414c1f3af8dc0b", - "spec/functions/floor_spec.rb": "7d110b1f994432e1c6c7c004a3dedbe4", - "spec/functions/fqdn_rand_string_spec.rb": "2edaae1764df4d751684d8ceda7b9cda", - "spec/functions/fqdn_rotate_spec.rb": "e9b1ce122788f18611cf64696d666328", - "spec/functions/get_module_path_spec.rb": "ef22bd80ce5dedb069830d5aa10572c1", - "spec/functions/getparam_spec.rb": "dbbdde0a72653feb479e9fb971b94ec7", - "spec/functions/getvar_spec.rb": "18a9340442dd59cea8a6c98e95d38f4d", - "spec/functions/grep_spec.rb": "b9d0722e7708351b0114c46d4272f760", - "spec/functions/has_interface_with_spec.rb": "473c000e461c3497f8461eb17cf73430", - "spec/functions/has_ip_address_spec.rb": "7b36b993ea32757e74be9909906bd165", - "spec/functions/has_ip_network_spec.rb": "23021acd604dc4ca3a1fef62e8863d8e", - "spec/functions/has_key_spec.rb": "6bc81bc7d179d4b680e7065a60b76562", - "spec/functions/hash_spec.rb": "4519b75eeb8eb0bba80b4594c297cf5e", - "spec/functions/intersection_spec.rb": "fcd475963335b3efee99c3ddd0ddd969", - "spec/functions/is_a_spec.rb": "51b1f473786fbd1d723febf20281de23", - "spec/functions/is_array_spec.rb": "7ea00635b395f231fce6467c95410b05", - "spec/functions/is_bool_spec.rb": "9173b8fd7cb5aea4504f0fa860d883c9", - "spec/functions/is_domain_name_spec.rb": "4ea3825d5b77a5d75eab8228dcc738f9", - "spec/functions/is_email_address_spec.rb": "699c4573dfd00db8993a18afc0eaf875", - "spec/functions/is_float_spec.rb": "42b7f071e02af58e3154643b84445af1", - "spec/functions/is_function_available.rb": "f8ab234d536532c3629ff6a5068e7877", - "spec/functions/is_hash_spec.rb": "11563529f0f1f821769edb3131277100", - "spec/functions/is_integer_spec.rb": "799bef092df12fa590e71473db957d11", - "spec/functions/is_ip_address_spec.rb": "195e89d0c32eae24e4a51d12b8c59009", - "spec/functions/is_mac_address_spec.rb": "748b7e3dffae6d4097da9cc29a37e94d", - "spec/functions/is_numeric_spec.rb": "d131e94cf670075e8c46576b5109c2b6", - "spec/functions/is_string_spec.rb": "f41f332f93fc05b57ee9611cdbe73c11", - "spec/functions/join_keys_to_values_spec.rb": "b95f8f32888a96c4239c87cf9785d288", - "spec/functions/join_spec.rb": "2181956bf08efe90f932a17e5138a25c", - "spec/functions/keys_spec.rb": "8a6772daf2ae821e98d392f5266fdf67", - "spec/functions/load_module_metadata_spec.rb": "bcc48736e28992853c4f6b16d397daed", - "spec/functions/loadyaml_spec.rb": "f4f50af8016ffd187a0358b78634a259", - "spec/functions/lstrip_spec.rb": "58644ca945b38ec8b3d8729423aacf69", - "spec/functions/max_spec.rb": "47de8d59070d8d51b2184731f5d1aa43", - "spec/functions/member_spec.rb": "02891f40caaca15a5aba43443c7d2ccb", - "spec/functions/merge_spec.rb": "56297527d192640bbe82c7ccf1e39815", - "spec/functions/min_spec.rb": "8b38e2a989912406cd2c57dcd3a460c4", - "spec/functions/num2bool_spec.rb": "7c4fd30e41a11b1bd0d9e5233340f16b", - "spec/functions/parsejson_spec.rb": "656300186e986725982595c262f7eccd", - "spec/functions/parseyaml_spec.rb": "67b3be346368a2070535585a51bcd7c2", - "spec/functions/pick_default_spec.rb": "bef7bb2f755e665775aa0085c6897fb2", - "spec/functions/pick_spec.rb": "8fe02695ea909e993119254accc61f1a", - "spec/functions/prefix_spec.rb": "95956321291a0f6d1e2f45572569fe3b", - "spec/functions/private_spec.rb": "f404771c4590a0cd7ce61ddff8f3eb7b", - "spec/functions/pw_hash_spec.rb": "640609cc73b4c8bbcdfc88c3e9797664", - "spec/functions/range_spec.rb": "e73c3bb7f2c25540780c3bad19b30994", - "spec/functions/reject_spec.rb": "e0eb0546885dd0aef023dfa4694155db", - "spec/functions/reverse_spec.rb": "cb48f198c2a9efe224a00d67e68d978f", - "spec/functions/rstrip_spec.rb": "f0391a775d335e2a5c9335d50c657f4b", - "spec/functions/seeded_rand_spec.rb": "d7d80c3458706e83a8087e17c8a7b6ab", - "spec/functions/shuffle_spec.rb": "6ab6083720cfd4dfa99556e5ef81f576", - "spec/functions/size_spec.rb": "51495c464a203d9e1919008209f05cd5", - "spec/functions/sort_spec.rb": "d9533dd37c6263b92895f7eba8485248", - "spec/functions/squeeze_spec.rb": "549af334b7f9dd5f06d6b45c3e3e8303", - "spec/functions/str2bool_spec.rb": "607b25fb0badd0da5acb86c63437c8be", - "spec/functions/str2saltedsha512_spec.rb": "07586b0026757cd39229c12c7221808b", - "spec/functions/strftime_spec.rb": "f1a34fc930940213abfba3095d5d8065", - "spec/functions/strip_spec.rb": "0cb8537f2e7df14f42247349ab3161a6", - "spec/functions/suffix_spec.rb": "65172f6879c902802230f718ea9df7da", - "spec/functions/swapcase_spec.rb": "90bace1b004aa63d46eb6481c6dce2b1", - "spec/functions/time_spec.rb": "6dc8f5b42cf89345d2de424bfe19be90", - "spec/functions/to_bytes_spec.rb": "b771f8490d922de46a519e407d358139", - "spec/functions/try_get_value_spec.rb": "b917b899f5d29764dd4b1b07e07ec6ce", - "spec/functions/type3x_spec.rb": "eed4ce3a2bc92d14effedefef9690654", - "spec/functions/type_of_spec.rb": "83755d9390b9c00e086a007edff7fd9b", - "spec/functions/type_spec.rb": "7a61b4af7d3d83be590d783a7e5e80f8", - "spec/functions/union_spec.rb": "089b03e9a6ef25cdcf68157bb986d8a8", - "spec/functions/unique_spec.rb": "b793c531b4d227ae55d05a187b706fb8", - "spec/functions/unix2dos_spec.rb": "628c8a0c608d1fa0dd09bd1b5af97c1f", - "spec/functions/upcase_spec.rb": "4f0461a20c03d618f0c18da39bebcf65", - "spec/functions/uriescape_spec.rb": "1458afbe7e7e11dcaad8d295a7f2be59", - "spec/functions/validate_absolute_path_spec.rb": "26e00ce6122016b9b53797806e681682", - "spec/functions/validate_array_spec.rb": "df0bcf372b3efdd1f4de16b508987616", - "spec/functions/validate_augeas_spec.rb": "d598e89a23912be9f24d39b809f30b47", - "spec/functions/validate_bool_spec.rb": "93cfbecbe8cc4707ada13f48f5c8c8a6", - "spec/functions/validate_cmd_spec.rb": "05eb581532fc689ff91212413b2e678d", - "spec/functions/validate_email_address_spec.rb": "1296f9934d102258091379ee07f9a2a8", - "spec/functions/validate_hash_spec.rb": "56f4b7e42a4d3f62172982fa639f5cc3", - "spec/functions/validate_integer_spec.rb": "0a2677479c8bf0257bdd54c3d0db1f81", - "spec/functions/validate_ip_address_spec.rb": "e4ba65ff0c87b28b29f05e1637b7e700", - "spec/functions/validate_ipv4_address_spec.rb": "dc1af709faa724ccc51d9c5aba1d6356", - "spec/functions/validate_ipv6_address_spec.rb": "5f27c395b286385c489df5ee119580bc", - "spec/functions/validate_numeric_spec.rb": "dd5fcc7421002c85252d0a9421a5a99b", - "spec/functions/validate_re_spec.rb": "430e57fd80d3f29f4ba8be62c5463e62", - "spec/functions/validate_slength_spec.rb": "92252419e0d311a7bd6b426edb3c1040", - "spec/functions/validate_string_spec.rb": "779473e87660081e610c397f0157331a", - "spec/functions/validate_x509_rsa_key_pair_spec.rb": "24810bdb8ac473ae1168f1b2c5708170", - "spec/functions/values_at_spec.rb": "c318f66de43f8e6095d28f733f55ec5d", - "spec/functions/values_spec.rb": "5550da71a69514f8be87a12b575d5228", - "spec/functions/zip_spec.rb": "4c991f26985096b3e8b336cef528aa00", - "spec/monkey_patches/alias_should_to_must.rb": "b19ee31563afb91a72f9869f9d7362ff", - "spec/monkey_patches/publicize_methods.rb": "c690e444b77c871375d321e413e28ca1", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "4da340042246df9b9e3dc221a5807528", - "spec/spec_helper_local.rb": "845be3a017611728b73e73af427f7431", - "spec/unit/facter/facter_dot_d_spec.rb": "420339a544851f2c7ee6fa4c651bdce8", - "spec/unit/facter/package_provider_spec.rb": "3a6ba799822fbcabc9adab5880260b7a", - "spec/unit/facter/pe_version_spec.rb": "d0fa6c0d5b01a4b9fd36ed4168635e9f", - "spec/unit/facter/root_home_spec.rb": "036c160d5543f4f3e80a300a3a170b77", - "spec/unit/facter/service_provider_spec.rb": "a97efb411817a44c511cd6cd79d9af8c", - "spec/unit/facter/util/puppet_settings_spec.rb": "6f9df9b10a1b39245ecdf002616a4122", - "spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb": "0145a78254ea716e5e7600d9464318a8", - "spec/unit/puppet/parser/functions/is_absolute_path_spec.rb": "52f8d3b9011fb1fd8a2a429fe8b2ae08", - "spec/unit/puppet/provider/file_line/ruby_spec.rb": "e70f3093b17aeccef198b52901ab2f94", - "spec/unit/puppet/type/anchor_spec.rb": "06a669dffa44d716bf19b4e7f5f1d75d", - "spec/unit/puppet/type/file_line_spec.rb": "af824724caf0071d84464042490a6f88" -} \ No newline at end of file diff --git a/vagrant/puppet/modules/stdlib/examples/file_line.pp b/vagrant/puppet/modules/stdlib/examples/file_line.pp deleted file mode 100644 index 85b132586..000000000 --- a/vagrant/puppet/modules/stdlib/examples/file_line.pp +++ /dev/null @@ -1,9 +0,0 @@ -# This is a simple smoke test -# of the file_line resource type. -file { '/tmp/dansfile': - ensure => file, -} -> -file_line { 'dans_line': - line => 'dan is awesome', - path => '/tmp/dansfile', -} diff --git a/vagrant/puppet/modules/stdlib/examples/has_interface_with.pp b/vagrant/puppet/modules/stdlib/examples/has_interface_with.pp deleted file mode 100644 index a578dd279..000000000 --- a/vagrant/puppet/modules/stdlib/examples/has_interface_with.pp +++ /dev/null @@ -1,9 +0,0 @@ -include ::stdlib -info('has_interface_with(\'lo\'):', has_interface_with('lo')) -info('has_interface_with(\'loX\'):', has_interface_with('loX')) -info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1')) -info('has_interface_with(\'ipaddress\', \'127.0.0.100\'):', has_interface_with('ipaddress', '127.0.0.100')) -info('has_interface_with(\'network\', \'127.0.0.0\'):', has_interface_with('network', '127.0.0.0')) -info('has_interface_with(\'network\', \'128.0.0.0\'):', has_interface_with('network', '128.0.0.0')) -info('has_interface_with(\'netmask\', \'255.0.0.0\'):', has_interface_with('netmask', '255.0.0.0')) -info('has_interface_with(\'netmask\', \'256.0.0.0\'):', has_interface_with('netmask', '256.0.0.0')) diff --git a/vagrant/puppet/modules/stdlib/examples/has_ip_address.pp b/vagrant/puppet/modules/stdlib/examples/has_ip_address.pp deleted file mode 100644 index 594143d66..000000000 --- a/vagrant/puppet/modules/stdlib/examples/has_ip_address.pp +++ /dev/null @@ -1,3 +0,0 @@ -include ::stdlib -info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256')) -info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1')) diff --git a/vagrant/puppet/modules/stdlib/examples/has_ip_network.pp b/vagrant/puppet/modules/stdlib/examples/has_ip_network.pp deleted file mode 100644 index 1f1130dc7..000000000 --- a/vagrant/puppet/modules/stdlib/examples/has_ip_network.pp +++ /dev/null @@ -1,3 +0,0 @@ -include ::stdlib -info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0')) -info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0')) diff --git a/vagrant/puppet/modules/stdlib/examples/init.pp b/vagrant/puppet/modules/stdlib/examples/init.pp deleted file mode 100644 index ad2797213..000000000 --- a/vagrant/puppet/modules/stdlib/examples/init.pp +++ /dev/null @@ -1 +0,0 @@ -include ::stdlib diff --git a/vagrant/puppet/modules/stdlib/lib/facter/facter_dot_d.rb b/vagrant/puppet/modules/stdlib/lib/facter/facter_dot_d.rb deleted file mode 100644 index 5c5fb1fde..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/facter_dot_d.rb +++ /dev/null @@ -1,202 +0,0 @@ -# A Facter plugin that loads facts from /etc/facter/facts.d -# and /etc/puppetlabs/facter/facts.d. -# -# Facts can be in the form of JSON, YAML or Text files -# and any executable that returns key=value pairs. -# -# In the case of scripts you can also create a file that -# contains a cache TTL. For foo.sh store the ttl as just -# a number in foo.sh.ttl -# -# The cache is stored in $libdir/facts_dot_d.cache as a mode -# 600 file and will have the end result of not calling your -# fact scripts more often than is needed - -class Facter::Util::DotD - require 'yaml' - - def initialize(dir="/etc/facts.d", cache_file=File.join(Puppet[:libdir], "facts_dot_d.cache")) - @dir = dir - @cache_file = cache_file - @cache = nil - @types = {".txt" => :txt, ".json" => :json, ".yaml" => :yaml} - end - - def entries - Dir.entries(@dir).reject { |f| f =~ /^\.|\.ttl$/ }.sort.map { |f| File.join(@dir, f) } - rescue - [] - end - - def fact_type(file) - extension = File.extname(file) - - type = @types[extension] || :unknown - - type = :script if type == :unknown && File.executable?(file) - - return type - end - - def txt_parser(file) - File.readlines(file).each do |line| - if line =~ /^([^=]+)=(.+)$/ - var = $1; val = $2 - - Facter.add(var) do - setcode { val } - end - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}") - end - - def json_parser(file) - begin - require 'json' - rescue LoadError - retry if require 'rubygems' - raise - end - - JSON.load(File.read(file)).each_pair do |f, v| - Facter.add(f) do - setcode { v } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}") - end - - def yaml_parser(file) - require 'yaml' - - YAML.load_file(file).each_pair do |f, v| - Facter.add(f) do - setcode { v } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}") - end - - def script_parser(file) - result = cache_lookup(file) - ttl = cache_time(file) - - unless result - result = Facter::Util::Resolution.exec(file) - - if ttl > 0 - Facter.debug("Updating cache for #{file}") - cache_store(file, result) - cache_save! - end - else - Facter.debug("Using cached data for #{file}") - end - - result.split("\n").each do |line| - if line =~ /^(.+)=(.+)$/ - var = $1; val = $2 - - Facter.add(var) do - setcode { val } - end - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}") - Facter.debug(e.backtrace.join("\n\t")) - end - - def cache_save! - cache = load_cache - File.open(@cache_file, "w", 0600) { |f| f.write(YAML.dump(cache)) } - rescue - end - - def cache_store(file, data) - load_cache - - @cache[file] = {:data => data, :stored => Time.now.to_i} - rescue - end - - def cache_lookup(file) - cache = load_cache - - return nil if cache.empty? - - ttl = cache_time(file) - - if cache[file] - now = Time.now.to_i - - return cache[file][:data] if ttl == -1 - return cache[file][:data] if (now - cache[file][:stored]) <= ttl - return nil - else - return nil - end - rescue - return nil - end - - def cache_time(file) - meta = file + ".ttl" - - return File.read(meta).chomp.to_i - rescue - return 0 - end - - def load_cache - unless @cache - if File.exist?(@cache_file) - @cache = YAML.load_file(@cache_file) - else - @cache = {} - end - end - - return @cache - rescue - @cache = {} - return @cache - end - - def create - entries.each do |fact| - type = fact_type(fact) - parser = "#{type}_parser" - - if respond_to?("#{type}_parser") - Facter.debug("Parsing #{fact} using #{parser}") - - send(parser, fact) - end - end - end -end - - -mdata = Facter.version.match(/(\d+)\.(\d+)\.(\d+)/) -if mdata - (major, minor, patch) = mdata.captures.map { |v| v.to_i } - if major < 2 - # Facter 1.7 introduced external facts support directly - unless major == 1 and minor > 6 - Facter::Util::DotD.new("/etc/facter/facts.d").create - Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create - - # Windows has a different configuration directory that defaults to a vendor - # specific sub directory of the %COMMON_APPDATA% directory. - if Dir.const_defined? 'COMMON_APPDATA' then - windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d') - Facter::Util::DotD.new(windows_facts_dot_d).create - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/package_provider.rb b/vagrant/puppet/modules/stdlib/lib/facter/package_provider.rb deleted file mode 100644 index 3a9117fdb..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/package_provider.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Fact: package_provider -# -# Purpose: Returns the default provider Puppet will choose to manage packages -# on this system -# -# Resolution: Instantiates a dummy package resource and return the provider -# -# Caveats: -# -require 'puppet/type' -require 'puppet/type/package' - -Facter.add(:package_provider) do - setcode do - if defined? Gem and Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6') - Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s - else - Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/pe_version.rb b/vagrant/puppet/modules/stdlib/lib/facter/pe_version.rb deleted file mode 100644 index c9f2181c0..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/pe_version.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version -# -# Purpose: Return various facts about the PE state of the system -# -# Resolution: Uses a regex match against puppetversion to determine whether the -# machine has Puppet Enterprise installed, and what version (overall, major, -# minor, patch) is installed. -# -# Caveats: -# -Facter.add("pe_version") do - setcode do - puppet_ver = Facter.value("puppetversion") - if puppet_ver != nil - pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/) - pe_ver[1] if pe_ver - else - nil - end - end -end - -Facter.add("is_pe") do - setcode do - if Facter.value(:pe_version).to_s.empty? then - false - else - true - end - end -end - -Facter.add("pe_major_version") do - confine :is_pe => true - setcode do - if pe_version = Facter.value(:pe_version) - pe_version.to_s.split('.')[0] - end - end -end - -Facter.add("pe_minor_version") do - confine :is_pe => true - setcode do - if pe_version = Facter.value(:pe_version) - pe_version.to_s.split('.')[1] - end - end -end - -Facter.add("pe_patch_version") do - confine :is_pe => true - setcode do - if pe_version = Facter.value(:pe_version) - pe_version.to_s.split('.')[2] - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/puppet_vardir.rb b/vagrant/puppet/modules/stdlib/lib/facter/puppet_vardir.rb deleted file mode 100644 index 0e6af40e4..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/puppet_vardir.rb +++ /dev/null @@ -1,26 +0,0 @@ -# This facter fact returns the value of the Puppet vardir setting for the node -# running puppet or puppet agent. The intent is to enable Puppet modules to -# automatically have insight into a place where they can place variable data, -# regardless of the node's platform. -# -# The value should be directly usable in a File resource path attribute. - - -begin - require 'facter/util/puppet_settings' -rescue LoadError => e - # puppet apply does not add module lib directories to the $LOAD_PATH (See - # #4248). It should (in the future) but for the time being we need to be - # defensive which is what this rescue block is doing. - rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb') - load rb_file if File.exists?(rb_file) or raise e -end - -Facter.add(:puppet_vardir) do - setcode do - # This will be nil if Puppet is not available. - Facter::Util::PuppetSettings.with_puppet do - Puppet[:vardir] - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/root_home.rb b/vagrant/puppet/modules/stdlib/lib/facter/root_home.rb deleted file mode 100644 index 87c765718..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/root_home.rb +++ /dev/null @@ -1,45 +0,0 @@ -# A facter fact to determine the root home directory. -# This varies on PE supported platforms and may be -# reconfigured by the end user. - -module Facter::Util::RootHome - class << self - def get_root_home - root_ent = Facter::Util::Resolution.exec("getent passwd root") - # The home directory is the sixth element in the passwd entry - # If the platform doesn't have getent, root_ent will be nil and we should - # return it straight away. - root_ent && root_ent.split(":")[5] - end - end -end - -Facter.add(:root_home) do - setcode { Facter::Util::RootHome.get_root_home } -end - -Facter.add(:root_home) do - confine :kernel => :darwin - setcode do - str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root") - hash = {} - str.split("\n").each do |pair| - key,value = pair.split(/:/) - hash[key] = value - end - hash['dir'].strip - end -end - -Facter.add(:root_home) do - confine :kernel => :aix - root_home = nil - setcode do - str = Facter::Util::Resolution.exec("lsuser -c -a home root") - str && str.split("\n").each do |line| - next if line =~ /^#/ - root_home = line.split(/:/)[1] - end - root_home - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/service_provider.rb b/vagrant/puppet/modules/stdlib/lib/facter/service_provider.rb deleted file mode 100644 index a11792115..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/service_provider.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Fact: service_provider -# -# Purpose: Returns the default provider Puppet will choose to manage services -# on this system -# -# Resolution: Instantiates a dummy service resource and return the provider -# -# Caveats: -# -require 'puppet/type' -require 'puppet/type/service' - -Facter.add(:service_provider) do - setcode do - Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb b/vagrant/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb deleted file mode 100644 index 1ad945218..000000000 --- a/vagrant/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Facter - module Util - module PuppetSettings - # This method is intended to provide a convenient way to evaluate a - # Facter code block only if Puppet is loaded. This is to account for the - # situation where the fact happens to be in the load path, but Puppet is - # not loaded for whatever reason. Perhaps the user is simply running - # facter without the --puppet flag and they happen to be working in a lib - # directory of a module. - def self.with_puppet - begin - Module.const_get("Puppet") - rescue NameError - nil - else - yield - end - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/functions/is_a.rb b/vagrant/puppet/modules/stdlib/lib/puppet/functions/is_a.rb deleted file mode 100644 index da98b0352..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/functions/is_a.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. -# -# @example how to check a data type -# # check a data type -# foo = 3 -# $bar = [1,2,3] -# $baz = 'A string!' -# -# if $foo.is_a(Integer) { -# notify { 'foo!': } -# } -# if $bar.is_a(Array) { -# notify { 'bar!': } -# } -# if $baz.is_a(String) { -# notify { 'baz!': } -# } -# -# See the documentation for "The Puppet Type System" for more information about types. -# See the `assert_type()` function for flexible ways to assert the type of a value. -# -Puppet::Functions.create_function(:is_a) do - dispatch :is_a do - param 'Any', :value - param 'Type', :type - end - - def is_a(value, type) - # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression - Puppet::Pops::Types::TypeCalculator.instance?(type, value) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/functions/type_of.rb b/vagrant/puppet/modules/stdlib/lib/puppet/functions/type_of.rb deleted file mode 100644 index 02cdd4db7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/functions/type_of.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Returns the type when passed a value. -# -# @example how to compare values' types -# # compare the types of two values -# if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") } -# @example how to compare against an abstract type -# unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") } -# unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") } -# -# See the documentation for "The Puppet Type System" for more information about types. -# See the `assert_type()` function for flexible ways to assert the type of a value. -# -Puppet::Functions.create_function(:type_of) do - def type_of(value) - Puppet::Pops::Types::TypeCalculator.infer_set(value) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/abs.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/abs.rb deleted file mode 100644 index 11d2d7fea..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/abs.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# abs.rb -# - -module Puppet::Parser::Functions - newfunction(:abs, :type => :rvalue, :doc => <<-EOS - Returns the absolute value of a number, for example -34.56 becomes - 34.56. Takes a single integer and float value as an argument. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "abs(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - # Numbers in Puppet are often string-encoded which is troublesome ... - if value.is_a?(String) - if value.match(/^-?(?:\d+)(?:\.\d+){1}$/) - value = value.to_f - elsif value.match(/^-?\d+$/) - value = value.to_i - else - raise(Puppet::ParseError, 'abs(): Requires float or ' + - 'integer to work with') - end - end - - # We have numeric value to handle ... - result = value.abs - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/any2array.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/any2array.rb deleted file mode 100644 index e71407e89..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/any2array.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# any2array.rb -# - -module Puppet::Parser::Functions - newfunction(:any2array, :type => :rvalue, :doc => <<-EOS -This converts any object to an array containing that object. Empty argument -lists are converted to an empty array. Arrays are left untouched. Hashes are -converted to arrays of alternating keys and values. - EOS - ) do |arguments| - - if arguments.empty? - return [] - end - - if arguments.length == 1 - if arguments[0].kind_of?(Array) - return arguments[0] - elsif arguments[0].kind_of?(Hash) - result = [] - arguments[0].each do |key, value| - result << key << value - end - return result - end - end - - return arguments - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/assert_private.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/assert_private.rb deleted file mode 100644 index 66c79cce3..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/assert_private.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# assert_private.rb -# - -module Puppet::Parser::Functions - newfunction(:assert_private, :doc => <<-'EOS' - Sets the current class or definition as private. - Calling the class or definition from outside the current module will fail. - EOS - ) do |args| - - raise(Puppet::ParseError, "assert_private(): Wrong number of arguments "+ - "given (#{args.size}}) for 0 or 1)") if args.size > 1 - - scope = self - if scope.lookupvar('module_name') != scope.lookupvar('caller_module_name') - message = nil - if args[0] and args[0].is_a? String - message = args[0] - else - manifest_name = scope.source.name - manifest_type = scope.source.type - message = (manifest_type.to_s == 'hostclass') ? 'Class' : 'Definition' - message += " #{manifest_name} is private" - end - raise(Puppet::ParseError, message) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/base64.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/base64.rb deleted file mode 100644 index a8998f220..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/base64.rb +++ /dev/null @@ -1,68 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - - Base64 encode or decode a string based on the command and the string submitted - - Usage: - - $encodestring = base64('encode', 'thestring') - $decodestring = base64('decode', 'dGhlc3RyaW5n') - - # explicitly define encode/decode method: default, strict, urlsafe - $method = 'default' - $encodestring = base64('encode', 'thestring', $method) - $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) - - ENDHEREDOC - - require 'base64' - - raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be >= 2)") unless args.length >= 2 - - actions = ['encode','decode'] - - unless actions.include?(args[0]) - raise Puppet::ParseError, ("base64(): the first argument must be one of 'encode' or 'decode'") - end - - unless args[1].is_a?(String) - raise Puppet::ParseError, ("base64(): the second argument must be a string to base64") - end - - method = ['default','strict','urlsafe'] - - if args.length <= 2 - chosenMethod = 'default' - else - chosenMethod = args[2] - end - - unless method.include?(chosenMethod) - raise Puppet::ParseError, ("base64(): the third argument must be one of 'default', 'strict', or 'urlsafe'") - end - - case args[0] - when 'encode' - case chosenMethod - when 'default' - result = Base64.encode64(args[1]) - when 'strict' - result = Base64.strict_encode64(args[1]) - when 'urlsafe' - result = Base64.urlsafe_encode64(args[1]) - end - when 'decode' - case chosenMethod - when 'default' - result = Base64.decode64(args[1]) - when 'strict' - result = Base64.strict_decode64(args[1]) - when 'urlsafe' - result = Base64.urlsafe_decode64(args[1]) - end - end - - return result - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/basename.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/basename.rb deleted file mode 100644 index f7e443847..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/basename.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:basename, :type => :rvalue, :doc => <<-EOS - Strips directory (and optional suffix) from a filename - EOS - ) do |arguments| - - if arguments.size < 1 then - raise(Puppet::ParseError, "basename(): No arguments given") - elsif arguments.size > 2 then - raise(Puppet::ParseError, "basename(): Too many arguments given (#{arguments.size})") - else - - unless arguments[0].is_a?(String) - raise(Puppet::ParseError, 'basename(): Requires string as first argument') - end - - if arguments.size == 1 then - rv = File.basename(arguments[0]) - elsif arguments.size == 2 then - - unless arguments[1].is_a?(String) - raise(Puppet::ParseError, 'basename(): Requires string as second argument') - end - - rv = File.basename(arguments[0], arguments[1]) - end - - end - - return rv - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2num.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2num.rb deleted file mode 100644 index 6ad6cf4e8..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +++ /dev/null @@ -1,26 +0,0 @@ -# -# bool2num.rb -# - -module Puppet::Parser::Functions - newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS - Converts a boolean to a number. Converts the values: - false, f, 0, n, and no to 0 - true, t, 1, y, and yes to 1 - Requires a single boolean or string as an input. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = function_str2bool([arguments[0]]) - - # We have real boolean values as well ... - result = value ? 1 : 0 - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2str.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2str.rb deleted file mode 100644 index 7e364747c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/bool2str.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# bool2str.rb -# - -module Puppet::Parser::Functions - newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS - Converts a boolean to a string using optionally supplied arguments. The - optional second and third arguments represent what true and false will be - converted to respectively. If only one argument is given, it will be - converted from a boolean to a string containing 'true' or 'false'. - - *Examples:* - - bool2str(true) => 'true' - bool2str(true, 'yes', 'no') => 'yes' - bool2str(false, 't', 'f') => 'f' - - Requires a single boolean as an input. - EOS - ) do |arguments| - - unless arguments.size == 1 or arguments.size == 3 - raise(Puppet::ParseError, "bool2str(): Wrong number of arguments " + - "given (#{arguments.size} for 3)") - end - - value = arguments[0] - true_string = arguments[1] || 'true' - false_string = arguments[2] || 'false' - klass = value.class - - # We can have either true or false, and nothing else - unless [FalseClass, TrueClass].include?(klass) - raise(Puppet::ParseError, 'bool2str(): Requires a boolean to work with') - end - - unless [true_string, false_string].all?{|x| x.kind_of?(String)} - raise(Puppet::ParseError, "bool2str(): Requires strings to convert to" ) - end - - return value ? true_string : false_string - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/camelcase.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/camelcase.rb deleted file mode 100644 index d7f43f7a7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/camelcase.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# camelcase.rb -# - -module Puppet::Parser::Functions - newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS -Converts the case of a string or all strings in an array to camel case. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "camelcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - klass = value.class - - unless [Array, String].include?(klass) - raise(Puppet::ParseError, 'camelcase(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.split('_').map{|e| e.capitalize}.join : i } - else - result = value.split('_').map{|e| e.capitalize}.join - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/capitalize.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/capitalize.rb deleted file mode 100644 index 98b2d16c9..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# capitalize.rb -# - -module Puppet::Parser::Functions - newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS - Capitalizes the first letter of a string or array of strings. - Requires either a single string or an array as an input. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'capitalize(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.capitalize : i } - else - result = value.capitalize - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ceiling.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ceiling.rb deleted file mode 100644 index 5f3b10b89..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ceiling.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS - Returns the smallest integer greater or equal to the argument. - Takes a single numeric value as an argument. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "ceiling(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - begin - arg = Float(arguments[0]) - rescue TypeError, ArgumentError => e - raise(Puppet::ParseError, "ceiling(): Wrong argument type " + - "given (#{arguments[0]} for Numeric)") - end - - raise(Puppet::ParseError, "ceiling(): Wrong argument type " + - "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false - - arg.ceil - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chomp.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chomp.rb deleted file mode 100644 index c55841e3c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chomp.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# chomp.rb -# - -module Puppet::Parser::Functions - newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS' - Removes the record separator from the end of a string or an array of - strings, for example `hello\n` becomes `hello`. - Requires a single string or array as an input. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "chomp(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'chomp(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.chomp : i } - else - result = value.chomp - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chop.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chop.rb deleted file mode 100644 index b24ab7856..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/chop.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# chop.rb -# - -module Puppet::Parser::Functions - newfunction(:chop, :type => :rvalue, :doc => <<-'EOS' - Returns a new string with the last character removed. If the string ends - with `\r\n`, both characters are removed. Applying chop to an empty - string returns an empty string. If you wish to merely remove record - separators then you should use the `chomp` function. - Requires a string or array of strings as input. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "chop(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'chop(): Requires either an ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.chop : i } - else - result = value.chop - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/clamp.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/clamp.rb deleted file mode 100644 index 432c7c1fe..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/clamp.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# clamp.rb -# - -module Puppet::Parser::Functions - newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS - Clamps value to a range. - EOS - ) do |args| - - args.flatten! - - raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, ' + - 'need three to clamp') if args.size != 3 - - # check values out - args.each do |value| - case [value.class] - when [String] - raise(Puppet::ParseError, "clamp(): Required explicit numeric (#{value}:String)") unless value =~ /^\d+$/ - when [Hash] - raise(Puppet::ParseError, "clamp(): The Hash type is not allowed (#{value})") - end - end - - # convert to numeric each element - # then sort them and get a middle value - args.map{ |n| n.to_i }.sort[1] - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/concat.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/concat.rb deleted file mode 100644 index 91edb4e2b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/concat.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# concat.rb -# - -module Puppet::Parser::Functions - newfunction(:concat, :type => :rvalue, :doc => <<-EOS -Appends the contents of multiple arrays into array 1. - -*Example:* - - concat(['1','2','3'],['4','5','6'],['7','8','9']) - -Would result in: - - ['1','2','3','4','5','6','7','8','9'] - EOS - ) do |arguments| - - # Check that more than 2 arguments have been given ... - raise(Puppet::ParseError, "concat(): Wrong number of arguments " + - "given (#{arguments.size} for < 2)") if arguments.size < 2 - - a = arguments[0] - - # Check that the first parameter is an array - unless a.is_a?(Array) - raise(Puppet::ParseError, 'concat(): Requires array to work with') - end - - result = a - arguments.shift - - arguments.each do |x| - result = result + (x.is_a?(Array) ? x : [x]) - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/convert_base.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/convert_base.rb deleted file mode 100644 index 0fcbafeaf..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/convert_base.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args| - - Converts a given integer or base 10 string representing an integer to a specified base, as a string. - - Usage: - - $binary_repr = convert_base(5, 2) # $binary_repr is now set to "101" - $hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe" - - ENDHEREDOC - - raise Puppet::ParseError, ("convert_base(): First argument must be either a string or an integer") unless (args[0].is_a?(Integer) or args[0].is_a?(String)) - raise Puppet::ParseError, ("convert_base(): Second argument must be either a string or an integer") unless (args[1].is_a?(Integer) or args[1].is_a?(String)) - - if args[0].is_a?(String) - raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[0] =~ /^[0-9]+$/ - end - - if args[1].is_a?(String) - raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[1] =~ /^[0-9]+$/ - end - - number_to_convert = args[0] - new_base = args[1] - - number_to_convert = number_to_convert.to_i() - new_base = new_base.to_i() - - raise Puppet::ParseError, ("convert_base(): base must be at least 2 and must not be greater than 36") unless new_base >= 2 and new_base <= 36 - - return number_to_convert.to_s(new_base) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/count.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/count.rb deleted file mode 100644 index 52de1b8a5..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/count.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS -Takes an array as first argument and an optional second argument. -Count the number of elements in array that matches second argument. -If called with only an array it counts the number of elements that are not nil/undef. - EOS - ) do |args| - - if (args.size > 2) then - raise(ArgumentError, "count(): Wrong number of arguments "+ - "given #{args.size} for 1 or 2.") - end - - collection, item = args - - if item then - collection.count item - else - collection.count { |obj| obj != nil && obj != :undef && obj != '' } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb deleted file mode 100644 index 6df32e9c5..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - Recursively merges two or more hashes together and returns the resulting hash. - - For example: - - $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } - $merged_hash = deep_merge($hash1, $hash2) - # The resulting hash is equivalent to: - # $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } - - When there is a duplicate key that is a hash, they are recursively merged. - When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." - - ENDHEREDOC - - if args.length < 2 - raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)") - end - - deep_merge = Proc.new do |hash1,hash2| - hash1.merge(hash2) do |key,old_value,new_value| - if old_value.is_a?(Hash) && new_value.is_a?(Hash) - deep_merge.call(old_value, new_value) - else - new_value - end - end - end - - result = Hash.new - args.each do |arg| - next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef - # If the argument was not a hash, skip it. - unless arg.is_a?(Hash) - raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments" - end - - result = deep_merge.call(result, arg) - end - return( result ) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb deleted file mode 100644 index d7df306c7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Test whether a given class or definition is defined -require 'puppet/parser/functions' - -Puppet::Parser::Functions.newfunction(:defined_with_params, - :type => :rvalue, - :doc => <<-'ENDOFDOC' -Takes a resource reference and an optional hash of attributes. - -Returns true if a resource with the specified attributes has already been added -to the catalog, and false otherwise. - - user { 'dan': - ensure => present, - } - - if ! defined_with_params(User[dan], {'ensure' => 'present' }) { - user { 'dan': ensure => present, } - } -ENDOFDOC -) do |vals| - reference, params = vals - raise(ArgumentError, 'Must specify a reference') unless reference - if (! params) || params == '' - params = {} - end - ret = false - if resource = findresource(reference.to_s) - matches = params.collect do |key, value| - resource[key] == value - end - ret = params.empty? || !matches.include?(false) - end - Puppet.debug("Resource #{reference} was not determined to be defined") - ret -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete.rb deleted file mode 100644 index f548b4444..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# delete.rb -# - -# TODO(Krzysztof Wilczynski): We need to add support for regular expression ... - -module Puppet::Parser::Functions - newfunction(:delete, :type => :rvalue, :doc => <<-EOS -Deletes all instances of a given element from an array, substring from a -string, or key from a hash. - -*Examples:* - - delete(['a','b','c','b'], 'b') - Would return: ['a','c'] - - delete({'a'=>1,'b'=>2,'c'=>3}, 'b') - Would return: {'a'=>1,'c'=>3} - - delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c']) - Would return: {'a'=>1} - - delete('abracadabra', 'bra') - Would return: 'acada' - EOS - ) do |arguments| - - if (arguments.size != 2) then - raise(Puppet::ParseError, "delete(): Wrong number of arguments "+ - "given #{arguments.size} for 2.") - end - - collection = arguments[0].dup - Array(arguments[1]).each do |item| - case collection - when Array, Hash - collection.delete item - when String - collection.gsub! item, '' - else - raise(TypeError, "delete(): First argument must be an Array, " + - "String, or Hash. Given an argument of class #{collection.class}.") - end - end - collection - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_at.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_at.rb deleted file mode 100644 index 3eb4b5375..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# delete_at.rb -# - -module Puppet::Parser::Functions - newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS -Deletes a determined indexed value from an array. - -*Examples:* - - delete_at(['a','b','c'], 1) - -Would return: ['a','c'] - EOS - ) do |arguments| - - raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - - array = arguments[0] - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'delete_at(): Requires array to work with') - end - - index = arguments[1] - - if index.is_a?(String) and not index.match(/^\d+$/) - raise(Puppet::ParseError, 'delete_at(): You must provide ' + - 'non-negative numeric index') - end - - result = array.clone - - # Numbers in Puppet are often string-encoded which is troublesome ... - index = index.to_i - - if index > result.size - 1 # First element is at index 0 is it not? - raise(Puppet::ParseError, 'delete_at(): Given index ' + - 'exceeds size of array given') - end - - result.delete_at(index) # We ignore the element that got deleted ... - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb deleted file mode 100644 index f94d4da8d..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS -Returns a copy of input hash or array with all undefs deleted. - -*Examples:* - - $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) - -Would return: {a => 'A', b => '', d => false} - - $array = delete_undef_values(['A','',undef,false]) - -Would return: ['A','',false] - - EOS - ) do |args| - - raise(Puppet::ParseError, - "delete_undef_values(): Wrong number of arguments given " + - "(#{args.size})") if args.size < 1 - - unless args[0].is_a? Array or args[0].is_a? Hash - raise(Puppet::ParseError, - "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ") - end - result = args[0].dup - if result.is_a?(Hash) - result.delete_if {|key, val| val.equal? :undef} - elsif result.is_a?(Array) - result.delete :undef - end - result - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_values.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_values.rb deleted file mode 100644 index f6c8c0e6b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS -Deletes all instances of a given value from a hash. - -*Examples:* - - delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') - -Would return: {'a'=>'A','c'=>'C','B'=>'D'} - - EOS - ) do |arguments| - - raise(Puppet::ParseError, - "delete_values(): Wrong number of arguments given " + - "(#{arguments.size} of 2)") if arguments.size != 2 - - hash, item = arguments - - if not hash.is_a?(Hash) - raise(TypeError, "delete_values(): First argument must be a Hash. " + \ - "Given an argument of class #{hash.class}.") - end - hash.dup.delete_if { |key, val| item == val } - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/difference.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/difference.rb deleted file mode 100644 index cd258f751..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/difference.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# difference.rb -# - -module Puppet::Parser::Functions - newfunction(:difference, :type => :rvalue, :doc => <<-EOS -This function returns the difference between two arrays. -The returned array is a copy of the original array, removing any items that -also appear in the second array. - -*Examples:* - - difference(["a","b","c"],["b","c","d"]) - -Would return: ["a"] - EOS - ) do |arguments| - - # Two arguments are required - raise(Puppet::ParseError, "difference(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - - first = arguments[0] - second = arguments[1] - - unless first.is_a?(Array) && second.is_a?(Array) - raise(Puppet::ParseError, 'difference(): Requires 2 arrays') - end - - result = first - second - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dig.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dig.rb deleted file mode 100644 index a9aa770df..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dig.rb +++ /dev/null @@ -1,54 +0,0 @@ -# -# dig.rb -# - -module Puppet::Parser::Functions - newfunction(:dig, :type => :rvalue, :doc => <<-EOS -Looks up into a complex structure of arrays and hashes and returns nil -or the default value if nothing was found. - -Path is an array of keys to be looked up in data argument. The function -will go down the structure and try to extract the required value. - -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3' ]}} - -$value = dig($data, ['a', 'b', '2'], 'not_found') -=> $value = 'b3' - -a -> first hash key -b -> second hash key -2 -> array index starting with 0 - -not_found -> (optional) will be returned if there is no value or the path -did not match. Defaults to nil. - -In addition to the required "path" argument, "dig" accepts default -argument. It will be returned if no value was found or a path component is -missing. And the fourth argument can set a variable path separator. - EOS - ) do |arguments| - # Two arguments are required - raise(Puppet::ParseError, "dig(): Wrong number of arguments " + - "given (#{arguments.size} for at least 2)") if arguments.size < 2 - - data, path, default = *arguments - - if !(data.is_a?(Hash) || data.is_a?(Array)) - raise(Puppet::ParseError, "dig(): first argument must be a hash or an array, " << - "given #{data.class.name}") - end - - unless path.is_a? Array - raise(Puppet::ParseError, "dig(): second argument must be an array, " << - "given #{path.class.name}") - end - - value = path.reduce(data) { |h, k| (h.is_a?(Hash) || h.is_a?(Array)) ? h[k] : break } - value.nil? ? default : value - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb deleted file mode 100644 index 40b300d89..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dirname.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:dirname, :type => :rvalue, :doc => <<-EOS - Returns the dirname of a path. - EOS - ) do |arguments| - - if arguments.size < 1 then - raise(Puppet::ParseError, "dirname(): No arguments given") - end - if arguments.size > 1 then - raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})") - end - unless arguments[0].is_a?(String) - raise(Puppet::ParseError, 'dirname(): Requires string as argument') - end - - return File.dirname(arguments[0]) - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb deleted file mode 100644 index ccac89933..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Custom Puppet function to convert dos to unix format -module Puppet::Parser::Functions - newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS - Returns the Unix version of the given string. - Takes a single string argument. - EOS - ) do |arguments| - - unless arguments[0].is_a?(String) - raise(Puppet::ParseError, 'dos2unix(): Requires string as argument') - end - - arguments[0].gsub(/\r\n/, "\n") - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/downcase.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/downcase.rb deleted file mode 100644 index 040b84f56..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/downcase.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# downcase.rb -# - -module Puppet::Parser::Functions - newfunction(:downcase, :type => :rvalue, :doc => <<-EOS -Converts the case of a string or all strings in an array to lower case. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "downcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'downcase(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.downcase : i } - else - result = value.downcase - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/empty.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/empty.rb deleted file mode 100644 index b5a3cdea4..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/empty.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# empty.rb -# - -module Puppet::Parser::Functions - newfunction(:empty, :type => :rvalue, :doc => <<-EOS -Returns true if the variable is empty. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "empty(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric) - raise(Puppet::ParseError, 'empty(): Requires either ' + - 'array, hash, string or integer to work with') - end - - if value.is_a?(Numeric) - return false - else - result = value.empty? - - return result - end - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb deleted file mode 100644 index 80ffc3aca..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# enclose_ipv6.rb -# - -module Puppet::Parser::Functions - newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS -Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. - EOS - ) do |arguments| - - require 'ipaddr' - - rescuable_exceptions = [ ArgumentError ] - if defined?(IPAddr::InvalidAddressError) - rescuable_exceptions << IPAddr::InvalidAddressError - end - - if (arguments.size != 1) then - raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then - raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type "+ - "given #{arguments[0].class} expected String or Array") - end - - input = [arguments[0]].flatten.compact - result = [] - - input.each do |val| - unless val == '*' - begin - ip = IPAddr.new(val) - rescue *rescuable_exceptions - raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument "+ - "given #{val} is not an ip address.") - end - val = "[#{ip.to_s}]" if ip.ipv6? - end - result << val - end - - return result.uniq - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb deleted file mode 100644 index 532b70265..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +++ /dev/null @@ -1,46 +0,0 @@ -# -# ensure_packages.rb -# - -module Puppet::Parser::Functions - newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS -Takes a list of packages and only installs them if they don't already exist. -It optionally takes a hash as a second parameter that will be passed as the -third argument to the ensure_resource() function. - EOS - ) do |arguments| - - if arguments.size > 2 or arguments.size == 0 - raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " + - "given (#{arguments.size} for 1 or 2)") - elsif arguments.size == 2 and !arguments[1].is_a?(Hash) - raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash') - end - - if arguments[0].is_a?(Hash) - if arguments[1] - defaults = { 'ensure' => 'present' }.merge(arguments[1]) - else - defaults = { 'ensure' => 'present' } - end - - Puppet::Parser::Functions.function(:ensure_resources) - function_ensure_resources(['package', Hash(arguments[0]), defaults ]) - else - packages = Array(arguments[0]) - - if arguments[1] - defaults = { 'ensure' => 'present' }.merge(arguments[1]) - else - defaults = { 'ensure' => 'present' } - end - - Puppet::Parser::Functions.function(:ensure_resource) - packages.each { |package_name| - function_ensure_resource(['package', package_name, defaults ]) - } - end - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb deleted file mode 100644 index 1ba6a4478..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Test whether a given class or definition is defined -require 'puppet/parser/functions' - -Puppet::Parser::Functions.newfunction(:ensure_resource, - :type => :statement, - :doc => <<-'ENDOFDOC' -Takes a resource type, title, and a list of attributes that describe a -resource. - - user { 'dan': - ensure => present, - } - -This example only creates the resource if it does not already exist: - - ensure_resource('user', 'dan', {'ensure' => 'present' }) - -If the resource already exists but does not match the specified parameters, -this function will attempt to recreate the resource leading to a duplicate -resource definition error. - -An array of resources can also be passed in and each will be created with -the type and parameters specified if it doesn't already exist. - - ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) - -ENDOFDOC -) do |vals| - type, title, params = vals - raise(ArgumentError, 'Must specify a type') unless type - raise(ArgumentError, 'Must specify a title') unless title - params ||= {} - - items = [title].flatten - - items.each do |item| - Puppet::Parser::Functions.function(:defined_with_params) - if function_defined_with_params(["#{type}[#{item}]", params]) - Puppet.debug("Resource #{type}[#{item}] with params #{params} not created because it already exists") - else - Puppet.debug("Create new resource #{type}[#{item}] with params #{params}") - Puppet::Parser::Functions.function(:create_resources) - function_create_resources([type.capitalize, { item => params }]) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb deleted file mode 100644 index 30d57a88a..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'puppet/parser/functions' - -Puppet::Parser::Functions.newfunction(:ensure_resources, - :type => :statement, - :doc => <<-'ENDOFDOC' -Takes a resource type, title (only hash), and a list of attributes that describe a -resource. - - user { 'dan': - gid => 'mygroup', - ensure => present, - } - -An hash of resources should be passed in and each will be created with -the type and parameters specified if it doesn't already exist. - - ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } , 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) - -From Hiera Backend: - -userlist: - dan: - gid: 'mygroup' - uid: '600' - alex: - gid: 'mygroup' - -Call: -ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) - -ENDOFDOC -) do |vals| - type, title, params = vals - raise(ArgumentError, 'Must specify a type') unless type - raise(ArgumentError, 'Must specify a title') unless title - params ||= {} - - if title.is_a?(Hash) - resource_hash = Hash(title) - resources = resource_hash.keys - - Puppet::Parser::Functions.function(:ensure_resource) - resources.each { |resource_name| - if resource_hash[resource_name] - params_merged = params.merge(resource_hash[resource_name]) - else - params_merged = params - end - function_ensure_resource([ type, resource_name, params_merged ]) - } - else - raise(Puppet::ParseError, 'ensure_resources(): Requires second argument to be a Hash') - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/flatten.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/flatten.rb deleted file mode 100644 index a1ed18329..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/flatten.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# flatten.rb -# - -module Puppet::Parser::Functions - newfunction(:flatten, :type => :rvalue, :doc => <<-EOS -This function flattens any deeply nested arrays and returns a single flat array -as a result. - -*Examples:* - - flatten(['a', ['b', ['c']]]) - -Would return: ['a','b','c'] - EOS - ) do |arguments| - - raise(Puppet::ParseError, "flatten(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - array = arguments[0] - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'flatten(): Requires array to work with') - end - - result = array.flatten - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/floor.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/floor.rb deleted file mode 100644 index 9a6f014d7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/floor.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:floor, :type => :rvalue, :doc => <<-EOS - Returns the largest integer less or equal to the argument. - Takes a single numeric value as an argument. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "floor(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - begin - arg = Float(arguments[0]) - rescue TypeError, ArgumentError => e - raise(Puppet::ParseError, "floor(): Wrong argument type " + - "given (#{arguments[0]} for Numeric)") - end - - raise(Puppet::ParseError, "floor(): Wrong argument type " + - "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false - - arg.floor - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb deleted file mode 100644 index 2bb1287e0..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb +++ /dev/null @@ -1,34 +0,0 @@ -Puppet::Parser::Functions::newfunction( - :fqdn_rand_string, - :arity => -2, - :type => :rvalue, - :doc => "Usage: `fqdn_rand_string(LENGTH, [CHARSET], [SEED])`. LENGTH is - required and must be a positive integer. CHARSET is optional and may be - `undef` or a string. SEED is optional and may be any number or string. - - Generates a random string LENGTH characters long using the character set - provided by CHARSET, combining the `$fqdn` fact and the value of SEED for - repeatable randomness. (That is, each node will get a different random - string from this function, but a given node's result will be the same every - time unless its hostname changes.) Adding a SEED can be useful if you need - more than one unrelated string. CHARSET will default to alphanumeric if - `undef` or an empty string.") do |args| - raise(ArgumentError, "fqdn_rand_string(): wrong number of arguments (0 for 1)") if args.size == 0 - Puppet::Parser::Functions.function('is_integer') - raise(ArgumentError, "fqdn_rand_string(): first argument must be a positive integer") unless function_is_integer([args[0]]) and args[0].to_i > 0 - raise(ArgumentError, "fqdn_rand_string(): second argument must be undef or a string") unless args[1].nil? or args[1].is_a? String - - Puppet::Parser::Functions.function('fqdn_rand') - - length = args.shift.to_i - charset = args.shift.to_s.chars.to_a - - charset = (0..9).map { |i| i.to_s } + ('A'..'Z').to_a + ('a'..'z').to_a if charset.empty? - - rand_string = '' - for current in 1..length - rand_string << charset[function_fqdn_rand([charset.size, (args + [current.to_s]).join(':')]).to_i] - end - - rand_string -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb deleted file mode 100644 index b66431d1e..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +++ /dev/null @@ -1,63 +0,0 @@ -# -# fqdn_rotate.rb -# - -Puppet::Parser::Functions.newfunction( - :fqdn_rotate, - :type => :rvalue, - :doc => "Usage: `fqdn_rotate(VALUE, [SEED])`. VALUE is required and - must be an array or a string. SEED is optional and may be any number - or string. - - Rotates VALUE a random number of times, combining the `$fqdn` fact and - the value of SEED for repeatable randomness. (That is, each node will - get a different random rotation from this function, but a given node's - result will be the same every time unless its hostname changes.) Adding - a SEED can be useful if you need more than one unrelated rotation.") do |args| - - raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size < 1 - - value = args.shift - require 'digest/md5' - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'fqdn_rotate(): Requires either ' + - 'array or string to work with') - end - - result = value.clone - - string = value.is_a?(String) ? true : false - - # Check whether it makes sense to rotate ... - return result if result.size <= 1 - - # We turn any string value into an array to be able to rotate ... - result = string ? result.split('') : result - - elements = result.size - - seed = Digest::MD5.hexdigest([lookupvar('::fqdn'),args].join(':')).hex - # deterministic_rand() was added in Puppet 3.2.0; reimplement if necessary - if Puppet::Util.respond_to?(:deterministic_rand) - offset = Puppet::Util.deterministic_rand(seed, elements).to_i - else - if defined?(Random) == 'constant' && Random.class == Class - offset = Random.new(seed).rand(elements) - else - old_seed = srand(seed) - offset = rand(elements) - srand(old_seed) - end - end - offset.times { - result.push result.shift - } - - result = string ? result.join : result - - return result -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb deleted file mode 100644 index 1421b91f5..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT - Returns the absolute path of the specified module for the current - environment. - - Example: - $module_path = get_module_path('stdlib') - EOT - ) do |args| - raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1 - if module_path = Puppet::Module.find(args[0], compiler.environment.to_s) - module_path.path - else - raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}") - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getparam.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getparam.rb deleted file mode 100644 index 6d510069f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getparam.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Test whether a given class or definition is defined -require 'puppet/parser/functions' - -Puppet::Parser::Functions.newfunction(:getparam, - :type => :rvalue, - :doc => <<-'ENDOFDOC' -Takes a resource reference and name of the parameter and -returns value of resource's parameter. - -*Examples:* - - define example_resource($param) { - } - - example_resource { "example_resource_instance": - param => "param_value" - } - - getparam(Example_resource["example_resource_instance"], "param") - -Would return: param_value -ENDOFDOC -) do |vals| - reference, param = vals - raise(ArgumentError, 'Must specify a reference') unless reference - raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String - - return '' if param.empty? - - if resource = findresource(reference.to_s) - return resource[param] if resource[param] - end - - return '' -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getvar.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getvar.rb deleted file mode 100644 index ae9c869d1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/getvar.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - Lookup a variable in a remote namespace. - - For example: - - $foo = getvar('site::data::foo') - # Equivalent to $foo = $site::data::foo - - This is useful if the namespace itself is stored in a string: - - $datalocation = 'site::data' - $bar = getvar("${datalocation}::bar") - # Equivalent to $bar = $site::data::bar - ENDHEREDOC - - unless args.length == 1 - raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)") - end - - begin - catch(:undefined_variable) do - self.lookupvar("#{args[0]}") - end - rescue Puppet::ParseError # Eat the exception if strict_variables = true is set - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/grep.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/grep.rb deleted file mode 100644 index ceba9ecc8..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/grep.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# grep.rb -# - -module Puppet::Parser::Functions - newfunction(:grep, :type => :rvalue, :doc => <<-EOS -This function searches through an array and returns any elements that match -the provided regular expression. - -*Examples:* - - grep(['aaa','bbb','ccc','aaaddd'], 'aaa') - -Would return: - - ['aaa','aaaddd'] - EOS - ) do |arguments| - - if (arguments.size != 2) then - raise(Puppet::ParseError, "grep(): Wrong number of arguments "+ - "given #{arguments.size} for 2") - end - - a = arguments[0] - pattern = Regexp.new(arguments[1]) - - a.grep(pattern) - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb deleted file mode 100644 index e7627982d..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +++ /dev/null @@ -1,71 +0,0 @@ -# -# has_interface_with -# - -module Puppet::Parser::Functions - newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS -Returns boolean based on kind and value: - * macaddress - * netmask - * ipaddress - * network - -has_interface_with("macaddress", "x:x:x:x:x:x") -has_interface_with("ipaddress", "127.0.0.1") => true -etc. - -If no "kind" is given, then the presence of the interface is checked: -has_interface_with("lo") => true - EOS - ) do |args| - - raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments " + - "given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2 - - interfaces = lookupvar('interfaces') - - # If we do not have any interfaces, then there are no requested attributes - return false if (interfaces == :undefined || interfaces.nil?) - - interfaces = interfaces.split(',') - - if args.size == 1 - return interfaces.member?(args[0]) - end - - kind, value = args - - # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable - # https://tickets.puppetlabs.com/browse/PUP-3597 - factval = nil - begin - catch :undefined_variable do - factval = lookupvar(kind) - end - rescue Puppet::ParseError # Eat the exception if strict_variables = true is set - end - if factval == value - return true - end - - result = false - interfaces.each do |iface| - iface.downcase! - factval = nil - begin - # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable - # https://tickets.puppetlabs.com/browse/PUP-3597 - catch :undefined_variable do - factval = lookupvar("#{kind}_#{iface}") - end - rescue Puppet::ParseError # Eat the exception if strict_variables = true is set - end - if value == factval - result = true - break - end - end - - result - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb deleted file mode 100644 index 842c8ec67..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +++ /dev/null @@ -1,25 +0,0 @@ -# -# has_ip_address -# - -module Puppet::Parser::Functions - newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS -Returns true if the client has the requested IP address on some interface. - -This function iterates through the 'interfaces' fact and checks the -'ipaddress_IFACE' facts, performing a simple string comparison. - EOS - ) do |args| - - raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ - unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) - - function_has_interface_with(['ipaddress', args[0]]) - - end -end - -# vim:sts=2 sw=2 diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb deleted file mode 100644 index 9ccf9024f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +++ /dev/null @@ -1,25 +0,0 @@ -# -# has_ip_network -# - -module Puppet::Parser::Functions - newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS -Returns true if the client has an IP address within the requested network. - -This function iterates through the 'interfaces' fact and checks the -'network_IFACE' facts, performing a simple string comparision. - EOS - ) do |args| - - raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ - unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) - - function_has_interface_with(['network', args[0]]) - - end -end - -# vim:sts=2 sw=2 diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_key.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_key.rb deleted file mode 100644 index 4657cc29c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/has_key.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - Determine if a hash has a certain key value. - - Example: - - $my_hash = {'key_one' => 'value_one'} - if has_key($my_hash, 'key_two') { - notice('we will not reach here') - } - if has_key($my_hash, 'key_one') { - notice('this will be printed') - } - - ENDHEREDOC - - unless args.length == 2 - raise Puppet::ParseError, ("has_key(): wrong number of arguments (#{args.length}; must be 2)") - end - unless args[0].is_a?(Hash) - raise Puppet::ParseError, "has_key(): expects the first argument to be a hash, got #{args[0].inspect} which is of type #{args[0].class}" - end - args[0].has_key?(args[1]) - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/hash.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/hash.rb deleted file mode 100644 index 89d0e07ec..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/hash.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# hash.rb -# - -module Puppet::Parser::Functions - newfunction(:hash, :type => :rvalue, :doc => <<-EOS -This function converts an array into a hash. - -*Examples:* - - hash(['a',1,'b',2,'c',3]) - -Would return: {'a'=>1,'b'=>2,'c'=>3} - EOS - ) do |arguments| - - raise(Puppet::ParseError, "hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - array = arguments[0] - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'hash(): Requires array to work with') - end - - result = {} - - begin - # This is to make it compatible with older version of Ruby ... - array = array.flatten - result = Hash[*array] - rescue StandardError - raise(Puppet::ParseError, 'hash(): Unable to compute ' + - 'hash from array given') - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/intersection.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/intersection.rb deleted file mode 100644 index bfbb4babb..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/intersection.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# intersection.rb -# - -module Puppet::Parser::Functions - newfunction(:intersection, :type => :rvalue, :doc => <<-EOS -This function returns an array of the intersection of two. - -*Examples:* - - intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] - intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) - - EOS - ) do |arguments| - - # Two arguments are required - raise(Puppet::ParseError, "intersection(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - - first = arguments[0] - second = arguments[1] - - unless first.is_a?(Array) && second.is_a?(Array) - raise(Puppet::ParseError, 'intersection(): Requires 2 arrays') - end - - result = first & second - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb deleted file mode 100644 index 53a544507..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb +++ /dev/null @@ -1,50 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args| - Returns boolean true if the string represents an absolute path in the filesystem. This function works - for windows and unix style paths. - - The following values will return true: - - $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' - is_absolute_path($my_path) - $my_path2 = '/var/lib/puppet' - is_absolute_path($my_path2) - $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet'] - is_absolute_path($my_path3) - $my_path4 = ['/var/lib/puppet'] - is_absolute_path($my_path4) - - The following values will return false: - - is_absolute_path(true) - is_absolute_path('../var/lib/puppet') - is_absolute_path('var/lib/puppet') - $undefined = undef - is_absolute_path($undefined) - - ENDHEREDOC - - require 'puppet/util' - - path = args[0] - # This logic was borrowed from - # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb) - # Puppet 2.7 and beyond will have Puppet::Util.absolute_path? Fall back to a back-ported implementation otherwise. - if Puppet::Util.respond_to?(:absolute_path?) then - value = (Puppet::Util.absolute_path?(path, :posix) or Puppet::Util.absolute_path?(path, :windows)) - else - # This code back-ported from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path? - # Determine in a platform-specific way whether a path is absolute. This - # defaults to the local platform if none is specified. - # Escape once for the string literal, and once for the regex. - slash = '[\\\\/]' - name = '[^\\\\/]+' - regexes = { - :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, - :posix => %r!^/! - } - value = (!!(path =~ regexes[:posix])) || (!!(path =~ regexes[:windows])) - end - value - end -end \ No newline at end of file diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_array.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_array.rb deleted file mode 100644 index b39e184ae..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_array.rb +++ /dev/null @@ -1,22 +0,0 @@ -# -# is_array.rb -# - -module Puppet::Parser::Functions - newfunction(:is_array, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is an array. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "is_array(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - type = arguments[0] - - result = type.is_a?(Array) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_bool.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_bool.rb deleted file mode 100644 index 8bbdbc8a1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +++ /dev/null @@ -1,22 +0,0 @@ -# -# is_bool.rb -# - -module Puppet::Parser::Functions - newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is a boolean. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - type = arguments[0] - - result = type.is_a?(TrueClass) || type.is_a?(FalseClass) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb deleted file mode 100644 index 90ede3272..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +++ /dev/null @@ -1,54 +0,0 @@ -# -# is_domain_name.rb -# - -module Puppet::Parser::Functions - newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a syntactically correct domain name. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - # Only allow string types - return false unless arguments[0].is_a?(String) - - domain = arguments[0].dup - - # Limits (rfc1035, 3.1) - domain_max_length=255 - label_min_length=1 - label_max_length=63 - - # Allow ".", it is the top level domain - return true if domain == '.' - - # Remove the final dot, if present. - domain.chomp!('.') - - # Check the whole domain - return false if domain.empty? - return false if domain.length > domain_max_length - - # The top level domain must be alphabetic if there are multiple labels. - # See rfc1123, 2.1 - return false if domain.include? '.' and not /\.[A-Za-z]+$/.match(domain) - - # Check each label in the domain - labels = domain.split('.') - vlabels = labels.each do |label| - break if label.length < label_min_length - break if label.length > label_max_length - break if label[-1..-1] == '-' - break if label[0..0] == '-' - break unless /^[a-z\d-]+$/i.match(label) - end - return vlabels == labels - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb deleted file mode 100644 index 4fb022902..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# is_email_address.rb -# - -module Puppet::Parser::Functions - newfunction(:is_email_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid email address. - EOS - ) do |arguments| - if arguments.size != 1 - raise(Puppet::ParseError, 'is_email_address(): Wrong number of arguments '\ - "given #{arguments.size} for 1") - end - - # Taken from http://emailregex.com/ (simpler regex) - valid_email_regex = %r{\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z} - return (arguments[0] =~ valid_email_regex) == 0 - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_float.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_float.rb deleted file mode 100644 index a2da94385..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_float.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# is_float.rb -# - -module Puppet::Parser::Functions - newfunction(:is_float, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is a float. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - value = arguments[0] - - # Only allow Numeric or String types - return false unless value.is_a?(Numeric) or value.is_a?(String) - - if value != value.to_f.to_s and !value.is_a? Float then - return false - else - return true - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb deleted file mode 100644 index 6da82c8c1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +++ /dev/null @@ -1,26 +0,0 @@ -# -# is_function_available.rb -# - -module Puppet::Parser::Functions - newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS -This function accepts a string as an argument, determines whether the -Puppet runtime has access to a function by that name. It returns a -true if the function exists, false if not. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - # Only allow String types - return false unless arguments[0].is_a?(String) - - function = Puppet::Parser::Functions.function(arguments[0].to_sym) - function.is_a?(String) and not function.empty? - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_hash.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_hash.rb deleted file mode 100644 index ad907f086..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +++ /dev/null @@ -1,22 +0,0 @@ -# -# is_hash.rb -# - -module Puppet::Parser::Functions - newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is a hash. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - type = arguments[0] - - result = type.is_a?(Hash) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_integer.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_integer.rb deleted file mode 100644 index c03d28df9..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# is_integer.rb -# - -module Puppet::Parser::Functions - newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is an Integer or -a decimal (base 10) integer in String form. The string may -start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not -be followed by other digits as this indicates that the value is octal (base 8). - -If given any other argument `false` is returned. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - value = arguments[0] - - # Regex is taken from the lexer of puppet - # puppet/pops/parser/lexer.rb but modified to match also - # negative values and disallow numbers prefixed with multiple - # 0's - # - # TODO these parameter should be a constant but I'm not sure - # if there is no risk to declare it inside of the module - # Puppet::Parser::Functions - - # Integer numbers like - # -1234568981273 - # 47291 - numeric = %r{^-?(?:(?:[1-9]\d*)|0)$} - - if value.is_a? Integer or (value.is_a? String and value.match numeric) - return true - else - return false - end - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb deleted file mode 100644 index a90adabe1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# is_ip_address.rb -# - -module Puppet::Parser::Functions - newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid IP address. - EOS - ) do |arguments| - - require 'ipaddr' - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - begin - ip = IPAddr.new(arguments[0]) - rescue ArgumentError - return false - end - - if ip.ipv4? or ip.ipv6? then - return true - else - return false - end - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb deleted file mode 100644 index b4861d5b1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# is_ipv4_address.rb -# - -module Puppet::Parser::Functions - newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid IPv4 address. - EOS - ) do |arguments| - - require 'ipaddr' - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - begin - ip = IPAddr.new(arguments[0]) - rescue ArgumentError - return false - end - - return ip.ipv4? - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb deleted file mode 100644 index 475ad5043..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# is_ipv6_address.rb -# - -module Puppet::Parser::Functions - newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid IPv6 address. - EOS - ) do |arguments| - - require 'ipaddr' - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ipv6_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - begin - ip = IPAddr.new(arguments[0]) - rescue ArgumentError - return false - end - - return ip.ipv6? - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb deleted file mode 100644 index 2619d44a3..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# is_mac_address.rb -# - -module Puppet::Parser::Functions - newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid mac address. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - mac = arguments[0] - - if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then - return true - else - return false - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb deleted file mode 100644 index e7e1d2a74..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +++ /dev/null @@ -1,75 +0,0 @@ -# -# is_numeric.rb -# - -module Puppet::Parser::Functions - newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS -Returns true if the given argument is a Numeric (Integer or Float), -or a String containing either a valid integer in decimal base 10 form, or -a valid floating point string representation. - -The function recognizes only decimal (base 10) integers and float but not -integers in hex (base 16) or octal (base 8) form. - -The string representation may start with a '-' (minus). If a decimal '.' is used, -it must be followed by at least one digit. - -Valid examples: - - 77435 - 10e-12 - -8475 - 0.2343 - -23.561e3 - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - value = arguments[0] - - # Regex is taken from the lexer of puppet - # puppet/pops/parser/lexer.rb but modified to match also - # negative values and disallow invalid octal numbers or - # numbers prefixed with multiple 0's (except in hex numbers) - # - # TODO these parameters should be constants but I'm not sure - # if there is no risk to declare them inside of the module - # Puppet::Parser::Functions - - # TODO decide if this should be used - # HEX numbers like - # 0xaa230F - # 0X1234009C - # 0x0012 - # -12FcD - #numeric_hex = %r{^-?0[xX][0-9A-Fa-f]+$} - - # TODO decide if this should be used - # OCTAL numbers like - # 01234567 - # -045372 - #numeric_oct = %r{^-?0[1-7][0-7]*$} - - # Integer/Float numbers like - # -0.1234568981273 - # 47291 - # 42.12345e-12 - numeric = %r{^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$} - - if value.is_a? Numeric or (value.is_a? String and ( - value.match(numeric) #or - # value.match(numeric_hex) or - # value.match(numeric_oct) - )) - return true - else - return false - end - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_string.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_string.rb deleted file mode 100644 index f5bef0457..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/is_string.rb +++ /dev/null @@ -1,26 +0,0 @@ -# -# is_string.rb -# - -module Puppet::Parser::Functions - newfunction(:is_string, :type => :rvalue, :doc => <<-EOS -Returns true if the variable passed to this function is a string. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "is_string(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - type = arguments[0] - - result = type.is_a?(String) - - if result and (type == type.to_f.to_s or type == type.to_i.to_s) then - return false - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join.rb deleted file mode 100644 index 6c0a6ba02..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# join.rb -# - -module Puppet::Parser::Functions - newfunction(:join, :type => :rvalue, :doc => <<-EOS -This function joins an array into a string using a separator. - -*Examples:* - - join(['a','b','c'], ",") - -Would result in: "a,b,c" - EOS - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "join(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - array = arguments[0] - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'join(): Requires array to work with') - end - - suffix = arguments[1] if arguments[1] - - if suffix - unless suffix.is_a?(String) - raise(Puppet::ParseError, 'join(): Requires string to work with') - end - end - - result = suffix ? array.join(suffix) : array.join - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb deleted file mode 100644 index e9924fe2e..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# join.rb -# - -module Puppet::Parser::Functions - newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS -This function joins each key of a hash to that key's corresponding value with a -separator. Keys and values are cast to strings. The return value is an array in -which each element is one joined key/value pair. - -*Examples:* - - join_keys_to_values({'a'=>1,'b'=>2}, " is ") - -Would result in: ["a is 1","b is 2"] - EOS - ) do |arguments| - - # Validate the number of arguments. - if arguments.size != 2 - raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " + - "arguments, but #{arguments.size} given.") - end - - # Validate the first argument. - hash = arguments[0] - if not hash.is_a?(Hash) - raise(TypeError, "join_keys_to_values(): The first argument must be a " + - "hash, but a #{hash.class} was given.") - end - - # Validate the second argument. - separator = arguments[1] - if not separator.is_a?(String) - raise(TypeError, "join_keys_to_values(): The second argument must be a " + - "string, but a #{separator.class} was given.") - end - - # Join the keys to their values. - hash.map do |k,v| - String(k) + separator + String(v) - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/keys.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/keys.rb deleted file mode 100644 index f0d13b647..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/keys.rb +++ /dev/null @@ -1,26 +0,0 @@ -# -# keys.rb -# - -module Puppet::Parser::Functions - newfunction(:keys, :type => :rvalue, :doc => <<-EOS -Returns the keys of a hash as an array. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "keys(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - hash = arguments[0] - - unless hash.is_a?(Hash) - raise(Puppet::ParseError, 'keys(): Requires hash to work with') - end - - result = hash.keys - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb deleted file mode 100644 index c9b84885b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-EOT - EOT - ) do |args| - raise(Puppet::ParseError, "load_module_metadata(): Wrong number of arguments, expects one or two") unless [1,2].include?(args.size) - mod = args[0] - allow_empty_metadata = args[1] - module_path = function_get_module_path([mod]) - metadata_json = File.join(module_path, 'metadata.json') - - metadata_exists = File.exists?(metadata_json) - if metadata_exists - metadata = PSON.load(File.read(metadata_json)) - else - if allow_empty_metadata - metadata = {} - else - raise(Puppet::ParseError, "load_module_metadata(): No metadata.json file for module #{mod}") - end - end - - return metadata - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb deleted file mode 100644 index ca655f6ea..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - Load a YAML file containing an array, string, or hash, and return the data - in the corresponding native data type. - - For example: - - $myhash = loadyaml('/etc/puppet/data/myhash.yaml') - ENDHEREDOC - - unless args.length == 1 - raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)") - end - - if File.exists?(args[0]) then - YAML.load_file(args[0]) - else - warning("Can't load " + args[0] + ". File does not exist!") - nil - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/lstrip.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/lstrip.rb deleted file mode 100644 index 624e4c846..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# lstrip.rb -# - -module Puppet::Parser::Functions - newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS -Strips leading spaces to the left of a string. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'lstrip(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.lstrip : i } - else - result = value.lstrip - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/max.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/max.rb deleted file mode 100644 index 60fb94ac0..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/max.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:max, :type => :rvalue, :doc => <<-EOS - Returns the highest value of all arguments. - Requires at least one argument. - EOS - ) do |args| - - raise(Puppet::ParseError, "max(): Wrong number of arguments " + - "need at least one") if args.size == 0 - - # Sometimes we get numbers as numerics and sometimes as strings. - # We try to compare them as numbers when possible - return args.max do |a,b| - if a.to_s =~ /\A-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then - a.to_f <=> b.to_f - else - a.to_s <=> b.to_s - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/member.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/member.rb deleted file mode 100644 index 1e5b3def9..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/member.rb +++ /dev/null @@ -1,62 +0,0 @@ -# -# member.rb -# - -# TODO(Krzysztof Wilczynski): We need to add support for regular expression ... -# TODO(Krzysztof Wilczynski): Support for strings and hashes too ... - -module Puppet::Parser::Functions - newfunction(:member, :type => :rvalue, :doc => <<-EOS -This function determines if a variable is a member of an array. -The variable can be a string, fixnum, or array. - -*Examples:* - - member(['a','b'], 'b') - -Would return: true - - member(['a', 'b', 'c'], ['a', 'b']) - -would return: true - - member(['a','b'], 'c') - -Would return: false - - member(['a', 'b', 'c'], ['d', 'b']) - -would return: false - EOS - ) do |arguments| - - raise(Puppet::ParseError, "member(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - - array = arguments[0] - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'member(): Requires array to work with') - end - - unless arguments[1].is_a? String or arguments[1].is_a? Fixnum or arguments[1].is_a? Array - raise(Puppet::ParseError, 'member(): Item to search for must be a string, fixnum, or array') - end - - if arguments[1].is_a? String or arguments[1].is_a? Fixnum - item = [arguments[1]] - else - item = arguments[1] - end - - - raise(Puppet::ParseError, 'member(): You must provide item ' + - 'to search for within array given') if item.respond_to?('empty?') && item.empty? - - result = (item - array).empty? - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/merge.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/merge.rb deleted file mode 100644 index 1b39f2060..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/merge.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| - Merges two or more hashes together and returns the resulting hash. - - For example: - - $hash1 = {'one' => 1, 'two', => 2} - $hash2 = {'two' => 'dos', 'three', => 'tres'} - $merged_hash = merge($hash1, $hash2) - # The resulting hash is equivalent to: - # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} - - When there is a duplicate key, the key in the rightmost hash will "win." - - ENDHEREDOC - - if args.length < 2 - raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)") - end - - # The hash we accumulate into - accumulator = Hash.new - # Merge into the accumulator hash - args.each do |arg| - next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef - unless arg.is_a?(Hash) - raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments" - end - accumulator.merge!(arg) - end - # Return the fully merged hash - accumulator - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/min.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/min.rb deleted file mode 100644 index 6bd6ebf20..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/min.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:min, :type => :rvalue, :doc => <<-EOS - Returns the lowest value of all arguments. - Requires at least one argument. - EOS - ) do |args| - - raise(Puppet::ParseError, "min(): Wrong number of arguments " + - "need at least one") if args.size == 0 - - # Sometimes we get numbers as numerics and sometimes as strings. - # We try to compare them as numbers when possible - return args.min do |a,b| - if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then - a.to_f <=> b.to_f - else - a.to_s <=> b.to_s - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/num2bool.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/num2bool.rb deleted file mode 100644 index af0e6ed78..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +++ /dev/null @@ -1,43 +0,0 @@ -# -# num2bool.rb -# - -module Puppet::Parser::Functions - newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS -This function converts a number or a string representation of a number into a -true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 -become true. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - number = arguments[0] - - case number - when Numeric - # Yay, it's a number - when String - begin - number = Float(number) - rescue ArgumentError => ex - raise(Puppet::ParseError, "num2bool(): '#{number}' does not look like a number: #{ex.message}") - end - else - begin - number = number.to_s - rescue NoMethodError => ex - raise(Puppet::ParseError, "num2bool(): Unable to parse argument: #{ex.message}") - end - end - - # Truncate Floats - number = number.to_i - - # Return true for any positive number and false otherwise - return number > 0 - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parsejson.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parsejson.rb deleted file mode 100644 index f7c2896ed..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# parsejson.rb -# - -module Puppet::Parser::Functions - newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS -This function accepts JSON as a string and converts it into the correct -Puppet structure. - -The optional second argument can be used to pass a default value that will -be returned if the parsing of YAML string have failed. - EOS - ) do |arguments| - raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 - - begin - PSON::load(arguments[0]) || arguments[1] - rescue StandardError => e - if arguments[1] - arguments[1] - else - raise e - end - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb deleted file mode 100644 index ba9d98aa9..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# parseyaml.rb -# - -module Puppet::Parser::Functions - newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS -This function accepts YAML as a string and converts it into the correct -Puppet structure. - -The optional second argument can be used to pass a default value that will -be returned if the parsing of YAML string have failed. - EOS - ) do |arguments| - raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 - require 'yaml' - - begin - YAML::load(arguments[0]) || arguments[1] - # in ruby 1.9.3 Psych::SyntaxError is a RuntimeException - # this still needs to catch that and work also on rubies that - # do not have Psych available. - rescue StandardError, Psych::SyntaxError => e - if arguments[1] - arguments[1] - else - raise e - end - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick.rb deleted file mode 100644 index fdd0aefd7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:pick, :type => :rvalue, :doc => <<-EOS - -This function is similar to a coalesce function in SQL in that it will return -the first value in a list of values that is not undefined or an empty string -(two things in Puppet that will return a boolean false value). Typically, -this function is used to check for a value in the Puppet Dashboard/Enterprise -Console, and failover to a default value like the following: - - $real_jenkins_version = pick($::jenkins_version, '1.449') - -The value of $real_jenkins_version will first look for a top-scope variable -called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ -Enterprise Console are brought into Puppet as top-scope variables), and, -failing that, will use a default value of 1.449. - -EOS -) do |args| - args = args.compact - args.delete(:undef) - args.delete(:undefined) - args.delete("") - if args[0].to_s.empty? then - fail Puppet::ParseError, "pick(): must receive at least one non empty value" - else - return args[0] - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick_default.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick_default.rb deleted file mode 100644 index 36e33abfa..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS - -This function is similar to a coalesce function in SQL in that it will return -the first value in a list of values that is not undefined or an empty string -(two things in Puppet that will return a boolean false value). If no value is -found, it will return the last argument. - -Typically, this function is used to check for a value in the Puppet -Dashboard/Enterprise Console, and failover to a default value like the -following: - - $real_jenkins_version = pick_default($::jenkins_version, '1.449') - -The value of $real_jenkins_version will first look for a top-scope variable -called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ -Enterprise Console are brought into Puppet as top-scope variables), and, -failing that, will use a default value of 1.449. - -Note that, contrary to the pick() function, the pick_default does not fail if -all arguments are empty. This allows pick_default to use an empty value as -default. - -EOS -) do |args| - fail "Must receive at least one argument." if args.empty? - default = args.last - args = args[0..-2].compact - args.delete(:undef) - args.delete(:undefined) - args.delete("") - args << default - return args[0] - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/prefix.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/prefix.rb deleted file mode 100644 index ac1c58a55..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/prefix.rb +++ /dev/null @@ -1,52 +0,0 @@ -# -# prefix.rb -# - -module Puppet::Parser::Functions - newfunction(:prefix, :type => :rvalue, :doc => <<-EOS -This function applies a prefix to all elements in an array or a hash. - -*Examples:* - - prefix(['a','b','c'], 'p') - -Will return: ['pa','pb','pc'] - EOS - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "prefix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - enumerable = arguments[0] - - unless enumerable.is_a?(Array) or enumerable.is_a?(Hash) - raise Puppet::ParseError, "prefix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}" - end - - prefix = arguments[1] if arguments[1] - - if prefix - unless prefix.is_a?(String) - raise Puppet::ParseError, "prefix(): expected second argument to be a String, got #{prefix.inspect}" - end - end - - if enumerable.is_a?(Array) - # Turn everything into string same as join would do ... - result = enumerable.collect do |i| - i = i.to_s - prefix ? prefix + i : i - end - else - result = Hash[enumerable.map do |k,v| - k = k.to_s - [ prefix ? prefix + k : k, v ] - end] - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/private.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/private.rb deleted file mode 100644 index 3b00ba12f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/private.rb +++ /dev/null @@ -1,17 +0,0 @@ -# -# private.rb -# - -module Puppet::Parser::Functions - newfunction(:private, :doc => <<-'EOS' - DEPRECATED: Sets the current class or definition as private. - Calling the class or definition from outside the current module will fail. - EOS - ) do |args| - warning("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") - if !Puppet::Parser::Functions.autoloader.loaded?(:assert_private) - Puppet::Parser::Functions.autoloader.load(:assert_private) - end - function_assert_private([(args[0] unless args.size < 1)]) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb deleted file mode 100644 index 41d42238d..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb +++ /dev/null @@ -1,56 +0,0 @@ -Puppet::Parser::Functions::newfunction( - :pw_hash, - :type => :rvalue, - :arity => 3, - :doc => "Hashes a password using the crypt function. Provides a hash - usable on most POSIX systems. - - The first argument to this function is the password to hash. If it is - undef or an empty string, this function returns undef. - - The second argument to this function is which type of hash to use. It - will be converted into the appropriate crypt(3) hash specifier. Valid - hash types are: - - |Hash type |Specifier| - |---------------------|---------| - |MD5 |1 | - |SHA-256 |5 | - |SHA-512 (recommended)|6 | - - The third argument to this function is the salt to use. - - Note: this uses the Puppet Master's implementation of crypt(3). If your - environment contains several different operating systems, ensure that they - are compatible before using this function.") do |args| - raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3 - raise ArgumentError, "pw_hash(): first argument must be a string" unless args[0].is_a? String or args[0].nil? - raise ArgumentError, "pw_hash(): second argument must be a string" unless args[1].is_a? String - hashes = { 'md5' => '1', - 'sha-256' => '5', - 'sha-512' => '6' } - hash_type = hashes[args[1].downcase] - raise ArgumentError, "pw_hash(): #{args[1]} is not a valid hash type" if hash_type.nil? - raise ArgumentError, "pw_hash(): third argument must be a string" unless args[2].is_a? String - raise ArgumentError, "pw_hash(): third argument must not be empty" if args[2].empty? - raise ArgumentError, "pw_hash(): characters in salt must be in the set [a-zA-Z0-9./]" unless args[2].match(/\A[a-zA-Z0-9.\/]+\z/) - - password = args[0] - return nil if password.nil? or password.empty? - - salt = "$#{hash_type}$#{args[2]}" - - # handle weak implementations of String#crypt - if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.' - # JRuby < 1.7.17 - if RUBY_PLATFORM == 'java' - # puppetserver bundles Apache Commons Codec - org.apache.commons.codec.digest.Crypt.crypt(password.to_java_bytes, salt) - else - # MS Windows and other systems that don't support enhanced salts - raise Puppet::ParseError, 'system does not support enhanced salts' - end - else - password.crypt(salt) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/range.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/range.rb deleted file mode 100644 index 2fc211329..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/range.rb +++ /dev/null @@ -1,87 +0,0 @@ -# -# range.rb -# - -# TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ... - -module Puppet::Parser::Functions - newfunction(:range, :type => :rvalue, :doc => <<-EOS -When given range in the form of (start, stop) it will extrapolate a range as -an array. - -*Examples:* - - range("0", "9") - -Will return: [0,1,2,3,4,5,6,7,8,9] - - range("00", "09") - -Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to -integers automatically) - - range("a", "c") - -Will return: ["a","b","c"] - - range("host01", "host10") - -Will return: ["host01", "host02", ..., "host09", "host10"] - -Passing a third argument will cause the generated range to step by that -interval, e.g. - - range("0", "9", "2") - -Will return: [0,2,4,6,8] - EOS - ) do |arguments| - - raise(Puppet::ParseError, 'range(): Wrong number of ' + - 'arguments given (0 for 1)') if arguments.size == 0 - - if arguments.size > 1 - start = arguments[0] - stop = arguments[1] - step = arguments[2].nil? ? 1 : arguments[2].to_i.abs - - type = '..' # Use the simplest type of Range available in Ruby - - else # arguments.size == 1 - value = arguments[0] - - if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/) - start = m[1] - stop = m[3] - - type = m[2] - step = 1 - elsif value.match(/^.+$/) - raise(Puppet::ParseError, "range(): Unable to compute range " + - "from the value: #{value}") - else - raise(Puppet::ParseError, "range(): Unknown range format: #{value}") - end - end - - # If we were given an integer, ensure we work with one - if start.to_s.match(/^\d+$/) - start = start.to_i - stop = stop.to_i - else - start = start.to_s - stop = stop.to_s - end - - range = case type - when /^(\.\.|\-)$/ then (start .. stop) - when '...' then (start ... stop) # Exclusive of last element - end - - result = range.step(step).to_a - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reject.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reject.rb deleted file mode 100644 index 1953ffcf1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reject.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# reject.rb -# - -module Puppet::Parser::Functions - newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args| -This function searches through an array and rejects all elements that match -the provided regular expression. - -*Examples:* - - reject(['aaa','bbb','ccc','aaaddd'], 'aaa') - -Would return: - - ['bbb','ccc'] -EOS - - if (args.size != 2) - raise Puppet::ParseError, - "reject(): Wrong number of arguments given #{args.size} for 2" - end - - ary = args[0] - pattern = Regexp.new(args[1]) - - ary.reject { |e| e =~ pattern } - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reverse.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reverse.rb deleted file mode 100644 index 7f1018f67..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/reverse.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# reverse.rb -# - -module Puppet::Parser::Functions - newfunction(:reverse, :type => :rvalue, :doc => <<-EOS -Reverses the order of a string or array. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "reverse(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'reverse(): Requires either ' + - 'array or string to work with') - end - - result = value.reverse - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/rstrip.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/rstrip.rb deleted file mode 100644 index 0cf8d222c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# rstrip.rb -# - -module Puppet::Parser::Functions - newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS -Strips leading spaces to the right of the string. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'rstrip(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - result = value.collect { |i| i.is_a?(String) ? i.rstrip : i } - else - result = value.rstrip - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb deleted file mode 100644 index 44e27b8dc..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb +++ /dev/null @@ -1,22 +0,0 @@ -Puppet::Parser::Functions::newfunction( - :seeded_rand, - :arity => 2, - :type => :rvalue, - :doc => <<-EOS -Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string. - -Generates a random whole number greater than or equal to 0 and less -than MAX, using the value of SEED for repeatable randomness. If SEED -starts with "$fqdn:", this is behaves the same as `fqdn_rand`. - -EOS -) do |args| - require 'digest/md5' - - raise(ArgumentError, "seeded_rand(): first argument must be a positive integer") unless function_is_integer([args[0]]) and args[0].to_i > 0 - raise(ArgumentError, "seeded_rand(): second argument must be a string") unless args[1].is_a? String - - max = args[0].to_i - seed = Digest::MD5.hexdigest(args[1]).hex - Puppet::Util.deterministic_rand(seed,max) -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/shuffle.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/shuffle.rb deleted file mode 100644 index 30c663dbe..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# shuffle.rb -# - -module Puppet::Parser::Functions - newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS -Randomizes the order of a string or array elements. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'shuffle(): Requires either ' + - 'array or string to work with') - end - - result = value.clone - - string = value.is_a?(String) ? true : false - - # Check whether it makes sense to shuffle ... - return result if result.size <= 1 - - # We turn any string value into an array to be able to shuffle ... - result = string ? result.split('') : result - - elements = result.size - - # Simple implementation of Fisher–Yates in-place shuffle ... - elements.times do |i| - j = rand(elements - i) + i - result[j], result[i] = result[i], result[j] - end - - result = string ? result.join : result - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/size.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/size.rb deleted file mode 100644 index 0d6cc9613..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/size.rb +++ /dev/null @@ -1,46 +0,0 @@ -# -# size.rb -# - -module Puppet::Parser::Functions - newfunction(:size, :type => :rvalue, :doc => <<-EOS -Returns the number of elements in a string, an array or a hash - EOS - ) do |arguments| - - raise(Puppet::ParseError, "size(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - item = arguments[0] - - if item.is_a?(String) - - begin - # - # Check whether your item is a numeric value or not ... - # This will take care about positive and/or negative numbers - # for both integer and floating-point values ... - # - # Please note that Puppet has no notion of hexadecimal - # nor octal numbers for its DSL at this point in time ... - # - Float(item) - - raise(Puppet::ParseError, 'size(): Requires either ' + - 'string, array or hash to work with') - - rescue ArgumentError - result = item.size - end - - elsif item.is_a?(Array) || item.is_a?(Hash) - result = item.size - else - raise(Puppet::ParseError, 'size(): Unknown type given') - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/sort.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/sort.rb deleted file mode 100644 index cefbe5463..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/sort.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# sort.rb -# - -module Puppet::Parser::Functions - newfunction(:sort, :type => :rvalue, :doc => <<-EOS -Sorts strings and arrays lexically. - EOS - ) do |arguments| - - if (arguments.size != 1) then - raise(Puppet::ParseError, "sort(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - - value = arguments[0] - - if value.is_a?(Array) then - value.sort - elsif value.is_a?(String) then - value.split("").sort.join("") - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/squeeze.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/squeeze.rb deleted file mode 100644 index 81fadfdb2..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# squeeze.rb -# - -module Puppet::Parser::Functions - newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS -Returns a new string where runs of the same character that occur in this set are replaced by a single character. - EOS - ) do |arguments| - - if ((arguments.size != 2) and (arguments.size != 1)) then - raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+ - "given #{arguments.size} for 2 or 1") - end - - item = arguments[0] - squeezeval = arguments[1] - - if item.is_a?(Array) then - if squeezeval then - item.collect { |i| i.squeeze(squeezeval) } - else - item.collect { |i| i.squeeze } - end - else - if squeezeval then - item.squeeze(squeezeval) - else - item.squeeze - end - end - - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2bool.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2bool.rb deleted file mode 100644 index 8def131e3..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +++ /dev/null @@ -1,46 +0,0 @@ -# -# str2bool.rb -# - -module Puppet::Parser::Functions - newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS -This converts a string to a boolean. This attempt to convert strings that -contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things -like: 0, F,f, N,n, false, FALSE, no to 'false'. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "str2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - string = arguments[0] - - # If string is already Boolean, return it - if !!string == string - return string - end - - unless string.is_a?(String) - raise(Puppet::ParseError, 'str2bool(): Requires either ' + - 'string to work with') - end - - # We consider all the yes, no, y, n and so on too ... - result = case string - # - # This is how undef looks like in Puppet ... - # We yield false in this case. - # - when /^$/, '' then false # Empty string will be false ... - when /^(1|t|y|true|yes)$/i then true - when /^(0|f|n|false|no)$/i then false - when /^(undef|undefined)$/ then false # This is not likely to happen ... - else - raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given') - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb deleted file mode 100644 index 7fe7b0128..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# str2saltedsha512.rb -# - -module Puppet::Parser::Functions - newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS -This converts a string to a salted-SHA512 password hash (which is used for -OS X versions >= 10.7). Given any simple string, you will get a hex version -of a salted-SHA512 password hash that can be inserted into your Puppet -manifests as a valid password attribute. - EOS - ) do |arguments| - require 'digest/sha2' - - raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " + - "passed (#{arguments.size} but we require 1)") if arguments.size != 1 - - password = arguments[0] - - unless password.is_a?(String) - raise(Puppet::ParseError, 'str2saltedsha512(): Requires a ' + - "String argument, you passed: #{password.class}") - end - - seedint = rand(2**31 - 1) - seedstring = Array(seedint).pack("L") - saltedpass = Digest::SHA512.digest(seedstring + password) - (seedstring + saltedpass).unpack('H*')[0] - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strftime.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strftime.rb deleted file mode 100644 index 0b52adecd..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strftime.rb +++ /dev/null @@ -1,107 +0,0 @@ -# -# strftime.rb -# - -module Puppet::Parser::Functions - newfunction(:strftime, :type => :rvalue, :doc => <<-EOS -This function returns formatted time. - -*Examples:* - -To return the time since epoch: - - strftime("%s") - -To return the date: - - strftime("%Y-%m-%d") - -*Format meaning:* - - %a - The abbreviated weekday name (``Sun'') - %A - The full weekday name (``Sunday'') - %b - The abbreviated month name (``Jan'') - %B - The full month name (``January'') - %c - The preferred local date and time representation - %C - Century (20 in 2009) - %d - Day of the month (01..31) - %D - Date (%m/%d/%y) - %e - Day of the month, blank-padded ( 1..31) - %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) - %h - Equivalent to %b - %H - Hour of the day, 24-hour clock (00..23) - %I - Hour of the day, 12-hour clock (01..12) - %j - Day of the year (001..366) - %k - hour, 24-hour clock, blank-padded ( 0..23) - %l - hour, 12-hour clock, blank-padded ( 0..12) - %L - Millisecond of the second (000..999) - %m - Month of the year (01..12) - %M - Minute of the hour (00..59) - %n - Newline (\n) - %N - Fractional seconds digits, default is 9 digits (nanosecond) - %3N millisecond (3 digits) - %6N microsecond (6 digits) - %9N nanosecond (9 digits) - %p - Meridian indicator (``AM'' or ``PM'') - %P - Meridian indicator (``am'' or ``pm'') - %r - time, 12-hour (same as %I:%M:%S %p) - %R - time, 24-hour (%H:%M) - %s - Number of seconds since 1970-01-01 00:00:00 UTC. - %S - Second of the minute (00..60) - %t - Tab character (\t) - %T - time, 24-hour (%H:%M:%S) - %u - Day of the week as a decimal, Monday being 1. (1..7) - %U - Week number of the current year, - starting with the first Sunday as the first - day of the first week (00..53) - %v - VMS date (%e-%b-%Y) - %V - Week number of year according to ISO 8601 (01..53) - %W - Week number of the current year, - starting with the first Monday as the first - day of the first week (00..53) - %w - Day of the week (Sunday is 0, 0..6) - %x - Preferred representation for the date alone, no time - %X - Preferred representation for the time alone, no date - %y - Year without a century (00..99) - %Y - Year with century - %z - Time zone as hour offset from UTC (e.g. +0900) - %Z - Time zone name - %% - Literal ``%'' character - EOS - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "strftime(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - format = arguments[0] - - raise(Puppet::ParseError, 'strftime(): You must provide ' + - 'format for evaluation') if format.empty? - - # The Time Zone argument is optional ... - time_zone = arguments[1] if arguments[1] - - time = Time.new - - # There is probably a better way to handle Time Zone ... - if time_zone and not time_zone.empty? - original_zone = ENV['TZ'] - - local_time = time.clone - local_time = local_time.utc - - ENV['TZ'] = time_zone - - time = local_time.localtime - - ENV['TZ'] = original_zone - end - - result = time.strftime(format) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strip.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strip.rb deleted file mode 100644 index 3fac47d53..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/strip.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# strip.rb -# - -module Puppet::Parser::Functions - newfunction(:strip, :type => :rvalue, :doc => <<-EOS -This function removes leading and trailing whitespace from a string or from -every string inside an array. - -*Examples:* - - strip(" aaa ") - -Would result in: "aaa" - EOS - ) do |arguments| - - raise(Puppet::ParseError, "strip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'strip(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - result = value.collect { |i| i.is_a?(String) ? i.strip : i } - else - result = value.strip - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/suffix.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/suffix.rb deleted file mode 100644 index 29084340c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/suffix.rb +++ /dev/null @@ -1,53 +0,0 @@ -# -# suffix.rb -# - -module Puppet::Parser::Functions - newfunction(:suffix, :type => :rvalue, :doc => <<-EOS -This function applies a suffix to all elements in an array, or to the keys -in a hash. - -*Examples:* - - suffix(['a','b','c'], 'p') - -Will return: ['ap','bp','cp'] - EOS - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "suffix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - enumerable = arguments[0] - - unless enumerable.is_a?(Array) or enumerable.is_a?(Hash) - raise Puppet::ParseError, "suffix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}" - end - - suffix = arguments[1] if arguments[1] - - if suffix - unless suffix.is_a? String - raise Puppet::ParseError, "suffix(): expected second argument to be a String, got #{suffix.inspect}" - end - end - - if enumerable.is_a?(Array) - # Turn everything into string same as join would do ... - result = enumerable.collect do |i| - i = i.to_s - suffix ? i + suffix : i - end - else - result = Hash[enumerable.map do |k,v| - k = k.to_s - [ suffix ? k + suffix : k, v ] - end] - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/swapcase.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/swapcase.rb deleted file mode 100644 index eb7fe137d..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# swapcase.rb -# - -module Puppet::Parser::Functions - newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS -This function will swap the existing case of a string. - -*Examples:* - - swapcase("aBcD") - -Would result in: "AbCd" - EOS - ) do |arguments| - - raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'swapcase(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.swapcase : i } - else - result = value.swapcase - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/time.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/time.rb deleted file mode 100644 index c5747474f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/time.rb +++ /dev/null @@ -1,50 +0,0 @@ -# -# time.rb -# - -module Puppet::Parser::Functions - newfunction(:time, :type => :rvalue, :doc => <<-EOS -This function will return the current time since epoch as an integer. - -*Examples:* - - time() - -Will return something like: 1311972653 - EOS - ) do |arguments| - - # The Time Zone argument is optional ... - time_zone = arguments[0] if arguments[0] - - if (arguments.size != 0) and (arguments.size != 1) then - raise(Puppet::ParseError, "time(): Wrong number of arguments "+ - "given #{arguments.size} for 0 or 1") - end - - time = Time.new - - # There is probably a better way to handle Time Zone ... - if time_zone and not time_zone.empty? - original_zone = ENV['TZ'] - - local_time = time.clone - local_time = local_time.utc - - ENV['TZ'] = time_zone - - result = local_time.localtime.strftime('%s') - - ENV['TZ'] = original_zone - else - result = time.localtime.strftime('%s') - end - - # Calling Time#to_i on a receiver changes it. Trust me I am the Doctor. - result = result.to_i - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb deleted file mode 100644 index df490ea8c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS - Converts the argument into bytes, for example 4 kB becomes 4096. - Takes a single string value as an argument. - These conversions reflect a layperson's understanding of - 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - arg = arguments[0] - - return arg if arg.is_a? Numeric - - value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(arg)[1,2] - - value = value.to_f - case prefix - when '' then return value.to_i - when 'k' then return (value*(1<<10)).to_i - when 'M' then return (value*(1<<20)).to_i - when 'G' then return (value*(1<<30)).to_i - when 'T' then return (value*(1<<40)).to_i - when 'P' then return (value*(1<<50)).to_i - when 'E' then return (value*(1<<60)).to_i - else raise Puppet::ParseError, "to_bytes(): Unknown prefix #{prefix}" - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb deleted file mode 100644 index fc19a230a..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb +++ /dev/null @@ -1,53 +0,0 @@ -module Puppet::Parser::Functions - newfunction( - :try_get_value, - :type => :rvalue, - :arity => -2, - :doc => <<-eos -DEPRECATED: this function is deprecated, please use dig() instead. - -Looks up into a complex structure of arrays and hashes and returns a value -or the default value if nothing was found. - -Key can contain slashes to describe path components. The function will go down -the structure and try to extract the required value. - -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = try_get_value($data, 'a/b/2', 'not_found', '/') -=> $value = 'b3' - -a -> first hash key -b -> second hash key -2 -> array index starting with 0 - -not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil. -/ -> (optional) path delimiter. Defaults to '/'. - -In addition to the required "key" argument, "try_get_value" accepts default -argument. It will be returned if no value was found or a path component is -missing. And the fourth argument can set a variable path separator. - eos - ) do |args| - warning("try_get_value() DEPRECATED: this function is deprecated, please use dig() instead.") - data = args[0] - path = args[1] || '' - default = args[2] - - if !(data.is_a?(Hash) || data.is_a?(Array)) || path == '' - return default || data - end - - separator = args[3] || '/' - path = path.split(separator).map{ |key| key =~ /^\d+$/ ? key.to_i : key } - function_dig([data, path, default]) - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type.rb deleted file mode 100644 index 016529b03..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type.rb +++ /dev/null @@ -1,19 +0,0 @@ -# -# type.rb -# - -module Puppet::Parser::Functions - newfunction(:type, :type => :rvalue, :doc => <<-EOS - DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. - EOS - ) do |args| - - warning("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") - if ! Puppet::Parser::Functions.autoloader.loaded?(:type3x) - Puppet::Parser::Functions.autoloader.load(:type3x) - end - function_type3x(args + [false]) - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type3x.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type3x.rb deleted file mode 100644 index 0800b4a3e..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/type3x.rb +++ /dev/null @@ -1,51 +0,0 @@ -# -# type3x.rb -# - -module Puppet::Parser::Functions - newfunction(:type3x, :type => :rvalue, :doc => <<-EOS -DEPRECATED: This function will be removed when puppet 3 support is dropped; please migrate to the new parser's typing system. - -Returns the type when passed a value. Type can be one of: - -* string -* array -* hash -* float -* integer -* boolean - EOS - ) do |args| - raise(Puppet::ParseError, "type3x(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size < 1 - - value = args[0] - - klass = value.class - - if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass) - raise(Puppet::ParseError, 'type3x(): Unknown type') - end - - klass = klass.to_s # Ugly ... - - # We note that Integer is the parent to Bignum and Fixnum ... - result = case klass - when /^(?:Big|Fix)num$/ then 'integer' - when /^(?:True|False)Class$/ then 'boolean' - else klass - end - - if result == "String" then - if value == value.to_i.to_s then - result = "Integer" - elsif value == value.to_f.to_s then - result = "Float" - end - end - - return result.downcase - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/union.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/union.rb deleted file mode 100644 index 6c5bb8348..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/union.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# union.rb -# - -module Puppet::Parser::Functions - newfunction(:union, :type => :rvalue, :doc => <<-EOS -This function returns a union of two or more arrays. - -*Examples:* - - union(["a","b","c"],["b","c","d"]) - -Would return: ["a","b","c","d"] - EOS - ) do |arguments| - - # Check that 2 or more arguments have been given ... - raise(Puppet::ParseError, "union(): Wrong number of arguments " + - "given (#{arguments.size} for < 2)") if arguments.size < 2 - - arguments.each do |argument| - raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array) - end - - arguments.reduce(:|) - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unique.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unique.rb deleted file mode 100644 index cf770f3b4..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unique.rb +++ /dev/null @@ -1,50 +0,0 @@ -# -# unique.rb -# - -module Puppet::Parser::Functions - newfunction(:unique, :type => :rvalue, :doc => <<-EOS -This function will remove duplicates from strings and arrays. - -*Examples:* - - unique("aabbcc") - -Will return: - - abc - -You can also use this with arrays: - - unique(["a","a","b","b","c","c"]) - -This returns: - - ["a","b","c"] - EOS - ) do |arguments| - - raise(Puppet::ParseError, "unique(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'unique(): Requires either ' + - 'array or string to work with') - end - - result = value.clone - - string = value.is_a?(String) ? true : false - - # We turn any string value into an array to be able to shuffle ... - result = string ? result.split('') : result - result = result.uniq # Remove duplicates ... - result = string ? result.join : result - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb deleted file mode 100644 index 0bd9cd1f1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Custom Puppet function to convert unix to dos format -module Puppet::Parser::Functions - newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-EOS - Returns the DOS version of the given string. - Takes a single string argument. - EOS - ) do |arguments| - - unless arguments[0].is_a?(String) - raise(Puppet::ParseError, 'unix2dos(): Requires string as argument') - end - - arguments[0].gsub(/\r*\n/, "\r\n") - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/upcase.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/upcase.rb deleted file mode 100644 index 44b3bcd6f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/upcase.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# upcase.rb -# - -module Puppet::Parser::Functions - newfunction(:upcase, :type => :rvalue, :doc => <<-EOS -Converts a string or an array of strings to uppercase. - -*Examples:* - - upcase("abcd") - -Will return: - - ABCD - EOS - ) do |arguments| - - raise(Puppet::ParseError, "upcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:upcase) - raise(Puppet::ParseError, 'upcase(): Requires an ' + - 'array, hash or object that responds to upcase in order to work') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| function_upcase([i]) } - elsif value.is_a?(Hash) - result = {} - value.each_pair do |k, v| - result[function_upcase([k])] = function_upcase([v]) - end - else - result = value.upcase - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/uriescape.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/uriescape.rb deleted file mode 100644 index 45bbed22c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# uriescape.rb -# -require 'uri' - -module Puppet::Parser::Functions - newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS - Urlencodes a string or array of strings. - Requires either a single string or an array as an input. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - value = arguments[0] - - unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'uriescape(): Requires either ' + - 'array or string to work with') - end - - if value.is_a?(Array) - # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? URI.escape(i) : i } - else - result = URI.escape(value) - end - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb deleted file mode 100644 index 5f85f72fe..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args| - Validate the string represents an absolute path in the filesystem. This function works - for windows and unix style paths. - - The following values will pass: - - $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' - validate_absolute_path($my_path) - $my_path2 = '/var/lib/puppet' - validate_absolute_path($my_path2) - $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] - validate_absolute_path($my_path3) - $my_path4 = ['/var/lib/puppet','/usr/share/puppet'] - validate_absolute_path($my_path4) - - The following values will fail, causing compilation to abort: - - validate_absolute_path(true) - validate_absolute_path('../var/lib/puppet') - validate_absolute_path('var/lib/puppet') - validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) - validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) - $undefined = undef - validate_absolute_path($undefined) - - ENDHEREDOC - - require 'puppet/util' - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_absolute_path(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - # put arg to candidate var to be able to replace it - candidates = arg - # if arg is just a string with a path to test, convert it to an array - # to avoid test code duplication - unless arg.is_a?(Array) then - candidates = Array.new(1,arg) - end - # iterate over all paths within the candidates array - candidates.each do |path| - unless function_is_absolute_path([path]) - raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.") - end - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_array.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_array.rb deleted file mode 100644 index 34b511825..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args| - Validate that all passed values are array data structures. Abort catalog - compilation if any value fails this check. - - The following values will pass: - - $my_array = [ 'one', 'two' ] - validate_array($my_array) - - The following values will fail, causing compilation to abort: - - validate_array(true) - validate_array('some_string') - $undefined = undef - validate_array($undefined) - - ENDHEREDOC - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(Array) - raise Puppet::ParseError, ("#{arg.inspect} is not an Array. It looks to be a #{arg.class}") - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb deleted file mode 100644 index 2196c3e0e..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'tempfile' - -module Puppet::Parser::Functions - newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args| - Perform validation of a string using an Augeas lens - The first argument of this function should be a string to - test, and the second argument should be the name of the Augeas lens to use. - If Augeas fails to parse the string with the lens, the compilation will - abort with a parse error. - - A third argument can be specified, listing paths which should - not be found in the file. The `$file` variable points to the location - of the temporary file being tested in the Augeas tree. - - For example, if you want to make sure your passwd content never contains - a user `foo`, you could write: - - validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) - - Or if you wanted to ensure that no users used the '/bin/barsh' shell, - you could use: - - validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] - - If a fourth argument is specified, this will be the error message raised and - seen by the user. - - A helpful error message can be returned like this: - - validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') - - ENDHEREDOC - unless Puppet.features.augeas? - raise Puppet::ParseError, ("validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.") - end - - if (args.length < 2) or (args.length > 4) then - raise Puppet::ParseError, ("validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)") - end - - msg = args[3] || "validate_augeas(): Failed to validate content against #{args[1].inspect}" - - require 'augeas' - aug = Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD) - begin - content = args[0] - - # Test content in a temporary file - tmpfile = Tempfile.new("validate_augeas") - begin - tmpfile.write(content) - ensure - tmpfile.close - end - - # Check for syntax - lens = args[1] - aug.transform( - :lens => lens, - :name => 'Validate_augeas', - :incl => tmpfile.path - ) - aug.load! - - unless aug.match("/augeas/files#{tmpfile.path}//error").empty? - error = aug.get("/augeas/files#{tmpfile.path}//error/message") - msg += " with error: #{error}" - raise Puppet::ParseError, (msg) - end - - # Launch unit tests - tests = args[2] || [] - aug.defvar('file', "/files#{tmpfile.path}") - tests.each do |t| - msg += " testing path #{t}" - raise Puppet::ParseError, (msg) unless aug.match(t).empty? - end - ensure - aug.close - tmpfile.unlink - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb deleted file mode 100644 index 59a08056b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args| - Validate that all passed values are either true or false. Abort catalog - compilation if any value fails this check. - - The following values will pass: - - $iamtrue = true - validate_bool(true) - validate_bool(true, true, false, $iamtrue) - - The following values will fail, causing compilation to abort: - - $some_array = [ true ] - validate_bool("false") - validate_bool("true") - validate_bool($some_array) - - ENDHEREDOC - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless function_is_bool([arg]) - raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}") - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb deleted file mode 100644 index 685162b0c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'puppet/util/execution' -require 'tempfile' - -module Puppet::Parser::Functions - newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args| - Perform validation of a string with an external command. - The first argument of this function should be a string to - test, and the second argument should be a path to a test command - taking a % as a placeholder for the file path (will default to the end). - If the command, launched against a tempfile containing the passed string, - returns a non-null value, compilation will abort with a parse error. - - If a third argument is specified, this will be the error message raised and - seen by the user. - - A helpful error message can be returned like this: - - Example: - - # Defaults to end of path - validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') - - # % as file location - validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') - - ENDHEREDOC - if (args.length < 2) or (args.length > 3) then - raise Puppet::ParseError, ("validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)") - end - - msg = args[2] || "validate_cmd(): failed to validate content with command #{args[1].inspect}" - - content = args[0] - checkscript = args[1] - - # Test content in a temporary file - tmpfile = Tempfile.new("validate_cmd") - begin - tmpfile.write(content) - tmpfile.close - - if checkscript =~ /\s%(\s|$)/ - check_with_correct_location = checkscript.gsub(/%/,tmpfile.path) - else - check_with_correct_location = "#{checkscript} #{tmpfile.path}" - end - - if Puppet::Util::Execution.respond_to?('execute') - Puppet::Util::Execution.execute(check_with_correct_location) - else - Puppet::Util.execute(check_with_correct_location) - end - rescue Puppet::ExecutionFailure => detail - msg += "\n#{detail}" - raise Puppet::ParseError, msg - rescue StandardError => detail - msg += "\n#{detail.class.name} #{detail}" - raise Puppet::ParseError, msg - ensure - tmpfile.unlink - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb deleted file mode 100644 index 63f59a7d3..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:validate_email_address, doc: <<-ENDHEREDOC - Validate that all values passed are valid email addresses. - Fail compilation if any value fails this check. - The following values will pass: - $my_email = "waldo@gmail.com" - validate_email_address($my_email) - validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) - - The following values will fail, causing compilation to abort: - $some_array = [ 'bad_email@/d/efdf.com' ] - validate_email_address($some_array) - ENDHEREDOC - ) do |args| - rescuable_exceptions = [ArgumentError] - - if args.empty? - raise Puppet::ParseError, "validate_email_address(): wrong number of arguments (#{args.length}; must be > 0)" - end - - args.each do |arg| - raise Puppet::ParseError, "#{arg.inspect} is not a string." unless arg.is_a?(String) - - begin - raise Puppet::ParseError, "#{arg.inspect} is not a valid email address" unless function_is_email_address([arg]) - rescue *rescuable_exceptions - raise Puppet::ParseError, "#{arg.inspect} is not a valid email address" - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb deleted file mode 100644 index 9bdd54328..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args| - Validate that all passed values are hash data structures. Abort catalog - compilation if any value fails this check. - - The following values will pass: - - $my_hash = { 'one' => 'two' } - validate_hash($my_hash) - - The following values will fail, causing compilation to abort: - - validate_hash(true) - validate_hash('some_string') - $undefined = undef - validate_hash($undefined) - - ENDHEREDOC - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(Hash) - raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}") - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb deleted file mode 100644 index a950916b1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb +++ /dev/null @@ -1,132 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_integer, :doc => <<-'ENDHEREDOC') do |args| - Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. - - The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. - If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check - if (all elements of) the first argument are greater or equal to the given minimum. - - It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer. - - The following values will pass: - - validate_integer(1) - validate_integer(1, 2) - validate_integer(1, 1) - validate_integer(1, 2, 0) - validate_integer(2, 2, 2) - validate_integer(2, '', 0) - validate_integer(2, undef, 0) - $foo = undef - validate_integer(2, $foo, 0) - validate_integer([1,2,3,4,5], 6) - validate_integer([1,2,3,4,5], 6, 0) - - Plus all of the above, but any combination of values passed as strings ('1' or "1"). - Plus all of the above, but with (correct) combinations of negative integer values. - - The following values will not: - - validate_integer(true) - validate_integer(false) - validate_integer(7.0) - validate_integer({ 1 => 2 }) - $foo = undef - validate_integer($foo) - validate_integer($foobaridontexist) - - validate_integer(1, 0) - validate_integer(1, true) - validate_integer(1, '') - validate_integer(1, undef) - validate_integer(1, , 0) - validate_integer(1, 2, 3) - validate_integer(1, 3, 2) - validate_integer(1, 3, true) - - Plus all of the above, but any combination of values passed as strings ('false' or "false"). - Plus all of the above, but with incorrect combinations of negative integer values. - Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. - - ENDHEREDOC - - # tell the user we need at least one, and optionally up to two other parameters - raise Puppet::ParseError, "validate_integer(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4 - - input, max, min = *args - - # check maximum parameter - if args.length > 1 - max = max.to_s - # allow max to be empty (or undefined) if we have a minimum set - if args.length > 2 and max == '' - max = nil - else - begin - max = Integer(max) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_integer(): Expected second argument to be unset or an Integer, got #{max}:#{max.class}" - end - end - else - max = nil - end - - # check minimum parameter - if args.length > 2 - begin - min = Integer(min.to_s) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_integer(): Expected third argument to be unset or an Integer, got #{min}:#{min.class}" - end - else - min = nil - end - - # ensure that min < max - if min and max and min > max - raise Puppet::ParseError, "validate_integer(): Expected second argument to be larger than third argument, got #{max} < #{min}" - end - - # create lamba validator function - validator = lambda do |num| - # check input < max - if max and num > max - raise Puppet::ParseError, "validate_integer(): Expected #{input.inspect} to be smaller or equal to #{max}, got #{input.inspect}." - end - # check input > min (this will only be checked if no exception has been raised before) - if min and num < min - raise Puppet::ParseError, "validate_integer(): Expected #{input.inspect} to be greater or equal to #{min}, got #{input.inspect}." - end - end - - # if this is an array, handle it. - case input - when Array - # check every element of the array - input.each_with_index do |arg, pos| - begin - raise TypeError if arg.is_a?(Hash) - arg = Integer(arg.to_s) - validator.call(arg) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_integer(): Expected element at array position #{pos} to be an Integer, got #{arg.class}" - end - end - # for the sake of compatibility with ruby 1.8, we need extra handling of hashes - when Hash - raise Puppet::ParseError, "validate_integer(): Expected first argument to be an Integer or Array, got #{input.class}" - # check the input. this will also fail any stuff other than pure, shiny integers - else - begin - input = Integer(input.to_s) - validator.call(input) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_integer(): Expected first argument to be an Integer or Array, got #{input.class}" - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb deleted file mode 100644 index 64fbd75a7..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb +++ /dev/null @@ -1,50 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_ip_address, :doc => <<-ENDHEREDOC - Validate that all values passed are valid IP addresses, - regardless they are IPv4 or IPv6 - Fail compilation if any value fails this check. - The following values will pass: - $my_ip = "1.2.3.4" - validate_ip_address($my_ip) - validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip) - - $my_ip = "3ffe:505:2" - validate_ip_address(1) - validate_ip_address($my_ip) - validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip) - - The following values will fail, causing compilation to abort: - $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] - validate_ip_address($some_array) - ENDHEREDOC - ) do |args| - - require "ipaddr" - rescuable_exceptions = [ ArgumentError ] - - if defined?(IPAddr::InvalidAddressError) - rescuable_exceptions << IPAddr::InvalidAddressError - end - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_ip_address(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(String) - raise Puppet::ParseError, "#{arg.inspect} is not a string." - end - - begin - unless IPAddr.new(arg).ipv4? or IPAddr.new(arg).ipv6? - raise Puppet::ParseError, "#{arg.inspect} is not a valid IP address." - end - rescue *rescuable_exceptions - raise Puppet::ParseError, "#{arg.inspect} is not a valid IP address." - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb deleted file mode 100644 index 97faa5729..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_ipv4_address, :doc => <<-ENDHEREDOC - Validate that all values passed are valid IPv4 addresses. - Fail compilation if any value fails this check. - - The following values will pass: - - $my_ip = "1.2.3.4" - validate_ipv4_address($my_ip) - validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip) - - The following values will fail, causing compilation to abort: - - $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] - validate_ipv4_address($some_array) - - ENDHEREDOC - ) do |args| - - require "ipaddr" - rescuable_exceptions = [ ArgumentError ] - - if defined?(IPAddr::InvalidAddressError) - rescuable_exceptions << IPAddr::InvalidAddressError - end - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_ipv4_address(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(String) - raise Puppet::ParseError, "#{arg.inspect} is not a string." - end - - begin - unless IPAddr.new(arg).ipv4? - raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv4 address." - end - rescue *rescuable_exceptions - raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv4 address." - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb deleted file mode 100644 index b0f2558df..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_ipv6_address, :doc => <<-ENDHEREDOC - Validate that all values passed are valid IPv6 addresses. - Fail compilation if any value fails this check. - - The following values will pass: - - $my_ip = "3ffe:505:2" - validate_ipv6_address(1) - validate_ipv6_address($my_ip) - validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip) - - The following values will fail, causing compilation to abort: - - $some_array = [ true, false, "garbage string", "1.2.3.4" ] - validate_ipv6_address($some_array) - - ENDHEREDOC - ) do |args| - - require "ipaddr" - rescuable_exceptions = [ ArgumentError ] - - if defined?(IPAddr::InvalidAddressError) - rescuable_exceptions << IPAddr::InvalidAddressError - end - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_ipv6_address(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(String) - raise Puppet::ParseError, "#{arg.inspect} is not a string." - end - - begin - unless IPAddr.new(arg).ipv6? - raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv6 address." - end - rescue *rescuable_exceptions - raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv6 address." - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb deleted file mode 100644 index 3a144434b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb +++ /dev/null @@ -1,94 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_numeric, :doc => <<-'ENDHEREDOC') do |args| - Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. - - The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. - If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check - if (all elements of) the first argument are greater or equal to the given minimum. - - It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric. - - For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. - - ENDHEREDOC - - # tell the user we need at least one, and optionally up to two other parameters - raise Puppet::ParseError, "validate_numeric(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4 - - input, max, min = *args - - # check maximum parameter - if args.length > 1 - max = max.to_s - # allow max to be empty (or undefined) if we have a minimum set - if args.length > 2 and max == '' - max = nil - else - begin - max = Float(max) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_numeric(): Expected second argument to be unset or a Numeric, got #{max}:#{max.class}" - end - end - else - max = nil - end - - # check minimum parameter - if args.length > 2 - begin - min = Float(min.to_s) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_numeric(): Expected third argument to be unset or a Numeric, got #{min}:#{min.class}" - end - else - min = nil - end - - # ensure that min < max - if min and max and min > max - raise Puppet::ParseError, "validate_numeric(): Expected second argument to be larger than third argument, got #{max} < #{min}" - end - - # create lamba validator function - validator = lambda do |num| - # check input < max - if max and num > max - raise Puppet::ParseError, "validate_numeric(): Expected #{input.inspect} to be smaller or equal to #{max}, got #{input.inspect}." - end - # check input > min (this will only be checked if no exception has been raised before) - if min and num < min - raise Puppet::ParseError, "validate_numeric(): Expected #{input.inspect} to be greater or equal to #{min}, got #{input.inspect}." - end - end - - # if this is an array, handle it. - case input - when Array - # check every element of the array - input.each_with_index do |arg, pos| - begin - raise TypeError if arg.is_a?(Hash) - arg = Float(arg.to_s) - validator.call(arg) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_numeric(): Expected element at array position #{pos} to be a Numeric, got #{arg.class}" - end - end - # for the sake of compatibility with ruby 1.8, we need extra handling of hashes - when Hash - raise Puppet::ParseError, "validate_integer(): Expected first argument to be a Numeric or Array, got #{input.class}" - # check the input. this will also fail any stuff other than pure, shiny integers - else - begin - input = Float(input.to_s) - validator.call(input) - rescue TypeError, ArgumentError - raise Puppet::ParseError, "validate_numeric(): Expected first argument to be a Numeric or Array, got #{input.class}" - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_re.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_re.rb deleted file mode 100644 index efee7f8cb..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args| - Perform simple validation of a string against one or more regular - expressions. The first argument of this function should be a string to - test, and the second argument should be a stringified regular expression - (without the // delimiters) or an array of regular expressions. If none - of the regular expressions match the string passed in, compilation will - abort with a parse error. - - If a third argument is specified, this will be the error message raised and - seen by the user. - - The following strings will validate against the regular expressions: - - validate_re('one', '^one$') - validate_re('one', [ '^one', '^two' ]) - - The following strings will fail to validate, causing compilation to abort: - - validate_re('one', [ '^two', '^three' ]) - - A helpful error message can be returned like this: - - validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') - - Note: Compilation will also abort, if the first argument is not a String. Always use - quotes to force stringification: - - validate_re("${::operatingsystemmajrelease}", '^[57]$') - - ENDHEREDOC - if (args.length < 2) or (args.length > 3) then - raise Puppet::ParseError, "validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)" - end - - raise Puppet::ParseError, "validate_re(): input needs to be a String, not a #{args[0].class}" unless args[0].is_a? String - - msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}" - - # We're using a flattened array here because we can't call String#any? in - # Ruby 1.9 like we can in Ruby 1.8 - raise Puppet::ParseError, msg unless [args[1]].flatten.any? do |re_str| - args[0] =~ Regexp.compile(re_str) - end - - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb deleted file mode 100644 index 47c7d4a6c..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +++ /dev/null @@ -1,69 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args| - Validate that the first argument is a string (or an array of strings), and - less/equal to than the length of the second argument. An optional third - parameter can be given the minimum length. It fails if the first - argument is not a string or array of strings, and if arg 2 and arg 3 are - not convertable to a number. - - The following values will pass: - - validate_slength("discombobulate",17) - validate_slength(["discombobulate","moo"],17) - validate_slength(["discombobulate","moo"],17,3) - - The following valueis will not: - - validate_slength("discombobulate",1) - validate_slength(["discombobulate","thermometer"],5) - validate_slength(["discombobulate","moo"],17,10) - - ENDHEREDOC - - raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3 - - input, max_length, min_length = *args - - begin - max_length = Integer(max_length) - raise ArgumentError if max_length <= 0 - rescue ArgumentError, TypeError - raise Puppet::ParseError, "validate_slength(): Expected second argument to be a positive Numeric, got #{max_length}:#{max_length.class}" - end - - if min_length - begin - min_length = Integer(min_length) - raise ArgumentError if min_length < 0 - rescue ArgumentError, TypeError - raise Puppet::ParseError, "validate_slength(): Expected third argument to be unset or a positive Numeric, got #{min_length}:#{min_length.class}" - end - else - min_length = 0 - end - - raise Puppet::ParseError, "validate_slength(): Expected second argument to be equal to or larger than third argument" unless max_length >= min_length - - validator = lambda do |str| - unless str.length <= max_length and str.length >= min_length - raise Puppet::ParseError, "validate_slength(): Expected length of #{input.inspect} to be between #{min_length} and #{max_length}, was #{input.length}" - end - end - - case input - when String - validator.call(input) - when Array - input.each_with_index do |arg, pos| - if arg.is_a? String - validator.call(arg) - else - raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got #{arg.class}" - end - end - else - raise Puppet::ParseError, "validate_slength(): Expected first argument to be a String or Array, got #{input.class}" - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_string.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_string.rb deleted file mode 100644 index c841f6abb..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args| - Validate that all passed values are string data structures. Abort catalog - compilation if any value fails this check. - - The following values will pass: - - $my_string = "one two" - validate_string($my_string, 'three') - - The following values will fail, causing compilation to abort: - - validate_string(true) - validate_string([ 'some', 'array' ]) - - Note: validate_string(undef) will not fail in this version of the - functions API (incl. current and future parser). Instead, use: - - if $var == undef { - fail('...') - } - - ENDHEREDOC - - unless args.length > 0 then - raise Puppet::ParseError, ("validate_string(): wrong number of arguments (#{args.length}; must be > 0)") - end - - args.each do |arg| - unless arg.is_a?(String) - raise Puppet::ParseError, ("#{arg.inspect} is not a string. It looks to be a #{arg.class}") - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb deleted file mode 100644 index fc9f23ff1..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Puppet::Parser::Functions - - newfunction(:validate_x509_rsa_key_pair, :doc => <<-ENDHEREDOC - Validates a PEM-formatted X.509 certificate and RSA private key using - OpenSSL. Verifies that the certficate's signature was created from the - supplied key. - - Fail compilation if any value fails this check. - - validate_x509_rsa_key_pair($cert, $key) - - ENDHEREDOC - ) do |args| - - require 'openssl' - - NUM_ARGS = 2 unless defined? NUM_ARGS - - unless args.length == NUM_ARGS then - raise Puppet::ParseError, - ("validate_x509_rsa_key_pair(): wrong number of arguments (#{args.length}; must be #{NUM_ARGS})") - end - - args.each do |arg| - unless arg.is_a?(String) - raise Puppet::ParseError, "#{arg.inspect} is not a string." - end - end - - begin - cert = OpenSSL::X509::Certificate.new(args[0]) - rescue OpenSSL::X509::CertificateError => e - raise Puppet::ParseError, "Not a valid x509 certificate: #{e}" - end - - begin - key = OpenSSL::PKey::RSA.new(args[1]) - rescue OpenSSL::PKey::RSAError => e - raise Puppet::ParseError, "Not a valid RSA key: #{e}" - end - - unless cert.verify(key) - raise Puppet::ParseError, "Certificate signature does not match supplied key" - end - end - -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values.rb deleted file mode 100644 index 16067561b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# values.rb -# - -module Puppet::Parser::Functions - newfunction(:values, :type => :rvalue, :doc => <<-EOS -When given a hash this function will return the values of that hash. - -*Examples:* - - $hash = { - 'a' => 1, - 'b' => 2, - 'c' => 3, - } - values($hash) - -This example would return: - - [1,2,3] - EOS - ) do |arguments| - - raise(Puppet::ParseError, "values(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - - hash = arguments[0] - - unless hash.is_a?(Hash) - raise(Puppet::ParseError, 'values(): Requires hash to work with') - end - - result = hash.values - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values_at.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values_at.rb deleted file mode 100644 index f350f5391..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/values_at.rb +++ /dev/null @@ -1,99 +0,0 @@ -# -# values_at.rb -# - -module Puppet::Parser::Functions - newfunction(:values_at, :type => :rvalue, :doc => <<-EOS -Finds value inside an array based on location. - -The first argument is the array you want to analyze, and the second element can -be a combination of: - -* A single numeric index -* A range in the form of 'start-stop' (eg. 4-9) -* An array combining the above - -*Examples*: - - values_at(['a','b','c'], 2) - -Would return ['c']. - - values_at(['a','b','c'], ["0-1"]) - -Would return ['a','b']. - - values_at(['a','b','c','d','e'], [0, "2-3"]) - -Would return ['a','c','d']. - EOS - ) do |arguments| - - raise(Puppet::ParseError, "values_at(): Wrong number of " + - "arguments given (#{arguments.size} for 2)") if arguments.size < 2 - - array = arguments.shift - - unless array.is_a?(Array) - raise(Puppet::ParseError, 'values_at(): Requires array to work with') - end - - indices = [arguments.shift].flatten() # Get them all ... Pokemon ... - - if not indices or indices.empty? - raise(Puppet::ParseError, 'values_at(): You must provide ' + - 'at least one positive index to collect') - end - - result = [] - indices_list = [] - - indices.each do |i| - i = i.to_s - if m = i.match(/^(\d+)(\.\.\.?|\-)(\d+)$/) - start = m[1].to_i - stop = m[3].to_i - - type = m[2] - - if start > stop - raise(Puppet::ParseError, 'values_at(): Stop index in ' + - 'given indices range is smaller than the start index') - elsif stop > array.size - 1 # First element is at index 0 is it not? - raise(Puppet::ParseError, 'values_at(): Stop index in ' + - 'given indices range exceeds array size') - end - - range = case type - when /^(\.\.|\-)$/ then (start .. stop) - when /^(\.\.\.)$/ then (start ... stop) # Exclusive of last element ... - end - - range.each { |i| indices_list << i.to_i } - else - # Only positive numbers allowed in this case ... - if not i.match(/^\d+$/) - raise(Puppet::ParseError, 'values_at(): Unknown format ' + - 'of given index') - end - - # In Puppet numbers are often string-encoded ... - i = i.to_i - - if i > array.size - 1 # Same story. First element is at index 0 ... - raise(Puppet::ParseError, 'values_at(): Given index ' + - 'exceeds array size') - end - - indices_list << i - end - end - - # We remove nil values as they make no sense in Puppet DSL ... - result = indices_list.collect { |i| array[i] }.compact - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/zip.rb b/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/zip.rb deleted file mode 100644 index 3074f282b..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/parser/functions/zip.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# zip.rb -# - -module Puppet::Parser::Functions - newfunction(:zip, :type => :rvalue, :doc => <<-EOS -Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments. - -*Example:* - - zip(['1','2','3'],['4','5','6']) - -Would result in: - - ["1", "4"], ["2", "5"], ["3", "6"] - EOS - ) do |arguments| - - # Technically we support three arguments but only first is mandatory ... - raise(Puppet::ParseError, "zip(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - - a = arguments[0] - b = arguments[1] - - unless a.is_a?(Array) and b.is_a?(Array) - raise(Puppet::ParseError, 'zip(): Requires array to work with') - end - - flatten = function_str2bool([arguments[2]]) if arguments[2] - - result = a.zip(b) - result = flatten ? result.flatten : result - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/provider/file_line/ruby.rb b/vagrant/puppet/modules/stdlib/lib/puppet/provider/file_line/ruby.rb deleted file mode 100644 index aab6fe289..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +++ /dev/null @@ -1,128 +0,0 @@ -Puppet::Type.type(:file_line).provide(:ruby) do - def exists? - if resource[:replace].to_s != 'true' and count_matches(match_regex) > 0 - true - else - lines.find do |line| - line.chomp == resource[:line].chomp - end - end - end - - def create - unless resource[:replace].to_s != 'true' and count_matches(match_regex) > 0 - if resource[:match] - handle_create_with_match - elsif resource[:after] - handle_create_with_after - else - append_line - end - end - end - - def destroy - if resource[:match_for_absence].to_s == 'true' and resource[:match] - handle_destroy_with_match - else - handle_destroy_line - end - end - - private - def lines - # If this type is ever used with very large files, we should - # write this in a different way, using a temp - # file; for now assuming that this type is only used on - # small-ish config files that can fit into memory without - # too much trouble. - @lines ||= File.readlines(resource[:path]) - end - - def match_regex - resource[:match] ? Regexp.new(resource[:match]) : nil - end - - def handle_create_with_match() - regex_after = resource[:after] ? Regexp.new(resource[:after]) : nil - match_count = count_matches(match_regex) - - if match_count > 1 && resource[:multiple].to_s != 'true' - raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'" - end - - File.open(resource[:path], 'w') do |fh| - lines.each do |l| - fh.puts(match_regex.match(l) ? resource[:line] : l) - if (match_count == 0 and regex_after) - if regex_after.match(l) - fh.puts(resource[:line]) - match_count += 1 #Increment match_count to indicate that the new line has been inserted. - end - end - end - - if (match_count == 0) - fh.puts(resource[:line]) - end - end - end - - def handle_create_with_after - regex = Regexp.new(resource[:after]) - count = count_matches(regex) - - if count > 1 && resource[:multiple].to_s != 'true' - raise Puppet::Error, "#{count} lines match pattern '#{resource[:after]}' in file '#{resource[:path]}'. One or no line must match the pattern." - end - - File.open(resource[:path], 'w') do |fh| - lines.each do |l| - fh.puts(l) - if regex.match(l) then - fh.puts(resource[:line]) - end - end - end - - if (count == 0) # append the line to the end of the file - append_line - end - end - - def count_matches(regex) - lines.select{|l| l.match(regex)}.size - end - - def handle_destroy_with_match - match_count = count_matches(match_regex) - if match_count > 1 && resource[:multiple].to_s != 'true' - raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'" - end - - local_lines = lines - File.open(resource[:path],'w') do |fh| - fh.write(local_lines.reject{|l| match_regex.match(l) }.join('')) - end - end - - def handle_destroy_line - local_lines = lines - File.open(resource[:path],'w') do |fh| - fh.write(local_lines.reject{|l| l.chomp == resource[:line] }.join('')) - end - end - - ## - # append the line to the file. - # - # @api private - def append_line - File.open(resource[:path], 'w') do |fh| - lines.each do |l| - fh.puts(l) - end - fh.puts resource[:line] - end - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/type/anchor.rb b/vagrant/puppet/modules/stdlib/lib/puppet/type/anchor.rb deleted file mode 100644 index fe1e5aa19..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/type/anchor.rb +++ /dev/null @@ -1,46 +0,0 @@ -Puppet::Type.newtype(:anchor) do - desc <<-'ENDOFDESC' - A simple resource type intended to be used as an anchor in a composite class. - - In Puppet 2.6, when a class declares another class, the resources in the - interior class are not contained by the exterior class. This interacts badly - with the pattern of composing complex modules from smaller classes, as it - makes it impossible for end users to specify order relationships between the - exterior class and other modules. - - The anchor type lets you work around this. By sandwiching any interior - classes between two no-op resources that _are_ contained by the exterior - class, you can ensure that all resources in the module are contained. - - class ntp { - # These classes will have the correct order relationship with each - # other. However, without anchors, they won't have any order - # relationship to Class['ntp']. - class { 'ntp::package': } - -> class { 'ntp::config': } - -> class { 'ntp::service': } - - # These two resources "anchor" the composed classes within the ntp - # class. - anchor { 'ntp::begin': } -> Class['ntp::package'] - Class['ntp::service'] -> anchor { 'ntp::end': } - } - - This allows the end user of the ntp module to establish require and before - relationships with Class['ntp']: - - class { 'ntp': } -> class { 'mcollective': } - class { 'mcollective': } -> class { 'ntp': } - - ENDOFDESC - - newparam :name do - desc "The name of the anchor resource." - end - - def refresh - # We don't do anything with them, but we need this to - # show that we are "refresh aware" and not break the - # chain of propagation. - end -end diff --git a/vagrant/puppet/modules/stdlib/lib/puppet/type/file_line.rb b/vagrant/puppet/modules/stdlib/lib/puppet/type/file_line.rb deleted file mode 100644 index f2c69379f..000000000 --- a/vagrant/puppet/modules/stdlib/lib/puppet/type/file_line.rb +++ /dev/null @@ -1,123 +0,0 @@ -Puppet::Type.newtype(:file_line) do - - desc <<-EOT - Ensures that a given line is contained within a file. The implementation - matches the full line, including whitespace at the beginning and end. If - the line is not contained in the given file, Puppet will append the line to - the end of the file to ensure the desired state. Multiple resources may - be declared to manage multiple lines in the same file. - - Example: - - file_line { 'sudo_rule': - path => '/etc/sudoers', - line => '%sudo ALL=(ALL) ALL', - } - - file_line { 'sudo_rule_nopw': - path => '/etc/sudoers', - line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', - } - - In this example, Puppet will ensure both of the specified lines are - contained in the file /etc/sudoers. - - Match Example: - - file_line { 'bashrc_proxy': - ensure => present, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - } - - In this code example match will look for a line beginning with export - followed by HTTP_PROXY and replace it with the value in line. - - Match Example With `ensure => absent`: - - file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - match_for_absence => true, - } - - In this code example match will look for a line beginning with export - followed by HTTP_PROXY and delete it. If multiple lines match, an - error will be raised unless the `multiple => true` parameter is set. - - **Autorequires:** If Puppet is managing the file that will contain the line - being managed, the file_line resource will autorequire that file. - EOT - - ensurable do - defaultvalues - defaultto :present - end - - newparam(:name, :namevar => true) do - desc 'An arbitrary name used as the identity of the resource.' - end - - newparam(:match) do - desc 'An optional ruby regular expression to run against existing lines in the file.' + - ' If a match is found, we replace that line rather than adding a new line.' + - ' A regex comparison is performed against the line value and if it does not' + - ' match an exception will be raised.' - end - - newparam(:match_for_absence) do - desc 'An optional value to determine if match should be applied when ensure => absent.' + - ' If set to true and match is set, the line that matches match will be deleted.' + - ' If set to false (the default), match is ignored when ensure => absent.' - newvalues(true, false) - defaultto false - end - - newparam(:multiple) do - desc 'An optional value to determine if match can change multiple lines.' + - ' If set to false, an exception will be raised if more than one line matches' - newvalues(true, false) - end - - newparam(:after) do - desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' - end - - newparam(:line) do - desc 'The line to be appended to the file or used to replace matches found by the match attribute.' - end - - newparam(:path) do - desc 'The file Puppet will ensure contains the line specified by the line parameter.' - validate do |value| - unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/)) - raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'") - end - end - end - - newparam(:replace) do - desc 'If true, replace line that matches. If false, do not write line if a match is found' - newvalues(true, false) - defaultto true - end - - # Autorequire the file resource if it's being managed - autorequire(:file) do - self[:path] - end - - validate do - unless self[:line] - unless (self[:ensure].to_s == 'absent') and (self[:match_for_absence].to_s == 'true') and self[:match] - raise(Puppet::Error, "line is a required attribute") - end - end - unless self[:path] - raise(Puppet::Error, "path is a required attribute") - end - end -end diff --git a/vagrant/puppet/modules/stdlib/manifests/init.pp b/vagrant/puppet/modules/stdlib/manifests/init.pp deleted file mode 100644 index 9ea22a737..000000000 --- a/vagrant/puppet/modules/stdlib/manifests/init.pp +++ /dev/null @@ -1,18 +0,0 @@ -# Class: stdlib -# -# This module manages stdlib. Most of stdlib's features are automatically -# loaded by Puppet, but this class should be declared in order to use the -# standardized run stages. -# -# Parameters: none -# -# Actions: -# -# Declares all other classes in the stdlib module. Currently, this consists -# of stdlib::stages. -# -# Requires: nothing -# -class stdlib { - include ::stdlib::stages -} diff --git a/vagrant/puppet/modules/stdlib/manifests/stages.pp b/vagrant/puppet/modules/stdlib/manifests/stages.pp deleted file mode 100644 index 7de254c71..000000000 --- a/vagrant/puppet/modules/stdlib/manifests/stages.pp +++ /dev/null @@ -1,43 +0,0 @@ -# Class: stdlib::stages -# -# This class manages a standard set of run stages for Puppet. It is managed by -# the stdlib class, and should not be declared independently. -# -# The high level stages are (in order): -# -# * setup -# * main -# * runtime -# * setup_infra -# * deploy_infra -# * setup_app -# * deploy_app -# * deploy -# -# Parameters: none -# -# Actions: -# -# Declares various run-stages for deploying infrastructure, -# language runtimes, and application layers. -# -# Requires: nothing -# -# Sample Usage: -# -# node default { -# include ::stdlib -# class { java: stage => 'runtime' } -# } -# -class stdlib::stages { - - stage { 'setup': before => Stage['main'] } - stage { 'runtime': require => Stage['main'] } - -> stage { 'setup_infra': } - -> stage { 'deploy_infra': } - -> stage { 'setup_app': } - -> stage { 'deploy_app': } - -> stage { 'deploy': } - -} diff --git a/vagrant/puppet/modules/stdlib/metadata.json b/vagrant/puppet/modules/stdlib/metadata.json deleted file mode 100644 index dea6acfb0..000000000 --- a/vagrant/puppet/modules/stdlib/metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "name": "puppetlabs-stdlib", - "version": "4.12.0", - "author": "puppetlabs", - "summary": "Standard library of resources for Puppet modules.", - "license": "Apache-2.0", - "source": "https://github.com/puppetlabs/puppetlabs-stdlib", - "project_page": "https://github.com/puppetlabs/puppetlabs-stdlib", - "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", - "dependencies": [ - - ], - "data_provider": null, - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "4", - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "4", - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "4", - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "4", - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "10 SP4", - "11 SP1", - "12" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04" - ] - }, - { - "operatingsystem": "Solaris", - "operatingsystemrelease": [ - "10", - "11", - "12" - ] - }, - { - "operatingsystem": "Windows", - "operatingsystemrelease": [ - "Server 2003", - "Server 2003 R2", - "Server 2008", - "Server 2008 R2", - "Server 2012", - "Server 2012 R2", - "7", - "8" - ] - }, - { - "operatingsystem": "AIX", - "operatingsystemrelease": [ - "5.3", - "6.1", - "7.1" - ] - } - ], - "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.0.0 < 2015.4.0" - }, - { - "name": "puppet", - "version_requirement": ">=2.7.20 <5.0.0" - } - ], - "description": "Standard Library for Puppet Modules" -} diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/abs_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/abs_spec.rb deleted file mode 100755 index 6e41e2fde..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/abs_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should accept a string' do - pp = <<-EOS - $input = '-34.56' - $output = abs($input) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 34.56/) - end - end - - it 'should accept a float' do - pp = <<-EOS - $input = -34.56 - $output = abs($input) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 34.56/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/anchor_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/anchor_spec.rb deleted file mode 100755 index 5bc2bbb3b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/anchor_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'anchor type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should effect proper chaining of resources' do - pp = <<-EOS - class anchored { - anchor { 'anchored::begin': } - ~> anchor { 'anchored::end': } - } - - class anchorrefresh { - notify { 'first': } - ~> class { 'anchored': } - ~> anchor { 'final': } - } - - include anchorrefresh - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Anchor\[final\]: Triggered 'refresh'/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/any2array_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/any2array_spec.rb deleted file mode 100755 index 18ea4cd9b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/any2array_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should create an empty array' do - pp = <<-EOS - $input = '' - $output = any2array($input) - validate_array($output) - notify { "Output: ${output}": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: Output: /) - end - end - - it 'should leave arrays modified' do - pp = <<-EOS - $input = ['test', 'array'] - $output = any2array($input) - validate_array($output) - notify { "Output: ${output}": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/) - end - end - - it 'should turn a hash into an array' do - pp = <<-EOS - $input = {'test' => 'array'} - $output = any2array($input) - - validate_array($output) - # Check each element of the array is a plain string. - validate_string($output[0]) - validate_string($output[1]) - notify { "Output: ${output}": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/base64_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/base64_spec.rb deleted file mode 100755 index 97e1738ef..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/base64_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should encode then decode a string' do - pp = <<-EOS - $encodestring = base64('encode', 'thestring') - $decodestring = base64('decode', $encodestring) - notify { $decodestring: } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/thestring/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/bool2num_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/bool2num_spec.rb deleted file mode 100755 index 52ff75bcf..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/bool2num_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - ['false', 'f', '0', 'n', 'no'].each do |bool| - it "should convert a given boolean, #{bool}, to 0" do - pp = <<-EOS - $input = "#{bool}" - $output = bool2num($input) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 0/) - end - end - end - - ['true', 't', '1', 'y', 'yes'].each do |bool| - it "should convert a given boolean, #{bool}, to 1" do - pp = <<-EOS - $input = "#{bool}" - $output = bool2num($input) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 1/) - end - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/build_csv.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/build_csv.rb deleted file mode 100755 index 62ecbf13a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/build_csv.rb +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env ruby -# vim: set sw=2 sts=2 et tw=80 : -require 'rspec' - -#XXX Super ugly hack to keep from starting beaker nodes -module Kernel - # make an alias of the original require - alias_method :original_require, :require - # rewrite require - def require name - original_require name if name != 'spec_helper_acceptance' - end -end -UNSUPPORTED_PLATFORMS = [] -def fact(*args) [] end -#XXX End hax - -# Get a list of functions for test coverage -function_list = Dir[File.join(File.dirname(__FILE__),"..","..","lib","puppet","parser","functions","*.rb")].collect do |function_rb| - File.basename(function_rb,".rb") -end - -## Configure rspec to parse tests -options = RSpec::Core::ConfigurationOptions.new(['spec/acceptance']) -configuration = RSpec::configuration -world = RSpec::world -options.parse_options -options.configure(configuration) -configuration.load_spec_files - -## Collect up tests and example groups into a hash -def get_tests(children) - children.inject({}) do |memo,c| - memo[c.description] = Hash.new - memo[c.description]["groups"] = get_tests(c.children) unless c.children.empty? - memo[c.description]["tests"] = c.examples.collect { |e| - e.description unless e.pending? - }.compact unless c.examples.empty? - memo[c.description]["pending_tests"] = c.examples.collect { |e| - e.description if e.pending? - }.compact unless c.examples.empty? - memo - end -end - -def count_test_types_in(type,group) - return 0 if group.nil? - group.inject(0) do |m,(k,v)| - m += v.length if k == type - m += count_tests_in(v) if v.is_a?(Hash) - m - end -end -def count_tests_in(group) - count_test_types_in('tests',group) -end -def count_pending_tests_in(group) - count_test_types_in('pending_tests',group) -end - -# Convert tests hash to csv format -def to_csv(function_list,tests) - function_list.collect do |function_name| - if v = tests["#{function_name} function"] - positive_tests = count_tests_in(v["groups"]["success"]) - negative_tests = count_tests_in(v["groups"]["failure"]) - pending_tests = - count_pending_tests_in(v["groups"]["failure"]) + - count_pending_tests_in(v["groups"]["failure"]) - else - positive_tests = 0 - negative_tests = 0 - pending_tests = 0 - end - sprintf("%-25s, %-9d, %-9d, %-9d", function_name,positive_tests,negative_tests,pending_tests) - end.compact -end - -tests = get_tests(world.example_groups) -csv = to_csv(function_list,tests) -percentage_tested = "#{tests.count*100/function_list.count}%" -printf("%-25s, %-9s, %-9s, %-9s\n","#{percentage_tested} have tests.","Positive","Negative","Pending") -puts csv diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/capitalize_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/capitalize_spec.rb deleted file mode 100755 index e5e7b7bf8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/capitalize_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should capitalize the first letter of a string' do - pp = <<-EOS - $input = 'this is a string' - $output = capitalize($input) - notify { $output: } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: This is a string/) - end - end - - it 'should capitalize the first letter of an array of strings' do - pp = <<-EOS - $input = ['this', 'is', 'a', 'string'] - $output = capitalize($input) - notify { $output: } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: This/) - expect(r.stdout).to match(/Notice: Is/) - expect(r.stdout).to match(/Notice: A/) - expect(r.stdout).to match(/Notice: String/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/ceiling_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/ceiling_spec.rb deleted file mode 100755 index 557986eb8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/ceiling_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'ceilings floats' do - pp = <<-EOS - $a = 12.8 - $b = 13 - $o = ceiling($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'ceilings integers' do - pp = <<-EOS - $a = 7 - $b = 7 - $o = ceiling($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/chomp_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/chomp_spec.rb deleted file mode 100755 index f6c15956e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/chomp_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should eat the newline' do - pp = <<-EOS - $input = "test\n" - if size($input) != 5 { - fail("Size of ${input} is not 5.") - } - $output = chomp($input) - if size($output) != 4 { - fail("Size of ${input} is not 4.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/chop_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/chop_spec.rb deleted file mode 100755 index a16a71026..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/chop_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should eat the last character' do - pp = <<-EOS - $input = "test" - if size($input) != 4 { - fail("Size of ${input} is not 4.") - } - $output = chop($input) - if size($output) != 3 { - fail("Size of ${input} is not 3.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - it 'should eat the last two characters of \r\n' do - pp = <<-'EOS' - $input = "test\r\n" - if size($input) != 6 { - fail("Size of ${input} is not 6.") - } - $output = chop($input) - if size($output) != 4 { - fail("Size of ${input} is not 4.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - it 'should not fail on empty strings' do - pp = <<-EOS - $input = "" - $output = chop($input) - EOS - - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/clamp_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/clamp_spec.rb deleted file mode 100755 index 0189258d7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/clamp_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'clamp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'clamps list of values' do - pp = <<-EOS - $x = 17 - $y = 225 - $z = 155 - $o = clamp($x, $y, $z) - if $o == $z { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'clamps array of values' do - pp = <<-EOS - $a = [7, 19, 66] - $b = 19 - $o = clamp($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/concat_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/concat_spec.rb deleted file mode 100755 index c472db6bf..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/concat_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should concat one array to another' do - pp = <<-EOS - $output = concat(['1','2','3'],['4','5','6']) - validate_array($output) - if size($output) != 6 { - fail("${output} should have 6 elements.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'should concat arrays and primitives to array' do - pp = <<-EOS - $output = concat(['1','2','3'],'4','5','6',['7','8','9']) - validate_array($output) - if size($output) != 9 { - fail("${output} should have 9 elements.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'should concat multiple arrays to one' do - pp = <<-EOS - $output = concat(['1','2','3'],['4','5','6'],['7','8','9']) - validate_array($output) - if size($output) != 9 { - fail("${output} should have 9 elements.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'should concat hash arguments' do - pp = <<-EOS - $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"}) - validate_array($output) - if size($output) != 2 { - fail("${output} should have 2 elements.") - } - if $output[1] != {"c" => "d", "e" => "f"} { - fail("${output} does not have the expected hash for the second element.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/count_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/count_spec.rb deleted file mode 100755 index fe7ca9dcf..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/count_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should count elements in an array' do - pp = <<-EOS - $input = [1,2,3,4] - $output = count($input) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 4/) - end - end - - it 'should count elements in an array that match a second argument' do - pp = <<-EOS - $input = [1,1,1,2] - $output = count($input, 1) - notify { "$output": } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: 3/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/deep_merge_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/deep_merge_spec.rb deleted file mode 100755 index c0f9b126d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/deep_merge_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should deep merge two hashes' do - pp = <<-EOS - $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } - $merged_hash = deep_merge($hash1, $hash2) - - if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } { - fail("Hash was incorrectly merged.") - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/defined_with_params_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/defined_with_params_spec.rb deleted file mode 100755 index fc544508b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/defined_with_params_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should successfully notify' do - pp = <<-EOS - user { 'dan': - ensure => present, - } - - if defined_with_params(User[dan], {'ensure' => 'present' }) { - notify { 'User defined with ensure=>present': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: User defined with ensure=>present/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_at_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/delete_at_spec.rb deleted file mode 100755 index db0c01f74..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_at_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should delete elements of the array' do - pp = <<-EOS - $output = delete_at(['a','b','c','b'], 1) - if $output == ['a','c','b'] { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/delete_spec.rb deleted file mode 100755 index a28604cea..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should delete elements of the array' do - pp = <<-EOS - $output = delete(['a','b','c','b'], 'b') - if $output == ['a','c'] { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb deleted file mode 100755 index b7eda1926..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should delete elements of the array' do - pp = <<-EOS - $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) - if $output == { a => 'A', b => '', d => false } { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/delete_values_spec.rb deleted file mode 100755 index 6d2369c3e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/delete_values_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should delete elements of the hash' do - pp = <<-EOS - $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' } - $b = { 'a' => 'A', 'B' => 'C' } - $o = delete_values($a, 'B') - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles non-hash arguments' - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/difference_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/difference_spec.rb deleted file mode 100755 index 2fae5c432..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/difference_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'returns non-duplicates in the first array' do - pp = <<-EOS - $a = ['a','b','c'] - $b = ['b','c','d'] - $c = ['a'] - $o = difference($a, $b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles non-array arguments' - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/dirname_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/dirname_spec.rb deleted file mode 100755 index 97913ddb0..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/dirname_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - context 'absolute path' do - it 'returns the dirname' do - pp = <<-EOS - $a = '/path/to/a/file.txt' - $b = '/path/to/a' - $o = dirname($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - context 'relative path' do - it 'returns the dirname' do - pp = <<-EOS - $a = 'path/to/a/file.txt' - $b = 'path/to/a' - $o = dirname($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/downcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/downcase_spec.rb deleted file mode 100755 index bc4e70692..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/downcase_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'returns the downcase' do - pp = <<-EOS - $a = 'AOEU' - $b = 'aoeu' - $o = downcase($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'doesn\'t affect lowercase words' do - pp = <<-EOS - $a = 'aoeu aoeu' - $b = 'aoeu aoeu' - $o = downcase($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/empty_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/empty_spec.rb deleted file mode 100755 index 2d4df901b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/empty_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'recognizes empty strings' do - pp = <<-EOS - $a = '' - $b = true - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'recognizes non-empty strings' do - pp = <<-EOS - $a = 'aoeu' - $b = false - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'handles numerical values' do - pp = <<-EOS - $a = 7 - $b = false - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/ensure_resource_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/ensure_resource_spec.rb deleted file mode 100755 index 93f25ddc0..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/ensure_resource_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'ensure_resource function' do - describe 'success' do - it 'ensures a resource already declared' do - apply_manifest('') - pp = <<-EOS - notify { "test": loglevel => 'err' } - ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - EOS - - apply_manifest(pp, :expect_changes => true) - end - - it 'ensures a undeclared resource' do - apply_manifest('') - pp = <<-EOS - ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - EOS - - apply_manifest(pp, :expect_changes => true) - end - it 'takes defaults arguments' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/flatten_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/flatten_spec.rb deleted file mode 100755 index c4d66e046..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/flatten_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'flattens arrays' do - pp = <<-EOS - $a = ["a","b",["c",["d","e"],"f","g"]] - $b = ["a","b","c","d","e","f","g"] - $o = flatten($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'does not affect flat arrays' do - pp = <<-EOS - $a = ["a","b","c","d","e","f","g"] - $b = ["a","b","c","d","e","f","g"] - $o = flatten($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/floor_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/floor_spec.rb deleted file mode 100755 index 0dcdad9c2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/floor_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'floors floats' do - pp = <<-EOS - $a = 12.8 - $b = 12 - $o = floor($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'floors integers' do - pp = <<-EOS - $a = 7 - $b = 7 - $o = floor($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb deleted file mode 100644 index 065a51726..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - include_context "with faked facts" - context "when the FQDN is 'fakehost.localdomain'" do - before :each do - fake_fact("fqdn", "fakehost.localdomain") - end - - it 'generates random alphanumeric strings' do - pp = <<-eos - $l = 10 - $o = fqdn_rand_string($l) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"/) - end - end - it 'generates random alphanumeric strings with custom charsets' do - pp = <<-eos - $l = 10 - $c = '0123456789' - $o = fqdn_rand_string($l, $c) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rand_string is "(7203048515|2383756694)"/) - end - end - it 'generates random alphanumeric strings with custom seeds' do - pp = <<-eos - $l = 10 - $s = 'seed' - $o = fqdn_rand_string($l, undef, $s) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"/) - end - end - it 'generates random alphanumeric strings with custom charsets and seeds' do - pp = <<-eos - $l = 10 - $c = '0123456789' - $s = 'seed' - $o = fqdn_rand_string($l, $c, $s) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rand_string is "(3104058232|7100592312)"/) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers for length argument' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb deleted file mode 100755 index 404351f6f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - include_context "with faked facts" - context "when the FQDN is 'fakehost.localdomain'" do - before :each do - fake_fact("fqdn", "fakehost.localdomain") - end - - it 'rotates arrays' do - pp = <<-EOS - $a = ['a','b','c','d'] - $o = fqdn_rotate($a) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/) - end - end - it 'rotates arrays with custom seeds' do - pp = <<-EOS - $a = ['a','b','c','d'] - $s = 'seed' - $o = fqdn_rotate($a, $s) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/) - end - end - it 'rotates strings' do - pp = <<-EOS - $a = 'abcd' - $o = fqdn_rotate($a) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rotate is "dabc"/) - end - end - it 'rotates strings with custom seeds' do - pp = <<-EOS - $a = 'abcd' - $s = 'seed' - $o = fqdn_rotate($a, $s) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/fqdn_rotate is "cdab"/) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles invalid arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/get_module_path_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/get_module_path_spec.rb deleted file mode 100755 index 6ac690c16..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/get_module_path_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'get_module_paths dne' do - pp = <<-EOS - $a = $::is_pe ? { - 'true' => '/etc/puppetlabs/puppet/modules/dne', - 'false' => '/etc/puppet/modules/dne', - } - $o = get_module_path('dne') - if $o == $a { - notify { 'output correct': } - } else { - notify { "failed; module path is '$o'": } - } - EOS - - apply_manifest(pp, :expect_failures => true) - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/getparam_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/getparam_spec.rb deleted file mode 100755 index b1a677eca..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/getparam_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'getparam a notify' do - pp = <<-EOS - notify { 'rspec': - message => 'custom rspec message', - } - $o = getparam(Notify['rspec'], 'message') - notice(inline_template('getparam is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/getparam is "custom rspec message"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/getvar_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/getvar_spec.rb deleted file mode 100755 index 333c467f6..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/getvar_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'getvars from classes' do - pp = <<-EOS - class a::data { $foo = 'aoeu' } - include a::data - $b = 'aoeu' - $o = getvar("a::data::foo") - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/grep_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/grep_spec.rb deleted file mode 100755 index b39d48ecb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/grep_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'greps arrays' do - pp = <<-EOS - $a = ['aaabbb','bbbccc','dddeee'] - $b = 'bbb' - $c = ['aaabbb','bbbccc'] - $o = grep($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/has_interface_with_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/has_interface_with_spec.rb deleted file mode 100755 index 959019304..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/has_interface_with_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do - describe 'success' do - it 'has_interface_with existing ipaddress' do - pp = <<-EOS - $a = $::ipaddress - $o = has_interface_with('ipaddress', $a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_interface_with is true/) - end - end - it 'has_interface_with absent ipaddress' do - pp = <<-EOS - $a = '128.0.0.1' - $o = has_interface_with('ipaddress', $a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_interface_with is false/) - end - end - it 'has_interface_with existing interface' do - pp = <<-EOS - if $osfamily == 'Solaris' or $osfamily == 'Darwin' { - $a = 'lo0' - }elsif $osfamily == 'windows' { - $a = $::kernelmajversion ? { - /6\.(2|3|4)/ => 'Ethernet0', - /6\.(0|1)/ => 'Local_Area_Connection', - /5\.(1|2)/ => undef, #Broken current in facter - } - }else { - $a = 'lo' - } - $o = has_interface_with($a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_interface_with is true/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_address_spec.rb deleted file mode 100755 index 149a10dc9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_address_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'has_ip_address function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do - describe 'success' do - it 'has_ip_address existing ipaddress' do - pp = <<-EOS - $a = '127.0.0.1' - $o = has_ip_address($a) - notice(inline_template('has_ip_address is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_ip_address is true/) - end - end - it 'has_ip_address absent ipaddress' do - pp = <<-EOS - $a = '128.0.0.1' - $o = has_ip_address($a) - notice(inline_template('has_ip_address is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_ip_address is false/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_network_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_network_spec.rb deleted file mode 100755 index 7d2f34ed5..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/has_ip_network_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'has_ip_network function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do - describe 'success' do - it 'has_ip_network existing ipaddress' do - pp = <<-EOS - $a = '127.0.0.0' - $o = has_ip_network($a) - notice(inline_template('has_ip_network is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_ip_network is true/) - end - end - it 'has_ip_network absent ipaddress' do - pp = <<-EOS - $a = '128.0.0.0' - $o = has_ip_network($a) - notice(inline_template('has_ip_network is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/has_ip_network is false/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/has_key_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/has_key_spec.rb deleted file mode 100755 index c8557cbeb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/has_key_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'has_keys in hashes' do - pp = <<-EOS - $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } - $b = 'bbb' - $c = true - $o = has_key($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'has_keys not in hashes' do - pp = <<-EOS - $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } - $b = 'ccc' - $c = false - $o = has_key($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-hashes' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/hash_spec.rb deleted file mode 100755 index ed53834be..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/hash_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'hashs arrays' do - pp = <<-EOS - $a = ['aaa','bbb','bbb','ccc','ddd','eee'] - $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' } - $o = hash($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'handles odd-length arrays' - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/intersection_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/intersection_spec.rb deleted file mode 100755 index 66b865297..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/intersection_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'intersections arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $b = ['bbb','ccc','ddd','eee'] - $c = ['bbb','ccc'] - $o = intersection($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'intersections empty arrays' - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_a_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_a_spec.rb deleted file mode 100644 index 355fd8379..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_a_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -if get_puppet_version =~ /^4/ - describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - it 'should match a string' do - pp = <<-EOS - if 'hello world'.is_a(String) { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - - it 'should not match a integer as string' do - pp = <<-EOS - if 5.is_a(String) { - notify { 'output wrong': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).not_to match(/Notice: output wrong/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_array_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_array_spec.rb deleted file mode 100755 index 9c6bad735..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_array_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_arrays arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $b = true - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_arrays empty arrays' do - pp = <<-EOS - $a = [] - $b = true - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_arrays strings' do - pp = <<-EOS - $a = "aoeu" - $b = false - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_arrays hashes' do - pp = <<-EOS - $a = {'aaa'=>'bbb'} - $b = false - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_bool_spec.rb deleted file mode 100755 index 60079f95e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_bool_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_bools arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_bools true' do - pp = <<-EOS - $a = true - $b = true - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_bools false' do - pp = <<-EOS - $a = false - $b = true - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_bools strings' do - pp = <<-EOS - $a = "true" - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_bools hashes' do - pp = <<-EOS - $a = {'aaa'=>'bbb'} - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_domain_name_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_domain_name_spec.rb deleted file mode 100755 index e0f03fa87..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_domain_name_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_domain_names arrays' do - pp = <<-EOS - $a = ['aaa.com','bbb','ccc'] - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_domain_name is false/) - end - end - it 'is_domain_names true' do - pp = <<-EOS - $a = true - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_domain_name is false/) - end - end - it 'is_domain_names false' do - pp = <<-EOS - $a = false - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_domain_name is false/) - end - end - it 'is_domain_names strings with hyphens' do - pp = <<-EOS - $a = "3foo-bar.2bar-fuzz.com" - $b = true - $o = is_domain_name($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_domain_names strings beginning with hyphens' do - pp = <<-EOS - $a = "-bar.2bar-fuzz.com" - $b = false - $o = is_domain_name($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_domain_names hashes' do - pp = <<-EOS - $a = {'aaa'=>'www.com'} - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_domain_name is false/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_float_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_float_spec.rb deleted file mode 100755 index 338ba58d4..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_float_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_floats arrays' do - pp = <<-EOS - $a = ['aaa.com','bbb','ccc'] - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_float is false/) - end - end - it 'is_floats true' do - pp = <<-EOS - $a = true - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_float is false/) - end - end - it 'is_floats strings' do - pp = <<-EOS - $a = "3.5" - $b = true - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_floats floats' do - pp = <<-EOS - $a = 3.5 - $b = true - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_floats integers' do - pp = <<-EOS - $a = 3 - $b = false - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_floats hashes' do - pp = <<-EOS - $a = {'aaa'=>'www.com'} - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_float is false/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_function_available_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_function_available_spec.rb deleted file mode 100755 index 2b5dd6d17..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_function_available_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_function_availables arrays' do - pp = <<-EOS - $a = ['fail','include','require'] - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_function_available is false/) - end - end - it 'is_function_availables true' do - pp = <<-EOS - $a = true - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_function_available is false/) - end - end - it 'is_function_availables strings' do - pp = <<-EOS - $a = "fail" - $b = true - $o = is_function_available($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_function_availables function_availables' do - pp = <<-EOS - $a = "is_function_available" - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_function_available is true/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_hash_spec.rb deleted file mode 100755 index 2ef310abc..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_hash_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_hashs arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $o = is_hash($a) - notice(inline_template('is_hash is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_hash is false/) - end - end - it 'is_hashs empty hashs' do - pp = <<-EOS - $a = {} - $b = true - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_hashs strings' do - pp = <<-EOS - $a = "aoeu" - $b = false - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_hashs hashes' do - pp = <<-EOS - $a = {'aaa'=>'bbb'} - $b = true - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_integer_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_integer_spec.rb deleted file mode 100755 index bf6902b90..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_integer_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_integers arrays' do - pp = <<-EOS - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_integers true' do - pp = <<-EOS - $a = true - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_integers strings' do - pp = <<-EOS - $a = "3" - $b = true - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_integers floats' do - pp = <<-EOS - $a = 3.5 - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_integers integers' do - pp = <<-EOS - $a = 3 - $b = true - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_integers hashes' do - pp = <<-EOS - $a = {'aaa'=>'www.com'} - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ip_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_ip_address_spec.rb deleted file mode 100755 index ed7a85439..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ip_address_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_ip_addresss ipv4' do - pp = <<-EOS - $a = '1.2.3.4' - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ip_addresss ipv6' do - pp = <<-EOS - $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ip_addresss ipv6 compressed' do - pp = <<-EOS - $a = "fe00::1" - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ip_addresss strings' do - pp = <<-EOS - $a = "aoeu" - $b = false - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ip_addresss ipv4 out of range' do - pp = <<-EOS - $a = '1.2.3.400' - $b = false - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb deleted file mode 100755 index 5dc6bf534..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_ipv4_addresss' do - pp = <<-EOS - $a = '1.2.3.4' - $b = true - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ipv4_addresss strings' do - pp = <<-EOS - $a = "aoeu" - $b = false - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ipv4_addresss ipv4 out of range' do - pp = <<-EOS - $a = '1.2.3.400' - $b = false - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb deleted file mode 100755 index 1e88be860..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_ipv6_addresss' do - pp = <<-EOS - $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" - $b = true - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ipv6_addresss ipv6 compressed' do - pp = <<-EOS - $a = "fe00::1" - $b = true - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ipv6_addresss strings' do - pp = <<-EOS - $a = "aoeu" - $b = false - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_ipv6_addresss ip out of range' do - pp = <<-EOS - $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg' - $b = false - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_mac_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_mac_address_spec.rb deleted file mode 100755 index a2c892f43..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_mac_address_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_mac_addresss a mac' do - pp = <<-EOS - $a = '00:a0:1f:12:7f:a0' - $b = true - $o = is_mac_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_mac_addresss a mac out of range' do - pp = <<-EOS - $a = '00:a0:1f:12:7f:g0' - $b = false - $o = is_mac_address($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_numeric_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_numeric_spec.rb deleted file mode 100755 index 21c898841..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_numeric_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_numerics arrays' do - pp = <<-EOS - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_numerics true' do - pp = <<-EOS - $a = true - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_numerics strings' do - pp = <<-EOS - $a = "3" - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_numerics floats' do - pp = <<-EOS - $a = 3.5 - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_numerics integers' do - pp = <<-EOS - $a = 3 - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_numerics hashes' do - pp = <<-EOS - $a = {'aaa'=>'www.com'} - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/is_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/is_string_spec.rb deleted file mode 100755 index 94d8e9678..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/is_string_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'is_strings arrays' do - pp = <<-EOS - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_strings true' do - pp = <<-EOS - $a = true - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_strings strings' do - pp = <<-EOS - $a = "aoeu" - $o = is_string($a) - notice(inline_template('is_string is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_string is true/) - end - end - it 'is_strings number strings' do - pp = <<-EOS - $a = "3" - $o = is_string($a) - notice(inline_template('is_string is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/is_string is false/) - end - end - it 'is_strings floats' do - pp = <<-EOS - $a = 3.5 - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_strings integers' do - pp = <<-EOS - $a = 3 - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'is_strings hashes' do - pp = <<-EOS - $a = {'aaa'=>'www.com'} - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb deleted file mode 100755 index 70493fd5a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'join_keys_to_valuess hashes' do - pp = <<-EOS - $a = {'aaa'=>'bbb','ccc'=>'ddd'} - $b = ':' - $o = join_keys_to_values($a,$b) - notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]/) - end - end - it 'handles non hashes' - it 'handles empty hashes' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/join_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/join_spec.rb deleted file mode 100755 index 5397ce2c8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/join_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'joins arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $b = ':' - $c = 'aaa:bbb:ccc' - $o = join($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - it 'handles non arrays' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/keys_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/keys_spec.rb deleted file mode 100755 index 176918e91..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/keys_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'keyss hashes' do - pp = <<-EOS - $a = {'aaa'=>'bbb','ccc'=>'ddd'} - $o = keys($a) - notice(inline_template('keys is <%= @o.sort.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/keys is \["aaa", "ccc"\]/) - end - end - it 'handles non hashes' - it 'handles empty hashes' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/loadyaml_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/loadyaml_spec.rb deleted file mode 100644 index 1e910a978..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/loadyaml_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -tmpdir = default.tmpdir('stdlib') - -describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'loadyamls array of values' do - shell("echo '--- - aaa: 1 - bbb: 2 - ccc: 3 - ddd: 4' > #{tmpdir}/testyaml.yaml") - pp = <<-EOS - $o = loadyaml('#{tmpdir}/testyaml.yaml') - notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>')) - notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>')) - notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>')) - notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/loadyaml\[aaa\] is 1/) - expect(r.stdout).to match(/loadyaml\[bbb\] is 2/) - expect(r.stdout).to match(/loadyaml\[ccc\] is 3/) - expect(r.stdout).to match(/loadyaml\[ddd\] is 4/) - end - end - end - describe 'failure' do - it 'fails with no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/lstrip_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/lstrip_spec.rb deleted file mode 100755 index 3dc952fbc..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/lstrip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'lstrips arrays' do - pp = <<-EOS - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = lstrip($a) - notice(inline_template('lstrip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/lstrip is \["the ", "public ", "art", "galleries "\]/) - end - end - it 'lstrips strings' do - pp = <<-EOS - $a = " blowzy night-frumps vex'd jack q " - $o = lstrip($a) - notice(inline_template('lstrip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/lstrip is "blowzy night-frumps vex'd jack q "/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/max_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/max_spec.rb deleted file mode 100755 index f04e3d283..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/max_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'maxs arrays' do - pp = <<-EOS - $o = max("the","public","art","galleries") - notice(inline_template('max is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/max is "the"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/member_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/member_spec.rb deleted file mode 100755 index fe75a0782..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/member_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - shared_examples 'item found' do - it 'should output correctly' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - end - describe 'success' do - it 'members arrays' do - pp = <<-EOS - $a = ['aaa','bbb','ccc'] - $b = 'ccc' - $c = true - $o = member($a,$b) - if $o == $c { - notify { 'output correct': } - } - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: output correct/) - end - end - describe 'members array of integers' do - it_should_behave_like 'item found' do - let(:pp) { <<-EOS - if member( [1,2,3,4], 4 ){ - notify { 'output correct': } - } - EOS - } - end - end - describe 'members of mixed array' do - it_should_behave_like 'item found' do - let(:pp) { <<-EOS - if member( ['a','4',3], 'a' ){ - notify { 'output correct': } -} - EOS - } - end - end - it 'members arrays without members' - end - - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/merge_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/merge_spec.rb deleted file mode 100755 index 227b99429..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/merge_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'should merge two hashes' do - pp = <<-EOS - $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $b = {'two' => 'dos', 'three' => { 'five' => 5 } } - $o = merge($a, $b) - notice(inline_template('merge[one] is <%= @o["one"].inspect %>')) - notice(inline_template('merge[two] is <%= @o["two"].inspect %>')) - notice(inline_template('merge[three] is <%= @o["three"].inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/merge\[one\] is ("1"|1)/) - expect(r.stdout).to match(/merge\[two\] is "dos"/) - expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/min_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/min_spec.rb deleted file mode 100755 index 509092d3c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/min_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'mins arrays' do - pp = <<-EOS - $o = min("the","public","art","galleries") - notice(inline_template('min is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/min is "art"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml deleted file mode 100644 index 2ad90b86a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-59-x64: - roles: - - master - platform: el-5-x86_64 - box : centos-59-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: git diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml deleted file mode 100644 index ca9c1d329..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml +++ /dev/null @@ -1,15 +0,0 @@ -HOSTS: - 'centos-6-vcloud': - roles: - - master - platform: el-6-x86_64 - hypervisor: vcloud - template: centos-6-x86_64 -CONFIG: - type: foss - ssh: - keys: "~/.ssh/id_rsa-acceptance" - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml deleted file mode 100644 index 7d9242f1b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - centos-64-x64: - roles: - - master - - database - - dashboard - platform: el-6-x86_64 - box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: pe diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml deleted file mode 100644 index 05540ed8c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-64-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml deleted file mode 100644 index 4e2cb809e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-vbox436-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/default.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/default.yml deleted file mode 100644 index 4e2cb809e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-vbox436-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml deleted file mode 100644 index 136164983..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - fedora-18-x64: - roles: - - master - platform: fedora-18-x86_64 - box : fedora-18-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml deleted file mode 100644 index 41abe2135..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - sles-11-x64.local: - roles: - - master - platform: sles-11-x64 - box : sles-11sp1-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml deleted file mode 100644 index 5ca1514e4..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-server-10044-x64: - roles: - - master - platform: ubuntu-10.04-amd64 - box : ubuntu-server-10044-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml deleted file mode 100644 index d065b304f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -HOSTS: - ubuntu-server-12042-x64: - roles: - - master - platform: ubuntu-12.04-amd64 - box : ubuntu-server-12042-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - type: foss diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml deleted file mode 100644 index cba1cd04c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - ubuntu-server-1404-x64: - roles: - - master - platform: ubuntu-14.04-amd64 - box : puppetlabs/ubuntu-14.04-64-nocm - box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm - hypervisor : vagrant -CONFIG: - log_level : debug - type: git diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml deleted file mode 100644 index 47dadbd52..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2003_i386: - roles: - - agent - - default - platform: windows-2003-i386 - template: win-2003-i386 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml deleted file mode 100644 index 6a884bc9f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2003_x86_64: - roles: - - agent - - default - platform: windows-2003-x86_64 - template: win-2003-x86_64 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml deleted file mode 100644 index ae3c11dd1..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2008_x86_64: - roles: - - agent - - default - platform: windows-2008-x86_64 - template: win-2008-x86_64 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml deleted file mode 100644 index 63923ac10..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2008r2: - roles: - - agent - - default - platform: windows-2008r2-x86_64 - template: win-2008r2-x86_64 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml deleted file mode 100644 index eaa4eca90..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2012: - roles: - - agent - - default - platform: windows-2012-x86_64 - template: win-2012-x86_64 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml b/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml deleted file mode 100644 index 1f0ea97c7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu1204: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - template: ubuntu-1204-x86_64 - hypervisor: vcloud - win2012r2: - roles: - - agent - - default - platform: windows-2012r2-x86_64 - template: win-2012r2-x86_64 - hypervisor: vcloud -CONFIG: - nfs_server: none - ssh: - keys: "~/.ssh/id_rsa-acceptance" - consoleport: 443 - datastore: instance0 - folder: Delivery/Quality Assurance/Enterprise/Dynamic - resourcepool: delivery/Quality Assurance/Enterprise/Dynamic - pooling_api: http://vcloud.delivery.puppetlabs.net/ - pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/num2bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/num2bool_spec.rb deleted file mode 100755 index 1d99ba025..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/num2bool_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'bools positive numbers and numeric strings as true' do - pp = <<-EOS - $a = 1 - $b = "1" - $c = "50" - $ao = num2bool($a) - $bo = num2bool($b) - $co = num2bool($c) - notice(inline_template('a is <%= @ao.inspect %>')) - notice(inline_template('b is <%= @bo.inspect %>')) - notice(inline_template('c is <%= @co.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/a is true/) - expect(r.stdout).to match(/b is true/) - expect(r.stdout).to match(/c is true/) - end - end - it 'bools negative numbers as false' do - pp = <<-EOS - $a = 0 - $b = -0.1 - $c = ["-50","1"] - $ao = num2bool($a) - $bo = num2bool($b) - $co = num2bool($c) - notice(inline_template('a is <%= @ao.inspect %>')) - notice(inline_template('b is <%= @bo.inspect %>')) - notice(inline_template('c is <%= @co.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/a is false/) - expect(r.stdout).to match(/b is false/) - expect(r.stdout).to match(/c is false/) - end - end - end - describe 'failure' do - it 'fails on words' do - pp = <<-EOS - $a = "a" - $ao = num2bool($a) - notice(inline_template('a is <%= @ao.inspect %>')) - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/) - end - - it 'fails on numberwords' do - pp = <<-EOS - $b = "1b" - $bo = num2bool($b) - notice(inline_template('b is <%= @bo.inspect %>')) - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/) - - end - - it 'fails on non-numeric/strings' do - pending "The function will call .to_s.to_i on anything not a Numeric or - String, and results in 0. Is this intended?" - pp = <<-EOS - $c = {"c" => "-50"} - $co = num2bool($c) - notice(inline_template('c is <%= @co.inspect %>')) - EOS - expect(apply_manifest(ppc :expect_failures => true).stderr).to match(/Unable to parse/) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/parsejson_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/parsejson_spec.rb deleted file mode 100755 index d0e3de847..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/parsejson_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'parses valid json' do - pp = <<-EOS - $a = '{"hunter": "washere", "tests": "passing"}' - $ao = parsejson($a) - $tests = $ao['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/tests are "passing"/) - end - end - end - - describe 'failure' do - it 'raises error on incorrect json' do - pp = <<-EOS - $a = '{"hunter": "washere", "tests": "passing",}' - $ao = parsejson($a, 'tests are using the default value') - notice(inline_template('a is <%= @ao.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/tests are using the default value/) - end - end - - it 'raises error on incorrect json' do - pp = <<-EOS - $a = '{"hunter": "washere", "tests": "passing",}' - $ao = parsejson($a) - notice(inline_template('a is <%= @ao.inspect %>')) - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/expected next name/) - end - end - - it 'raises error on incorrect number of arguments' do - pp = <<-EOS - $o = parsejson() - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/wrong number of arguments/i) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/parseyaml_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/parseyaml_spec.rb deleted file mode 100755 index 64511f13e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/parseyaml_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'parses valid yaml' do - pp = <<-EOS - $a = "---\nhunter: washere\ntests: passing\n" - $o = parseyaml($a) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/tests are "passing"/) - end - end - end - - describe 'failure' do - it 'returns the default value on incorrect yaml' do - pp = <<-EOS - $a = "---\nhunter: washere\ntests: passing\n:" - $o = parseyaml($a, {'tests' => 'using the default value'}) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/tests are "using the default value"/) - end - end - - it 'raises error on incorrect yaml' do - pp = <<-EOS - $a = "---\nhunter: washere\ntests: passing\n:" - $o = parseyaml($a) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/(syntax error|did not find expected key)/) - end - end - - - it 'raises error on incorrect number of arguments' do - pp = <<-EOS - $o = parseyaml() - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/wrong number of arguments/i) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/pick_default_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/pick_default_spec.rb deleted file mode 100755 index a663f54e8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/pick_default_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'pick_defaults a default value' do - pp = <<-EOS - $a = undef - $o = pick_default($a, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/picked is "default"/) - end - end - it 'pick_defaults with no value' do - pp = <<-EOS - $a = undef - $b = undef - $o = pick_default($a,$b) - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/picked is ""/) - end - end - it 'pick_defaults the first set value' do - pp = <<-EOS - $a = "something" - $b = "long" - $o = pick_default($a, $b, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/picked is "something"/) - end - end - end - describe 'failure' do - it 'raises error with no values' do - pp = <<-EOS - $o = pick_default() - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/Must receive at least one argument/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/pick_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/pick_spec.rb deleted file mode 100755 index 46cf63f28..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/pick_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'picks a default value' do - pp = <<-EOS - $a = undef - $o = pick($a, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/picked is "default"/) - end - end - it 'picks the first set value' do - pp = <<-EOS - $a = "something" - $b = "long" - $o = pick($a, $b, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/picked is "something"/) - end - end - end - describe 'failure' do - it 'raises error with all undef values' do - pp = <<-EOS - $a = undef - $b = undef - $o = pick($a, $b) - notice(inline_template('picked is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/must receive at least one non empty value/) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/prefix_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/prefix_spec.rb deleted file mode 100755 index de55530eb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/prefix_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'prefixes array of values' do - pp = <<-EOS - $o = prefix(['a','b','c'],'p') - notice(inline_template('prefix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/prefix is \["pa", "pb", "pc"\]/) - end - end - it 'prefixs with empty array' do - pp = <<-EOS - $o = prefix([],'p') - notice(inline_template('prefix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/prefix is \[\]/) - end - end - it 'prefixs array of values with undef' do - pp = <<-EOS - $o = prefix(['a','b','c'], undef) - notice(inline_template('prefix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/prefix is \["a", "b", "c"\]/) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/pw_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/pw_hash_spec.rb deleted file mode 100644 index cd4cb87c5..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/pw_hash_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -# Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do - describe 'success' do - it 'hashes passwords' do - pp = <<-EOS - $o = pw_hash('password', 'sha-512', 'salt') - notice(inline_template('pw_hash is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/) - end - end - - it 'returns nil if no password is provided' do - pp = <<-EOS - $o = pw_hash('', 'sha-512', 'salt') - notice(inline_template('pw_hash is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/pw_hash is nil/) - end - end - end - describe 'failure' do - it 'handles less than three arguments' - it 'handles more than three arguments' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/range_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/range_spec.rb deleted file mode 100755 index a3ccd3396..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/range_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'ranges letters' do - pp = <<-EOS - $o = range('a','d') - notice(inline_template('range is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/range is \["a", "b", "c", "d"\]/) - end - end - it 'ranges letters with a step' do - pp = <<-EOS - $o = range('a','d', '2') - notice(inline_template('range is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/range is \["a", "c"\]/) - end - end - it 'ranges letters with a negative step' - it 'ranges numbers' - it 'ranges numbers with a step' - it 'ranges numbers with a negative step' - it 'ranges numeric strings' - it 'ranges zero padded numbers' - end - describe 'failure' do - it 'fails with no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/reject_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/reject_spec.rb deleted file mode 100755 index 7f16a008d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/reject_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'rejects array of values' do - pp = <<-EOS - $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa') - notice(inline_template('reject is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/reject is \["bbb", "ccc"\]/) - end - end - it 'rejects with empty array' do - pp = <<-EOS - $o = reject([],'aaa') - notice(inline_template('reject is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/reject is \[\]/) - end - end - it 'rejects array of values with undef' do - pp = <<-EOS - $o = reject(['aaa','bbb','ccc','aaaddd'], undef) - notice(inline_template('reject is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/reject is \[\]/) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/reverse_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/reverse_spec.rb deleted file mode 100755 index c3f01567a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/reverse_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'reverses strings' do - pp = <<-EOS - $a = "the public art galleries" - # Anagram: Large picture halls, I bet - $o = reverse($a) - notice(inline_template('reverse is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/rstrip_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/rstrip_spec.rb deleted file mode 100755 index b57a8b045..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/rstrip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'rstrips arrays' do - pp = <<-EOS - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = rstrip($a) - notice(inline_template('rstrip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/rstrip is \[" the", " public", " art", "galleries"\]/) - end - end - it 'rstrips strings' do - pp = <<-EOS - $a = " blowzy night-frumps vex'd jack q " - $o = rstrip($a) - notice(inline_template('rstrip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/rstrip is " blowzy night-frumps vex'd jack q"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/shuffle_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/shuffle_spec.rb deleted file mode 100755 index b840d1f1b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/shuffle_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'shuffles arrays' do - pp = <<-EOS - $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = shuffle($a) - notice(inline_template('shuffle is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to_not match(/shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]/) - end - end - it 'shuffles strings' do - pp = <<-EOS - $a = "blowzy night-frumps vex'd jack q" - $o = shuffle($a) - notice(inline_template('shuffle is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to_not match(/shuffle is "blowzy night-frumps vex'd jack q"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/size_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/size_spec.rb deleted file mode 100755 index a52b778bd..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/size_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'single string size' do - pp = <<-EOS - $a = 'discombobulate' - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/size is 14/) - end - end - it 'with empty string' do - pp = <<-EOS - $a = '' - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/size is 0/) - end - end - it 'with undef' do - pp = <<-EOS - $a = undef - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/size is 0/) - end - end - it 'strings in array' do - pp = <<-EOS - $a = ['discombobulate', 'moo'] - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/size is 2/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/sort_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/sort_spec.rb deleted file mode 100755 index c85bfabd5..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/sort_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'sorts arrays' do - pp = <<-EOS - $a = ["the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = sort($a) - notice(inline_template('sort is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/sort is \["art", "galleries", "public", "the"\]/) - end - end - it 'sorts strings' do - pp = <<-EOS - $a = "blowzy night-frumps vex'd jack q" - $o = sort($a) - notice(inline_template('sort is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/sort is " '-abcdefghijklmnopqrstuvwxyz"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/squeeze_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/squeeze_spec.rb deleted file mode 100755 index 400a458c9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/squeeze_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'squeezes arrays' do - pp = <<-EOS - # Real words! - $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] - $o = squeeze($a) - notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]/) - end - end - it 'squeezez arrays with an argument' - it 'squeezes strings' do - pp = <<-EOS - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = squeeze($a) - notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/squeeze is "wales laparohysterosalpingophorectomy br godeship"/) - end - end - - it 'squeezes strings with an argument' do - pp = <<-EOS - $a = "countessship duchessship governessship hostessship" - $o = squeeze($a, 's') - notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/squeeze is "counteship ducheship governeship hosteship"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/str2bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/str2bool_spec.rb deleted file mode 100755 index cf549dab8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/str2bool_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'works with "y"' do - pp = <<-EOS - $o = str2bool('y') - notice(inline_template('str2bool is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/str2bool is true/) - end - end - it 'works with "Y"' - it 'works with "yes"' - it 'works with "1"' - it 'works with "true"' - it 'works with "n"' - it 'works with "N"' - it 'works with "no"' - it 'works with "0"' - it 'works with "false"' - it 'works with undef' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays or strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb deleted file mode 100755 index 993e63bac..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'works with "y"' do - pp = <<-EOS - $o = str2saltedsha512('password') - notice(inline_template('str2saltedsha512 is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles more than one argument' - it 'handles non strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/strftime_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/strftime_spec.rb deleted file mode 100755 index 53b7f903b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/strftime_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'gives the Century' do - pp = <<-EOS - $o = strftime('%C') - notice(inline_template('strftime is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/strftime is "20"/) - end - end - it 'takes a timezone argument' - end - describe 'failure' do - it 'handles no arguments' - it 'handles invalid format strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/strip_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/strip_spec.rb deleted file mode 100755 index 906fd7abe..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/strip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'strips arrays' do - pp = <<-EOS - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = strip($a) - notice(inline_template('strip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/strip is \["the", "public", "art", "galleries"\]/) - end - end - it 'strips strings' do - pp = <<-EOS - $a = " blowzy night-frumps vex'd jack q " - $o = strip($a) - notice(inline_template('strip is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/strip is "blowzy night-frumps vex'd jack q"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/suffix_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/suffix_spec.rb deleted file mode 100755 index 630f866d7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/suffix_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'suffixes array of values' do - pp = <<-EOS - $o = suffix(['a','b','c'],'p') - notice(inline_template('suffix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/suffix is \["ap", "bp", "cp"\]/) - end - end - it 'suffixs with empty array' do - pp = <<-EOS - $o = suffix([],'p') - notice(inline_template('suffix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/suffix is \[\]/) - end - end - it 'suffixs array of values with undef' do - pp = <<-EOS - $o = suffix(['a','b','c'], undef) - notice(inline_template('suffix is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/suffix is \["a", "b", "c"\]/) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/swapcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/swapcase_spec.rb deleted file mode 100755 index b7894fbe2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/swapcase_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'works with strings' do - pp = <<-EOS - $o = swapcase('aBcD') - notice(inline_template('swapcase is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/swapcase is "AbCd"/) - end - end - it 'works with arrays' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays or strings' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/time_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/time_spec.rb deleted file mode 100755 index cdb296070..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/time_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'gives the time' do - pp = <<-EOS - $o = time() - notice(inline_template('time is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - m = r.stdout.match(/time is (\d+)\D/) - - # When I wrote this test - expect(Integer(m[1])).to be > 1398894170 - end - end - it 'takes a timezone argument' do - pp = <<-EOS - $o = time('UTC') - notice(inline_template('time is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - m = r.stdout.match(/time is (\d+)\D/) - - expect(Integer(m[1])).to be > 1398894170 - end - end - end - describe 'failure' do - it 'handles more arguments' - it 'handles invalid timezones' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/to_bytes_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/to_bytes_spec.rb deleted file mode 100755 index 2b4c61f48..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/to_bytes_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'converts kB to B' do - pp = <<-EOS - $o = to_bytes('4 kB') - notice(inline_template('to_bytes is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - m = r.stdout.match(/to_bytes is (\d+)\D/) - expect(m[1]).to eq("4096") - end - end - it 'works without the B in unit' - it 'works without a space before unit' - it 'works without a unit' - it 'converts fractions' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non integer arguments' - it 'handles unknown units like uB' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/try_get_value_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/try_get_value_spec.rb deleted file mode 100755 index c0bf38ae3..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/try_get_value_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'gets a value' do - pp = <<-EOS - $data = { - 'a' => { 'b' => 'passing'} - } - - $tests = try_get_value($data, 'a/b') - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/tests are "passing"/) - end - end - end - describe 'failure' do - it 'uses a default value' do - pp = <<-EOS - $data = { - 'a' => { 'b' => 'passing'} - } - - $tests = try_get_value($data, 'c/d', 'using the default value') - notice(inline_template('tests are <%= @tests.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/using the default value/) - end - end - - it 'raises error on incorrect number of arguments' do - pp = <<-EOS - $o = try_get_value() - EOS - - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/wrong number of arguments/i) - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/type_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/type_spec.rb deleted file mode 100755 index 67e324803..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/type_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do - describe 'success' do - it 'types arrays' do - pp = <<-EOS - $a = ["the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "array"/) - end - end - it 'types strings' do - pp = <<-EOS - $a = "blowzy night-frumps vex'd jack q" - $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "string"/) - end - end - it 'types hashes' - it 'types integers' - it 'types floats' - it 'types booleans' - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/union_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/union_spec.rb deleted file mode 100755 index 160fd7b09..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/union_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'unions arrays' do - pp = <<-EOS - $a = ["the","public"] - $b = ["art"] - $c = ["galleries"] - # Anagram: Large picture halls, I bet - $o = union($a,$b,$c) - notice(inline_template('union is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/unique_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/unique_spec.rb deleted file mode 100755 index bfadad19b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/unique_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'uniques arrays' do - pp = <<-EOS - $a = ["wallless", "wallless", "brrr", "goddessship"] - $o = unique($a) - notice(inline_template('unique is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/unique is \["wallless", "brrr", "goddessship"\]/) - end - end - it 'uniques strings' do - pp = <<-EOS - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = unique($a) - notice(inline_template('unique is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/unique is "wales prohytingcmbd"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/unsupported_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/unsupported_spec.rb deleted file mode 100755 index 1c559f67e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/unsupported_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - it 'should fail' do - pp = <<-EOS - class { 'mysql::server': } - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/upcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/upcase_spec.rb deleted file mode 100755 index 3d2906d72..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/upcase_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'upcases arrays' do - pp = <<-EOS - $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] - $o = upcase($a) - notice(inline_template('upcase is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]/) - end - end - it 'upcases strings' do - pp = <<-EOS - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = upcase($a) - notice(inline_template('upcase is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"/) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/uriescape_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/uriescape_spec.rb deleted file mode 100755 index 7e30205e8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/uriescape_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'uriescape strings' do - pp = <<-EOS - $a = ":/?#[]@!$&'()*+,;= \\\"{}" - $o = uriescape($a) - notice(inline_template('uriescape is <%= @o.inspect %>')) - EOS - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"/) - end - end - it 'does nothing if a string is already safe' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb deleted file mode 100755 index 7082e848e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - %w{ - C:/ - C:\\\\ - C:\\\\WINDOWS\\\\System32 - C:/windows/system32 - X:/foo/bar - X:\\\\foo\\\\bar - /var/tmp - /var/lib/puppet - /var/opt/../lib/puppet - }.each do |path| - it "validates a single argument #{path}" do - pp = <<-EOS - $one = '#{path}' - validate_absolute_path($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles relative paths' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_array_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_array_spec.rb deleted file mode 100755 index b53e98c27..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_array_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = ['a', 'b'] - validate_array($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = ['a', 'b'] - $two = [['c'], 'd'] - validate_array($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a non-array' do - { - %{validate_array({'a' => 'hash' })} => "Hash", - %{validate_array('string')} => "String", - %{validate_array(false)} => "FalseClass", - %{validate_array(undef)} => "String" - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_augeas_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_augeas_spec.rb deleted file mode 100755 index 71a4c8425..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_augeas_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do - describe 'prep' do - it 'installs augeas for tests' - end - describe 'success' do - context 'valid inputs with no 3rd argument' do - { - 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns', - 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns' - }.each do |line,lens| - it "validates a single argument for #{lens}" do - pp = <<-EOS - $line = "#{line}" - $lens = "#{lens}" - validate_augeas($line, $lens) - EOS - - apply_manifest(pp, :catch_failures => true) - end - end - end - context 'valid inputs with 3rd and 4th arguments' do - it "validates a restricted value" do - line = 'root:x:0:0:root:/root:/bin/barsh\n' - lens = 'Passwd.lns' - restriction = '$file/*[shell="/bin/barsh"]' - pp = <<-EOS - $line = "#{line}" - $lens = "#{lens}" - $restriction = ['#{restriction}'] - validate_augeas($line, $lens, $restriction, "my custom failure message") - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/) - end - end - context 'invalid inputs' do - { - 'root:x:0:0:root' => 'Passwd.lns', - '127.0.1.1' => 'Hosts.lns' - }.each do |line,lens| - it "validates a single argument for #{lens}" do - pp = <<-EOS - $line = "#{line}" - $lens = "#{lens}" - validate_augeas($line, $lens) - EOS - - apply_manifest(pp, :expect_failures => true) - end - end - end - context 'garbage inputs' do - it 'raises an error on invalid inputs' - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_bool_spec.rb deleted file mode 100755 index c837f089f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_bool_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = true - validate_bool($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = true - $two = false - validate_bool($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a non-bool' do - { - %{validate_bool('true')} => "String", - %{validate_bool('false')} => "String", - %{validate_bool([true])} => "Array", - %{validate_bool(undef)} => "String", - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_cmd_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_cmd_spec.rb deleted file mode 100755 index 5ac66fdbf..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_cmd_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a true command' do - pp = <<-EOS - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'echo' #shell built-in - } else { - $two = '/bin/echo' - } - validate_cmd($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a fail command' do - pp = <<-EOS - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'C:/aoeu' - } else { - $two = '/bin/aoeu' - } - validate_cmd($one,$two) - EOS - - apply_manifest(pp, :expect_failures => true) - end - it 'validates a fail command with a custom error message' do - pp = <<-EOS - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'C:/aoeu' - } else { - $two = '/bin/aoeu' - } - validate_cmd($one,$two,"aoeu is dvorak") - EOS - - apply_manifest(pp, :expect_failures => true) do |output| - expect(output.stderr).to match(/aoeu is dvorak/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper argument types' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_hash_spec.rb deleted file mode 100755 index 52fb615bd..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_hash_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = { 'a' => 1 } - validate_hash($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = { 'a' => 1 } - $two = { 'b' => 2 } - validate_hash($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a non-hash' do - { - %{validate_hash('{ "not" => "hash" }')} => "String", - %{validate_hash('string')} => "String", - %{validate_hash(["array"])} => "Array", - %{validate_hash(undef)} => "String", - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb deleted file mode 100755 index 64841c371..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = '1.2.3.4' - validate_ipv4_address($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = '1.2.3.4' - $two = '5.6.7.8' - validate_ipv4_address($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles ipv6 addresses' - it 'handles non-ipv4 strings' - it 'handles numbers' - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb deleted file mode 100755 index 6426d1a52..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = '3ffe:0505:0002::' - validate_ipv6_address($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = '3ffe:0505:0002::' - $two = '3ffe:0505:0001::' - validate_ipv6_address($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles ipv6 addresses' - it 'handles non-ipv6 strings' - it 'handles numbers' - it 'handles no arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_re_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_re_spec.rb deleted file mode 100755 index 22f6d47d1..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_re_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a string' do - pp = <<-EOS - $one = 'one' - $two = '^one$' - validate_re($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an array' do - pp = <<-EOS - $one = 'one' - $two = ['^one$', '^two'] - validate_re($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a failed array' do - pp = <<-EOS - $one = 'one' - $two = ['^two$', '^three'] - validate_re($one,$two) - EOS - - apply_manifest(pp, :expect_failures => true) - end - it 'validates a failed array with a custom error message' do - pp = <<-EOS - $one = '3.4.3' - $two = '^2.7' - validate_re($one,$two,"The $puppetversion fact does not match 2.7") - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not match/) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper argument types' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_slength_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_slength_spec.rb deleted file mode 100755 index 1ab2bb986..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_slength_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single string max' do - pp = <<-EOS - $one = 'discombobulate' - $two = 17 - validate_slength($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates multiple string maxes' do - pp = <<-EOS - $one = ['discombobulate', 'moo'] - $two = 17 - validate_slength($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates min/max of strings in array' do - pp = <<-EOS - $one = ['discombobulate', 'moo'] - $two = 17 - $three = 3 - validate_slength($one,$two,$three) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a single string max of incorrect length' do - pp = <<-EOS - $one = 'discombobulate' - $two = 1 - validate_slength($one,$two) - EOS - - apply_manifest(pp, :expect_failures => true) - end - it 'validates multiple string maxes of incorrect length' do - pp = <<-EOS - $one = ['discombobulate', 'moo'] - $two = 3 - validate_slength($one,$two) - EOS - - apply_manifest(pp, :expect_failures => true) - end - it 'validates multiple strings min/maxes of incorrect length' do - pp = <<-EOS - $one = ['discombobulate', 'moo'] - $two = 17 - $three = 10 - validate_slength($one,$two,$three) - EOS - - apply_manifest(pp, :expect_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper first argument type' - it 'handles non-strings in array of first argument' - it 'handles improper second argument type' - it 'handles improper third argument type' - it 'handles negative ranges' - it 'handles improper ranges' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/validate_string_spec.rb deleted file mode 100755 index 8956f48c9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/validate_string_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'validates a single argument' do - pp = <<-EOS - $one = 'string' - validate_string($one) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates an multiple arguments' do - pp = <<-EOS - $one = 'string' - $two = 'also string' - validate_string($one,$two) - EOS - - apply_manifest(pp, :catch_failures => true) - end - it 'validates a non-string' do - { - %{validate_string({ 'a' => 'hash' })} => "Hash", - %{validate_string(['array'])} => "Array", - %{validate_string(false)} => "FalseClass", - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/values_at_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/values_at_spec.rb deleted file mode 100755 index da63cf307..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/values_at_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'returns a specific value' do - pp = <<-EOS - $one = ['a','b','c','d','e'] - $two = 1 - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b"\]/) - end - it 'returns a specific negative index value' do - pending("negative numbers don't work") - pp = <<-EOS - $one = ['a','b','c','d','e'] - $two = -1 - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["e"\]/) - end - it 'returns a range of values' do - pp = <<-EOS - $one = ['a','b','c','d','e'] - $two = "1-3" - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d"\]/) - end - it 'returns a negative specific value and range of values' do - pp = <<-EOS - $one = ['a','b','c','d','e'] - $two = ["1-3",0] - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d", "a"\]/) - end - end - describe 'failure' do - it 'handles improper number of arguments' do - pp = <<-EOS - $one = ['a','b','c','d','e'] - $output = values_at($one) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/) - end - it 'handles non-indicies arguments' do - pp = <<-EOS - $one = ['a','b','c','d','e'] - $two = [] - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/at least one positive index/) - end - - it 'detects index ranges smaller than the start range' - it 'handles index ranges larger than array' - it 'handles non-integer indicies' - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/values_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/values_spec.rb deleted file mode 100755 index a2eff329d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/values_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'returns an array of values' do - pp = <<-EOS - $arg = { - 'a' => 1, - 'b' => 2, - 'c' => 3, - } - $output = values($arg) - notice(inline_template('<%= @output.sort.inspect %>')) - EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/) - end - - end - end - describe 'failure' do - it 'handles non-hash arguments' do - pp = <<-EOS - $arg = "foo" - $output = values($arg) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires hash/) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/acceptance/zip_spec.rb b/vagrant/puppet/modules/stdlib/spec/acceptance/zip_spec.rb deleted file mode 100755 index 139079e31..000000000 --- a/vagrant/puppet/modules/stdlib/spec/acceptance/zip_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' -require 'puppet' - -describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - describe 'success' do - it 'zips two arrays of numbers together' do - pp = <<-EOS - $one = [1,2,3,4] - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/) - end - end - it 'zips two arrays of numbers & bools together' do - pp = <<-EOS - $one = [1,2,"three",4] - $two = [true,true,false,false] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/) - end - end - it 'zips two arrays of numbers together and flattens them' do - # XXX This only tests the argument `true`, even though the following are valid: - # 1 t y true yes - # 0 f n false no - # undef undefined - pp = <<-EOS - $one = [1,2,3,4] - $two = [5,6,7,8] - $output = zip($one,$two,true) - notice(inline_template('<%= @output.inspect %>')) - EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/) - end - end - it 'handles unmatched length' do - # XXX Is this expected behavior? - pp = <<-EOS - $one = [1,2] - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' do - pp = <<-EOS - $one = [1,2] - $output = zip($one) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/) - end - it 'handles improper argument types' do - pp = <<-EOS - $one = "a string" - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/abs_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/abs_spec.rb deleted file mode 100755 index 7d2257b02..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/abs_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'abs' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - end - - describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do - it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) } - end - - it { is_expected.to run.with_params(-34).and_return(34) } - it { is_expected.to run.with_params("-34").and_return(34) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params("34").and_return(34) } - it { is_expected.to run.with_params(-34.5).and_return(34.5) } - it { is_expected.to run.with_params("-34.5").and_return(34.5) } - it { is_expected.to run.with_params(34.5).and_return(34.5) } - it { is_expected.to run.with_params("34.5").and_return(34.5) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/any2array_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/any2array_spec.rb deleted file mode 100755 index 70121f1e3..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/any2array_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "any2array" do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_return([]) } - it { is_expected.to run.with_params(true).and_return([true]) } - it { is_expected.to run.with_params('one').and_return(['one']) } - it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) } - it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } - it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/assert_private_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/assert_private_spec.rb deleted file mode 100755 index 98f2598ea..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/assert_private_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'assert_private' do - context 'when called from inside module' do - it "should not fail" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('foo') - expect { - subject.call [] - }.not_to raise_error - end - end - - context "with an explicit failure message" do - it "prints the failure message on error" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - expect { - subject.call ['failure message!'] - }.to raise_error Puppet::ParseError, /failure message!/ - end - end - - context "when called from private class" do - it "should fail with a class error message" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - scope.source.expects(:name).returns('foo::baz') - scope.source.expects(:type).returns('hostclass') - expect { - subject.call [] - }.to raise_error Puppet::ParseError, /Class foo::baz is private/ - end - end - - context "when called from private definition" do - it "should fail with a class error message" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - scope.source.expects(:name).returns('foo::baz') - scope.source.expects(:type).returns('definition') - expect { - subject.call [] - }.to raise_error Puppet::ParseError, /Definition foo::baz is private/ - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/base64_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/base64_spec.rb deleted file mode 100755 index 842a37a98..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/base64_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe 'base64' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /first argument must be one of/) } - it { is_expected.to run.with_params("encode", ["two"]).and_raise_error(Puppet::ParseError, /second argument must be a string/) } - it { is_expected.to run.with_params("encode", 2).and_raise_error(Puppet::ParseError, /second argument must be a string/) } - it { is_expected.to run.with_params("encode", "thestring", "three").and_raise_error(Puppet::ParseError, /third argument must be one of/) } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "strict").and_raise_error(ArgumentError) } - - it { is_expected.to run.with_params("encode", "thestring").and_return("dGhlc3RyaW5n\n") } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n").and_return("thestring") } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n").and_return("thestring") } - - it { is_expected.to run.with_params("encode", "thestring", "default").and_return("dGhlc3RyaW5n\n") } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "default").and_return("thestring") } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "default").and_return("thestring") } - - it { is_expected.to run.with_params("encode", "thestring", "strict").and_return("dGhlc3RyaW5n") } - it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "strict").and_return("thestring") } - - it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n") } - it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") } - it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") } - - it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines", "strict").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==") } - it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") } - it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==", "strict").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") } - - it { is_expected.to run.with_params("encode", "https://www.google.com.tw/?gws_rd=ssl#q=hello+world", "urlsafe").and_return("aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk") } - it { is_expected.to run.with_params("decode", "aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk", "urlsafe").and_return("https://www.google.com.tw/?gws_rd=ssl#q=hello+world") } - - it { is_expected.to run.with_params("encode", "https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add", "urlsafe").and_return("aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=") } - it { is_expected.to run.with_params("decode", "aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=", "urlsafe").and_return("https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add") } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/basename_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/basename_spec.rb deleted file mode 100755 index c84e192b2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/basename_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'basename' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('file.ext') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('file.ext') } - it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') } - it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/bool2num_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/bool2num_spec.rb deleted file mode 100755 index e5068594b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/bool2num_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'bool2num' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - - [ true, 'true', AlsoString.new('true') ].each do |truthy| - it { is_expected.to run.with_params(truthy).and_return(1) } - end - - [ false, 'false', AlsoString.new('false') ].each do |falsey| - it { is_expected.to run.with_params(falsey).and_return(0) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/bool2str_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/bool2str_spec.rb deleted file mode 100755 index 23a754ba4..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/bool2str_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'bool2str' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - [ 'true', 'false', nil, :undef, ''].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError) } - end - it { is_expected.to run.with_params(true, 'yes', 'no', 'maybe').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true, 'maybe').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true, 0, 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true).and_return("true") } - it { is_expected.to run.with_params(false).and_return("false") } - it { is_expected.to run.with_params(true, 'yes', 'no').and_return("yes") } - it { is_expected.to run.with_params(false, 'yes', 'no').and_return("no") } - -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/camelcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/camelcase_spec.rb deleted file mode 100755 index c78aa62ff..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/camelcase_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'camelcase' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("abc").and_return("Abc") } - it { is_expected.to run.with_params("aa_bb_cc").and_return("AaBbCc") } - it { is_expected.to run.with_params("_aa__bb__cc_").and_return("AaBbCc") } - it { is_expected.to run.with_params("100").and_return("100") } - it { is_expected.to run.with_params("1_00").and_return("100") } - it { is_expected.to run.with_params("_").and_return("") } - it { is_expected.to run.with_params("").and_return("") } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(["abc", "aa_bb_cc"]).and_return(["Abc", "AaBbCc"]) } - it { is_expected.to run.with_params(["abc", 1, "aa_bb_cc"]).and_return(["Abc", 1, "AaBbCc"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/capitalize_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/capitalize_spec.rb deleted file mode 100755 index 7ce2e1630..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/capitalize_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'capitalize' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("one").and_return("One") } - it { is_expected.to run.with_params("one two").and_return("One two") } - it { is_expected.to run.with_params("ONE TWO").and_return("One two") } - - it { is_expected.to run.with_params(AlsoString.new("one")).and_return("One") } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(["one", "two"]).and_return(["One", "Two"]) } - it { is_expected.to run.with_params(["one", 1, "two"]).and_return(["One", 1, "Two"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/ceiling_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/ceiling_spec.rb deleted file mode 100755 index 567426fd3..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/ceiling_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe 'ceiling' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params(-34).and_return(-34) } - it { is_expected.to run.with_params(33.1).and_return(34) } - it { is_expected.to run.with_params(-33.1).and_return(-33) } -end - diff --git a/vagrant/puppet/modules/stdlib/spec/functions/chomp_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/chomp_spec.rb deleted file mode 100755 index 687874292..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/chomp_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'chomp' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params("one").and_return("one") } - it { is_expected.to run.with_params("one\n").and_return("one") } - it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "two", "three"]) } - - it { is_expected.to run.with_params(AlsoString.new("one")).and_return("one") } - it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } - it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } - it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "two", "three"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/chop_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/chop_spec.rb deleted file mode 100755 index db7d18b8c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/chop_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'chop' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params("one").and_return("on") } - it { is_expected.to run.with_params("one\n").and_return("one") } - it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "tw", "three"]) } - - it { is_expected.to run.with_params(AlsoString.new("one")).and_return("on") } - it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } - it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } - it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "tw", "three"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/clamp_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/clamp_spec.rb deleted file mode 100644 index 3e2fe7ac3..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/clamp_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe 'clamp' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, /Wrong number of arguments, need three to clamp/) } - it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, /Required explicit numeric/) } - it { is_expected.to run.with_params(1, 2, {'a' => 55}).and_raise_error(Puppet::ParseError, /The Hash type is not allowed/) } - it { is_expected.to run.with_params('24', [575, 187]).and_return(187) } - it { is_expected.to run.with_params([4, 3, '99']).and_return(4) } - it { is_expected.to run.with_params(16, 750, 88).and_return(88) } - it { is_expected.to run.with_params([3, 873], 73).and_return(73) } - it { is_expected.to run.with_params([4], 8, 75).and_return(8) } - it { is_expected.to run.with_params([6], [31], 9911).and_return(31) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/concat_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/concat_spec.rb deleted file mode 100755 index eb762338e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/concat_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'concat' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) } - it { is_expected.to run.with_params(['1','2','3'],['4','5','6']).and_return(['1','2','3','4','5','6']) } - it { is_expected.to run.with_params(['1','2','3'],'4').and_return(['1','2','3','4']) } - it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) } - it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) } - it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) } - it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) } - - it "should leave the original array intact" do - argument1 = ['1','2','3'] - original1 = argument1.dup - argument2 = ['4','5','6'] - original2 = argument2.dup - result = subject.call([argument1,argument2]) - expect(argument1).to eq(original1) - expect(argument2).to eq(original2) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/convert_base_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/convert_base_spec.rb deleted file mode 100644 index 8ab228454..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/convert_base_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'convert_base' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { is_expected.to run.with_params("asdf").and_raise_error(ArgumentError) } - it { is_expected.to run.with_params("asdf","moo","cow").and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(["1"],"2").and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) } - it { is_expected.to run.with_params("1",["2"]).and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) } - it { is_expected.to run.with_params("1",1).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) } - it { is_expected.to run.with_params("1",37).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) } - - it "should raise a ParseError if argument 1 is a string that does not correspond to an integer in base 10" do - is_expected.to run.with_params("ten",6).and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/) - end - - it "should raise a ParseError if argument 2 is a string and does not correspond to an integer in base 10" do - is_expected.to run.with_params(100,"hex").and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/) - end - - it { is_expected.to run.with_params("11",'16').and_return('b') } - it { is_expected.to run.with_params("35",'36').and_return('z') } - it { is_expected.to run.with_params(5, 2).and_return('101') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/count_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/count_spec.rb deleted file mode 100755 index c8d19601c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/count_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe 'count' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { is_expected.to run.with_params("one").and_raise_error(ArgumentError) } - it { is_expected.to run.with_params("one", "two").and_return(1) } - it { - pending("should actually be like this, and not like above") - is_expected.to run.with_params("one", "two").and_raise_error(ArgumentError) - } - it { is_expected.to run.with_params("one", "two", "three").and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(["one", "two", "three"]).and_return(3) } - it { is_expected.to run.with_params(["one", "two", "two"], "two").and_return(2) } - it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) } - it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) } - it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/deep_merge_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/deep_merge_spec.rb deleted file mode 100755 index 397e048ce..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/deep_merge_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' - -describe 'deep_merge' do - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) } - it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) } - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}, {}).and_return({}) } - it { is_expected.to run.with_params({'key' => 'value'}, '').and_return({'key' => 'value'}) } - it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2' }).and_return({'key1' => 'value1', 'key2' => 'value2'}) } - - describe 'when arguments have key collisions' do - it 'should prefer values from the last hash' do - is_expected.to run \ - .with_params( - {'key1' => 'value1', 'key2' => 'value2' }, - {'key2' => 'replacement_value', 'key3' => 'value3'}) \ - .and_return( - {'key1' => 'value1', 'key2' => 'replacement_value', 'key3' => 'value3'}) - end - it { is_expected.to run \ - .with_params({'key1' => 'value1'}, {'key1' => 'value2'}, {'key1' => 'value3'}) \ - .and_return({'key1' => 'value3' }) - } - end - - describe 'when arguments have subhashes' do - it { is_expected.to run \ - .with_params({'key1' => 'value1'}, {'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}}) \ - .and_return( {'key1' => 'value1', 'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}}) - } - it { is_expected.to run \ - .with_params({'key1' => {'subkey1' => 'value1'}}, {'key1' => {'subkey2' => 'value2'}}) \ - .and_return( {'key1' => {'subkey1' => 'value1', 'subkey2' => 'value2'}}) - } - it { is_expected.to run \ - .with_params({'key1' => {'subkey1' => {'subsubkey1' => 'value1'}}}, {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}}) \ - .and_return( {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}}) - } - end - - it 'should not change the original hashes' do - argument1 = { 'key1' => 'value1' } - original1 = argument1.dup - argument2 = { 'key2' => 'value2' } - original2 = argument2.dup - - subject.call([argument1, argument2]) - expect(argument1).to eq(original1) - expect(argument2).to eq(original2) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/defined_with_params_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/defined_with_params_spec.rb deleted file mode 100755 index 516d986db..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/defined_with_params_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'defined_with_params' do - describe 'when no resource is specified' do - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - end - describe 'when compared against a resource with no attributes' do - let :pre_condition do - 'user { "dan": }' - end - it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } - it { is_expected.to run.with_params('User[bob]', {}).and_return(false) } - it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) } - end - - describe 'when compared against a resource with attributes' do - let :pre_condition do - 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}' - end - it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } - it { is_expected.to run.with_params('User[dan]', '').and_return(true) } - it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) } - it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) } - it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/delete_at_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/delete_at_spec.rb deleted file mode 100755 index 0e19472ef..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/delete_at_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'delete_at' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError) } - it { - pending("Current implementation ignores parameters after the first two.") - is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError) - } - - describe 'argument validation' do - it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError) } - end - - it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) } - it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) } - it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) } - - it "should leave the original array intact" do - argument = [1, 2, 3] - original = argument.dup - result = subject.call([argument,2]) - expect(argument).to eq(original) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/delete_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/delete_spec.rb deleted file mode 100755 index cf696ac78..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/delete_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' - -describe 'delete' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } - - describe 'deleting from an array' do - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) } - end - - describe 'deleting from a string' do - it { is_expected.to run.with_params('', '').and_return('') } - it { is_expected.to run.with_params('bar', '').and_return('bar') } - it { is_expected.to run.with_params('', 'bar').and_return('') } - it { is_expected.to run.with_params('bar', 'bar').and_return('') } - it { is_expected.to run.with_params('barbar', 'bar').and_return('') } - it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') } - it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') } - it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') } - # this is so sick - it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') } - it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') } - end - - describe 'deleting from an array' do - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({}, 'key').and_return({}) } - it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \ - .and_return( {'key1' => 'value1', 'key3' => 'value3'}) - } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \ - .and_return( {'key3' => 'value3'}) - } - end - - it "should leave the original array intact" do - argument1 = ['one','two','three'] - original1 = argument1.dup - result = subject.call([argument1,'two']) - expect(argument1).to eq(original1) - end - it "should leave the original string intact" do - argument1 = 'onetwothree' - original1 = argument1.dup - result = subject.call([argument1,'two']) - expect(argument1).to eq(original1) - end - it "should leave the original hash intact" do - argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'} - original1 = argument1.dup - result = subject.call([argument1,'key2']) - expect(argument1).to eq(original1) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/delete_undef_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/delete_undef_values_spec.rb deleted file mode 100755 index ec9fb9c23..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/delete_undef_values_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper' - -describe 'delete_undef_values' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - - describe 'when deleting from an array' do - [ :undef, '', nil ].each do |undef_value| - describe "when undef is represented by #{undef_value.inspect}" do - before do - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == '' - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil - end - it { is_expected.to run.with_params([undef_value]).and_return([]) } - it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) } - end - - it "should leave the original argument intact" do - argument = ['one',undef_value,'two'] - original = argument.dup - result = subject.call([argument,2]) - expect(argument).to eq(original) - end - end - - it { is_expected.to run.with_params(['undef']).and_return(['undef']) } - end - - describe 'when deleting from a hash' do - [ :undef, '', nil ].each do |undef_value| - describe "when undef is represented by #{undef_value.inspect}" do - before do - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == '' - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil - end - it { is_expected.to run.with_params({'key' => undef_value}).and_return({}) } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2'}) \ - .and_return({'key1' => 'value1', 'key2' => 'value2'}) - } - end - - it "should leave the original argument intact" do - argument = { 'key1' => 'value1', 'key2' => undef_value } - original = argument.dup - result = subject.call([argument,2]) - expect(argument).to eq(original) - end - end - - it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/delete_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/delete_values_spec.rb deleted file mode 100755 index 12907d4b7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/delete_values_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe 'delete_values' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - describe 'when the first argument is not a hash' do - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError) } - end - - describe 'when deleting from a hash' do - it { is_expected.to run.with_params({}, 'value').and_return({}) } - it { is_expected.to run \ - .with_params({'key1' => 'value1'}, 'non-existing value') \ - .and_return({'key1' => 'value1'}) - } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value to delete'}, 'value to delete') \ - .and_return({'key1' => 'value1'}) - } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \ - .and_return({'key1' => 'value1'}) - } - end - - it "should leave the original argument intact" do - argument = { 'key1' => 'value1', 'key2' => 'value2' } - original = argument.dup - result = subject.call([argument, 'value2']) - expect(argument).to eq(original) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/difference_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/difference_spec.rb deleted file mode 100755 index d5e983d8f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/difference_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'difference' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return([]) } - it { is_expected.to run.with_params(['one'], ['one']).and_return([]) } - it { is_expected.to run.with_params(['one'], []).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) } - it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/dig_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/dig_spec.rb deleted file mode 100644 index 1c5d49d23..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/dig_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe 'dig' do - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('bad', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}, 'bad').and_raise_error(Puppet::ParseError) } - - it { is_expected.to run.with_params({}, []).and_return({}) } - it { is_expected.to run.with_params({"a" => "b"}, ["a"]).and_return("b") } - it { is_expected.to run.with_params({"a" => {"b" => "c"}}, ["a", "b"]).and_return("c") } - it { is_expected.to run.with_params({}, ["a", "b"], "d").and_return("d") } - it { is_expected.to run.with_params({"a" => false}, ["a"]).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/dirname_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/dirname_spec.rb deleted file mode 100755 index 46c4c35c7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/dirname_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe 'dirname' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/dos2unix_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/dos2unix_spec.rb deleted file mode 100644 index 9c84703cb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/dos2unix_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'dos2unix' do - context 'Checking parameter validity' do - it { is_expected.not_to eq(nil) } - it do - is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/) - end - it do - is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/) - end - it do - is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) - end - end - - context 'Converting from dos to unix format' do - sample_text = "Hello\r\nWorld\r\n" - desired_output = "Hello\nWorld\n" - - it 'should output unix format' do - should run.with_params(sample_text).and_return(desired_output) - end - end - - context 'Converting from unix to unix format' do - sample_text = "Hello\nWorld\n" - desired_output = "Hello\nWorld\n" - - it 'should output unix format' do - should run.with_params(sample_text).and_return(desired_output) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/downcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/downcase_spec.rb deleted file mode 100755 index c594560a0..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/downcase_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'downcase' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("abc").and_return("abc") } - it { is_expected.to run.with_params("Abc").and_return("abc") } - it { is_expected.to run.with_params("ABC").and_return("abc") } - - it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("abc") } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(["ONE", "TWO"]).and_return(["one", "two"]) } - it { is_expected.to run.with_params(["One", 1, "Two"]).and_return(["one", 1, "two"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/empty_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/empty_spec.rb deleted file mode 100755 index a3a25d6a0..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/empty_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'empty' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params(0).and_return(false) } - it { is_expected.to run.with_params('').and_return(true) } - it { is_expected.to run.with_params('one').and_return(false) } - - it { is_expected.to run.with_params(AlsoString.new('')).and_return(true) } - it { is_expected.to run.with_params(AlsoString.new('one')).and_return(false) } - - it { is_expected.to run.with_params([]).and_return(true) } - it { is_expected.to run.with_params(['one']).and_return(false) } - - it { is_expected.to run.with_params({}).and_return(true) } - it { is_expected.to run.with_params({'key' => 'value'}).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/ensure_packages_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/ensure_packages_spec.rb deleted file mode 100755 index c82473299..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/ensure_packages_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'ensure_packages' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { - pending("should not accept numbers as arguments") - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) - } - it { - pending("should not accept numbers as arguments") - is_expected.to run.with_params(["packagename", 1]).and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params("packagename") } - it { is_expected.to run.with_params(["packagename1", "packagename2"]) } - - context 'given a catalog with "package { puppet: ensure => absent }"' do - let(:pre_condition) { 'package { puppet: ensure => absent }' } - - describe 'after running ensure_package("facter")' do - before { subject.call(['facter']) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent') } - it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present') } - end - - describe 'after running ensure_package("facter", { "provider" => "gem" })' do - before { subject.call(['facter', { "provider" => "gem" }]) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider() } - it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present').with_provider("gem") } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/ensure_resource_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/ensure_resource_spec.rb deleted file mode 100755 index c4f2cbd0e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/ensure_resource_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' - -describe 'ensure_resource' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) } - it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) } - it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } - it { - pending("should not accept numbers as arguments") - is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError) - } - - context 'given a catalog with "user { username1: ensure => present }"' do - let(:pre_condition) { 'user { username1: ensure => present }' } - - describe 'after running ensure_resource("user", "username1", {})' do - before { subject.call(['User', 'username1', {}]) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } - end - - describe 'after running ensure_resource("user", "username2", {})' do - before { subject.call(['User', 'username2', {}]) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } - it { expect(lambda { catalogue }).to contain_user('username2').without_ensure } - end - - describe 'after running ensure_resource("user", ["username1", "username2"], {})' do - before { subject.call(['User', ['username1', 'username2'], {}]) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } - it { expect(lambda { catalogue }).to contain_user('username2').without_ensure } - end - - describe 'when providing already set params' do - let(:params) { { 'ensure' => 'present' } } - before { subject.call(['User', ['username2', 'username3'], params]) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(lambda { catalogue }).to contain_user('username1').with(params) } - it { expect(lambda { catalogue }).to contain_user('username2').with(params) } - end - - context 'when trying to add params' do - it { is_expected.to run \ - .with_params('User', 'username1', { 'ensure' => 'present', 'shell' => true }) \ - .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, /User\[username1\] is already declared/) - } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/flatten_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/flatten_spec.rb deleted file mode 100755 index a4338be4d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/flatten_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'flatten' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params([['one']]).and_return(['one']) } - it { is_expected.to run.with_params(["a","b","c","d","e","f","g"]).and_return(["a","b","c","d","e","f","g"]) } - it { is_expected.to run.with_params([["a","b",["c",["d","e"],"f","g"]]]).and_return(["a","b","c","d","e","f","g"]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/floor_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/floor_spec.rb deleted file mode 100755 index 608c602fa..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/floor_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'floor' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params(-34).and_return(-34) } - it { is_expected.to run.with_params(33.1).and_return(33) } - it { is_expected.to run.with_params(-33.1).and_return(-34) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb deleted file mode 100644 index e4070846b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -describe 'fqdn_rand_string' do - let(:default_charset) { %r{\A[a-zA-Z0-9]{100}\z} } - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(0).and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(1.5).and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(-10).and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params("-10").and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params("string").and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params({}).and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be undef or a string/) } - it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be undef or a string/) } - it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be undef or a string/) } - it { is_expected.to run.with_params(100).and_return(default_charset) } - it { is_expected.to run.with_params("100").and_return(default_charset) } - it { is_expected.to run.with_params(100, nil).and_return(default_charset) } - it { is_expected.to run.with_params(100, '').and_return(default_charset) } - it { is_expected.to run.with_params(100, 'a').and_return(/\Aa{100}\z/) } - it { is_expected.to run.with_params(100, 'ab').and_return(/\A[ab]{100}\z/) } - - it "provides the same 'random' value on subsequent calls for the same host" do - expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10)) - end - - it "considers the same host and same extra arguments to have the same random sequence" do - first_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"]) - second_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"]) - - expect(first_random).to eql(second_random) - end - - it "allows extra arguments to control the random value on a single host" do - first_random = fqdn_rand_string(10, :extra_identifier => [1, "different", "host"]) - second_different_random = fqdn_rand_string(10, :extra_identifier => [2, "different", "host"]) - - expect(first_random).not_to eql(second_different_random) - end - - it "should return different strings for different hosts" do - val1 = fqdn_rand_string(10, :host => "first.host.com") - val2 = fqdn_rand_string(10, :host => "second.host.com") - - expect(val1).not_to eql(val2) - end - - def fqdn_rand_string(max, args = {}) - host = args[:host] || '127.0.0.1' - charset = args[:charset] - extra = args[:extra_identifier] || [] - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - scope.stubs(:lookupvar).with("::fqdn", {}).returns(host) - - function_args = [max] - if args.has_key?(:charset) or !extra.empty? - function_args << charset - end - function_args += extra - scope.function_fqdn_rand_string(function_args) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rotate_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rotate_spec.rb deleted file mode 100755 index db7a71732..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/fqdn_rotate_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'spec_helper' - -describe 'fqdn_rotate' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - - it "should rotate a string and the result should be the same size" do - expect(fqdn_rotate("asdf").size).to eq(4) - end - - it "should rotate a string to give the same results for one host" do - val1 = fqdn_rotate("abcdefg", :host => 'one') - val2 = fqdn_rotate("abcdefg", :host => 'one') - expect(val1).to eq(val2) - end - - it "allows extra arguments to control the random rotation on a single host" do - val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "different", "host"]) - val2 = fqdn_rotate("abcdefg", :extra_identifier => [2, "different", "host"]) - expect(val1).not_to eq(val2) - end - - it "considers the same host and same extra arguments to have the same random rotation" do - val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"]) - val2 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"]) - expect(val1).to eq(val2) - end - - it "should rotate a string to give different values on different hosts" do - val1 = fqdn_rotate("abcdefg", :host => 'one') - val2 = fqdn_rotate("abcdefg", :host => 'two') - expect(val1).not_to eq(val2) - end - - it "should accept objects which extend String" do - result = fqdn_rotate(AlsoString.new('asdf')) - expect(result).to eq('dfas') - end - - it "should use the Puppet::Util.deterministic_rand function" do - if Puppet::Util.respond_to?(:deterministic_rand) - Puppet::Util.expects(:deterministic_rand).with(44489829212339698569024999901561968770,4) - fqdn_rotate("asdf") - else - skip 'Puppet::Util#deterministic_rand not available' - end - end - - it "should not leave the global seed in a deterministic state" do - fqdn_rotate("asdf") - rand1 = rand() - fqdn_rotate("asdf") - rand2 = rand() - expect(rand1).not_to eql(rand2) - end - - def fqdn_rotate(value, args = {}) - host = args[:host] || '127.0.0.1' - extra = args[:extra_identifier] || [] - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - scope.stubs(:lookupvar).with("::fqdn").returns(host) - - function_args = [value] + extra - scope.function_fqdn_rotate(function_args) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/get_module_path_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/get_module_path_spec.rb deleted file mode 100755 index a39e413d5..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/get_module_path_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -describe 'get_module_path' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) } - - class StubModule - attr_reader :path - def initialize(path) - @path = path - end - end - - describe 'when locating a module' do - let(:modulepath) { "/tmp/does_not_exist" } - let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") } - - before(:each) { Puppet[:modulepath] = modulepath } - - context 'in the default environment' do - before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').returns(path_of_module_foo) } - - it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) } - - context 'when the modulepath is a list' do - before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' } - - it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) } - end - end - - context 'in a non-default default environment' do - let(:environment) { 'test' } - before(:each) { Puppet::Module.expects(:find).with('foo', 'test').returns(path_of_module_foo) } - - it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) } - - context 'when the modulepath is a list' do - before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' } - - it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) } - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/getparam_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/getparam_spec.rb deleted file mode 100755 index 9e3d9e470..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/getparam_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'getparam' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a reference/) } - it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, /Must specify name of a parameter/) } - it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, /Must specify name of a parameter/) } - it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, /Must specify name of a parameter/) } - it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, /Must specify name of a parameter/) } - - describe 'when compared against a user resource with no params' do - let(:pre_condition) { 'user { "one": }' } - - it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[one]', 'shell').and_return('') } - end - - describe 'when compared against a user resource with params' do - let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' } - - it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') } - it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') } - it { - pending("both rspec-puppet as well as the function do the wrong thing here.") - is_expected.to run.with_params('User[one]', 'managehome').and_return(false) - } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/getvar_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/getvar_spec.rb deleted file mode 100755 index 6ab137ec7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/getvar_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'getvar' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - context 'given variables in namespaces' do - let(:pre_condition) { - <<-'ENDofPUPPETcode' - class site::data { $foo = 'baz' } - include site::data - ENDofPUPPETcode - } - - it { is_expected.to run.with_params('site::data::foo').and_return('baz') } - it { is_expected.to run.with_params('::site::data::foo').and_return('baz') } - it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/grep_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/grep_spec.rb deleted file mode 100755 index 6e0bd6eb9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/grep_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'grep' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("grep does not actually check this, and raises NoMethodError instead") - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/) - } - it { - pending("grep does not actually check this, and raises NoMethodError instead") - is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/) - } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/has_interface_with_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/has_interface_with_spec.rb deleted file mode 100755 index 7334d38b9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/has_interface_with_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'has_interface_with' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - # We need to mock out the Facts so we can specify how we expect this function - # to behave on different platforms. - context "On Mac OS X Systems" do - let(:facts) { { :interfaces => 'lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0' } } - it { is_expected.to run.with_params('lo0').and_return(true) } - it { is_expected.to run.with_params('lo').and_return(false) } - end - - context "On Linux Systems" do - let(:facts) do - { - :interfaces => 'eth0,lo', - :ipaddress => '10.0.0.1', - :ipaddress_lo => '127.0.0.1', - :ipaddress_eth0 => '10.0.0.1', - :muppet => 'kermit', - :muppet_lo => 'mspiggy', - :muppet_eth0 => 'kermit', - } - end - - it { is_expected.to run.with_params('lo').and_return(true) } - it { is_expected.to run.with_params('lo0').and_return(false) } - it { is_expected.to run.with_params('ipaddress', '127.0.0.1').and_return(true) } - it { is_expected.to run.with_params('ipaddress', '10.0.0.1').and_return(true) } - it { is_expected.to run.with_params('ipaddress', '8.8.8.8').and_return(false) } - it { is_expected.to run.with_params('muppet', 'kermit').and_return(true) } - it { is_expected.to run.with_params('muppet', 'mspiggy').and_return(true) } - it { is_expected.to run.with_params('muppet', 'bigbird').and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/has_ip_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/has_ip_address_spec.rb deleted file mode 100755 index 42a5a7926..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/has_ip_address_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'has_ip_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - context "On Linux Systems" do - let(:facts) do - { - :interfaces => 'eth0,lo', - :ipaddress => '10.0.0.1', - :ipaddress_lo => '127.0.0.1', - :ipaddress_eth0 => '10.0.0.1', - } - end - - it { is_expected.to run.with_params('127.0.0.1').and_return(true) } - it { is_expected.to run.with_params('10.0.0.1').and_return(true) } - it { is_expected.to run.with_params('8.8.8.8').and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/has_ip_network_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/has_ip_network_spec.rb deleted file mode 100755 index 7b5fe66ac..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/has_ip_network_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'has_ip_network' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - context "On Linux Systems" do - let(:facts) do - { - :interfaces => 'eth0,lo', - :network => :undefined, - :network_lo => '127.0.0.0', - :network_eth0 => '10.0.0.0', - } - end - - it { is_expected.to run.with_params('127.0.0.0').and_return(true) } - it { is_expected.to run.with_params('10.0.0.0').and_return(true) } - it { is_expected.to run.with_params('8.8.8.0').and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/has_key_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/has_key_spec.rb deleted file mode 100755 index 965d5a657..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/has_key_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'has_key' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) } - it { is_expected.to run.with_params(1, "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) } - it { is_expected.to run.with_params([], "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) } - - it { is_expected.to run.with_params({ 'key' => 'value' }, "key").and_return(true) } - it { is_expected.to run.with_params({}, "key").and_return(false) } - it { is_expected.to run.with_params({ 'key' => 'value'}, "not a key").and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/hash_spec.rb deleted file mode 100755 index 4fe99ceeb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/hash_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'hash' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /Unable to compute/) } - it { is_expected.to run.with_params([]).and_return({}) } - it { is_expected.to run.with_params(['key1', 'value1']).and_return({ 'key1' => 'value1' }) } - it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return({ 'key1' => 'value1', 'key2' => 'value2' }) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/intersection_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/intersection_spec.rb deleted file mode 100755 index c0f608690..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/intersection_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'intersection' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return([]) } - it { is_expected.to run.with_params(['one'], []).and_return([]) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) } - it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_a_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_a_spec.rb deleted file mode 100644 index 8dec13f5a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_a_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -if ENV["FUTURE_PARSER"] == 'yes' - describe 'type_of' do - pending 'teach rspec-puppet to load future-only functions under 3.7.5' do - it { is_expected.not_to eq(nil) } - end - end -end - -if Puppet.version.to_f >= 4.0 - describe 'is_a' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) } - - it 'succeeds when comparing a string and a string' do - is_expected.to run.with_params('hello world', String).and_return(true) - end - - it 'fails when comparing an integer and a string' do - is_expected.to run.with_params(5, String).and_return(false) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_array_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_array_spec.rb deleted file mode 100755 index 7dd21c23b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_array_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'is_array' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params([]).and_return(true) } - it { is_expected.to run.with_params(['one']).and_return(true) } - it { is_expected.to run.with_params([1]).and_return(true) } - it { is_expected.to run.with_params([{}]).and_return(true) } - it { is_expected.to run.with_params([[]]).and_return(true) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_bool_spec.rb deleted file mode 100755 index 76d619b00..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_bool_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'is_bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(true).and_return(true) } - it { is_expected.to run.with_params(false).and_return(true) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params([{}]).and_return(false) } - it { is_expected.to run.with_params([[]]).and_return(false) } - it { is_expected.to run.with_params([true]).and_return(false) } - it { is_expected.to run.with_params('true').and_return(false) } - it { is_expected.to run.with_params('false').and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_domain_name_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_domain_name_spec.rb deleted file mode 100755 index c1bf0e34b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_domain_name_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' - -describe 'is_domain_name' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('.').and_return(true) } - it { is_expected.to run.with_params('com').and_return(true) } - it { is_expected.to run.with_params('com.').and_return(true) } - it { is_expected.to run.with_params('x.com').and_return(true) } - it { is_expected.to run.with_params('x.com.').and_return(true) } - it { is_expected.to run.with_params('foo.example.com').and_return(true) } - it { is_expected.to run.with_params('foo.example.com.').and_return(true) } - it { is_expected.to run.with_params('2foo.example.com').and_return(true) } - it { is_expected.to run.with_params('2foo.example.com.').and_return(true) } - it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) } - it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) } - describe 'inputs with spaces' do - it { is_expected.to run.with_params('invalid domain').and_return(false) } - end - describe 'inputs with hyphens' do - it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) } - it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) } - it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) } - it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) } - it { is_expected.to run.with_params('-foo.example.com').and_return(false) } - it { is_expected.to run.with_params('-foo.example.com').and_return(false) } - end - # Values obtained from Facter values will be frozen strings - # in newer versions of Facter: - it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) } - describe 'top level domain must be alphabetic if there are multiple labels' do - it { is_expected.to run.with_params('2com').and_return(true) } - it { is_expected.to run.with_params('www.example.2com').and_return(false) } - end - describe 'IP addresses are not domain names' do - it { is_expected.to run.with_params('192.168.1.1').and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_email_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_email_address_spec.rb deleted file mode 100755 index 8b7b358da..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_email_address_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'is_email_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('bob@gmail.com').and_return(true) } - it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com').and_return(true) } - it { is_expected.to run.with_params('peter.parker@gmail.com').and_return(true) } - it { is_expected.to run.with_params('1.2.3@domain').and_return(false) } - it { is_expected.to run.with_params('1.2.3.4.5@').and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_float_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_float_spec.rb deleted file mode 100755 index ffff971a7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_float_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'is_float' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'passing a string' do - it { is_expected.to run.with_params('0.1').and_return(true) } - it { is_expected.to run.with_params('1.0').and_return(true) } - it { is_expected.to run.with_params('1').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params('one 1.0').and_return(false) } - it { is_expected.to run.with_params('1.0 one').and_return(false) } - end - - describe 'passing numbers' do - it { is_expected.to run.with_params(0.1).and_return(true) } - it { is_expected.to run.with_params(1.0).and_return(true) } - it { is_expected.to run.with_params(1).and_return(false) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_function_available.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_function_available.rb deleted file mode 100755 index 44f08c081..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_function_available.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' - -describe 'is_function_available' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('include').and_return(true) } - it { is_expected.to run.with_params('no_such_function').and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_hash_spec.rb deleted file mode 100755 index c2599a02a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_hash_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'is_hash' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params({}).and_return(true) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_integer_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_integer_spec.rb deleted file mode 100755 index 67263c18f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_integer_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'is_integer' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - it { is_expected.to run.with_params(3).and_return(true) } - it { is_expected.to run.with_params('3').and_return(true) } - it { is_expected.to run.with_params(-3).and_return(true) } - it { is_expected.to run.with_params('-3').and_return(true) } - - it { is_expected.to run.with_params(3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - it { is_expected.to run.with_params(-3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('0001234').and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_ip_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_ip_address_spec.rb deleted file mode 100755 index a7a383a1e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_ip_address_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'is_ip_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('1.2.3.4').and_return(true) } - it { is_expected.to run.with_params('1.2.3.255').and_return(true) } - it { is_expected.to run.with_params('1.2.3.256').and_return(false) } - it { is_expected.to run.with_params('1.2.3').and_return(false) } - it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } - it { is_expected.to run.with_params('fe00::1').and_return(true) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74').and_return(true) } - it { is_expected.to run.with_params('FE80:0000:CD12:D123:E2F8:47FF:FE09:DD74').and_return(true) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:zzzz').and_return(false) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09').and_return(false) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74:dd74').and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_mac_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_mac_address_spec.rb deleted file mode 100755 index 5f76a91b4..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_mac_address_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'is_mac_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('00:a0:1f:12:7f:a0').and_return(true) } - it { is_expected.to run.with_params('00:A0:1F:12:7F:A0').and_return(true) } - it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { - pending "should properly typecheck its arguments" - is_expected.to run.with_params(1).and_return(false) - } - it { - pending "should properly typecheck its arguments" - is_expected.to run.with_params({}).and_return(false) - } - it { - pending "should properly typecheck its arguments" - is_expected.to run.with_params([]).and_return(false) - } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_numeric_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_numeric_spec.rb deleted file mode 100755 index d0f5a6eb6..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_numeric_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'is_numeric' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - it { is_expected.to run.with_params(3).and_return(true) } - it { is_expected.to run.with_params('3').and_return(true) } - it { is_expected.to run.with_params(-3).and_return(true) } - it { is_expected.to run.with_params('-3').and_return(true) } - - it { is_expected.to run.with_params(3.7).and_return(true) } - it { is_expected.to run.with_params('3.7').and_return(true) } - it { is_expected.to run.with_params(-3.7).and_return(true) } - it { is_expected.to run.with_params('3.7').and_return(true) } - - it { is_expected.to run.with_params('-342.2315e-12').and_return(true) } - - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('0001234').and_return(false) } - it { is_expected.to run.with_params(' - 1234').and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/is_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/is_string_spec.rb deleted file mode 100755 index 8e459ccfe..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/is_string_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'is_string' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - - it { is_expected.to run.with_params(3).and_return(false) } - it { is_expected.to run.with_params('3').and_return(false) } - it { is_expected.to run.with_params(-3).and_return(false) } - it { is_expected.to run.with_params('-3').and_return(false) } - - it { is_expected.to run.with_params(3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - it { is_expected.to run.with_params(-3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('one').and_return(true) } - it { is_expected.to run.with_params('0001234').and_return(true) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/join_keys_to_values_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/join_keys_to_values_spec.rb deleted file mode 100755 index 6c109d1c2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/join_keys_to_values_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'join_keys_to_values' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) } - it { is_expected.to run.with_params({}, '', '').and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) } - it { is_expected.to run.with_params('one', '').and_raise_error(TypeError, /The first argument must be a hash/) } - it { is_expected.to run.with_params({}, 2).and_raise_error(TypeError, /The second argument must be a string/) } - - it { is_expected.to run.with_params({}, '').and_return([]) } - it { is_expected.to run.with_params({}, ':').and_return([]) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) } - it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) } - it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) } - it 'should run join_keys_to_values(, ":") and return the proper array' do - result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }, ':']) - expect(result.sort).to eq(['key1:value1', 'key2:value2'].sort) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/join_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/join_spec.rb deleted file mode 100755 index a3005714b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/join_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'join' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the second.") - is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Requires array to work with/) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /Requires string to work with/) } - - it { is_expected.to run.with_params([]).and_return('') } - it { is_expected.to run.with_params([], ':').and_return('') } - it { is_expected.to run.with_params(['one']).and_return('one') } - it { is_expected.to run.with_params(['one'], ':').and_return('one') } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') } - it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/keys_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/keys_spec.rb deleted file mode 100755 index 2e009dcc8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/keys_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'keys' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Requires hash to work with/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires hash to work with/) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /Requires hash to work with/) } - it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key']) } - it 'should return the array of keys' do - result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }]) - expect(result).to match_array(['key1', 'key2']) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/load_module_metadata_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/load_module_metadata_spec.rb deleted file mode 100755 index fe665fb50..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/load_module_metadata_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'load_module_metadata' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - it "should json parse the file" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with(/metadata.json/).and_return(true) - allow(File).to receive(:read).with(/metadata.json/).and_return('{"name": "spencer-science"}') - - result = subject.call(['science']) - expect(result['name']).to eq('spencer-science') - end - - it "should fail by default if there is no metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with(/metadata.json/).and_return(false) - expect {subject.call(['science'])}.to raise_error(Puppet::ParseError) - end - - it "should return nil if user allows empty metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with(/metadata.json/).and_return(false) - result = subject.call(['science', true]) - expect(result).to eq({}) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/loadyaml_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/loadyaml_spec.rb deleted file mode 100755 index ffc714d11..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/loadyaml_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'loadyaml' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - context 'when a non-existing file is specified' do - let(:filename) { '/tmp/doesnotexist' } - before { - File.expects(:exists?).with(filename).returns(false).once - YAML.expects(:load_file).never - } - it { is_expected.to run.with_params(filename).and_return(nil) } - end - context 'when an existing file is specified' do - let(:filename) { '/tmp/doesexist' } - let(:data) { { 'key' => 'value' } } - before { - File.expects(:exists?).with(filename).returns(true).once - YAML.expects(:load_file).with(filename).returns(data).once - } - it { is_expected.to run.with_params(filename).and_return(data) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/lstrip_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/lstrip_spec.rb deleted file mode 100755 index 981794edf..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/lstrip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'lstrip' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params("\tone").and_return('one') } - it { is_expected.to run.with_params("\t one").and_return('one') } - it { is_expected.to run.with_params('one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params("\tone ").and_return('one ') } - it { is_expected.to run.with_params("\t one ").and_return('one ') } - it { is_expected.to run.with_params("one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params("\tone \t").and_return("one \t") } - it { is_expected.to run.with_params("\t one \t").and_return("one \t") } - it { is_expected.to run.with_params(' o n e ').and_return('o n e ') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one ') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/max_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/max_spec.rb deleted file mode 100755 index 66fb0c869..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/max_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'max' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(1, 2).and_return(2) } - it { is_expected.to run.with_params(1, 2, 3).and_return(3) } - it { is_expected.to run.with_params(3, 2, 1).and_return(3) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('two') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('two') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('two') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return('one') } - it { is_expected.to run.with_params('1', 'one').and_return('one') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.4e0') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.3e1) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/member_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/member_spec.rb deleted file mode 100755 index 527f887fa..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/member_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'member' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params([], '').and_return(false) } - it { is_expected.to run.with_params([], ['']).and_return(false) } - it { is_expected.to run.with_params([''], '').and_return(true) } - it { is_expected.to run.with_params([''], ['']).and_return(true) } - it { is_expected.to run.with_params([], 'one').and_return(false) } - it { is_expected.to run.with_params([], ['one']).and_return(false) } - it { is_expected.to run.with_params(['one'], 'one').and_return(true) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/merge_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/merge_spec.rb deleted file mode 100755 index 7b53363ed..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/merge_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'merge' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, /unexpected argument type String/) } - it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) } - it { - pending 'should not special case this' - is_expected.to run.with_params({}).and_return({}) - } - it { is_expected.to run.with_params({}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}).and_return({}) } - describe 'should accept empty strings as puppet undef' do - it { is_expected.to run.with_params({}, '').and_return({}) } - end - it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return({ 'key' => 'value' }) } - it { is_expected.to run.with_params({}, { 'key' => 'value' }).and_return({ 'key' => 'value' }) } - it { is_expected.to run.with_params({ 'key' => 'value1' }, { 'key' => 'value2' }).and_return({ 'key' => 'value2' }) } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, { 'key3' => 'value3' }) \ - .and_return({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }) - } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/min_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/min_spec.rb deleted file mode 100755 index c840a72c9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/min_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'min' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(1, 2).and_return(1) } - it { is_expected.to run.with_params(1, 2, 3).and_return(1) } - it { is_expected.to run.with_params(3, 2, 1).and_return(1) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return(1) } - it { is_expected.to run.with_params('1', 'one').and_return('1') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.3e1') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.4e0) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/num2bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/num2bool_spec.rb deleted file mode 100755 index 494afff9f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/num2bool_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'num2bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('abc').and_raise_error(Puppet::ParseError, /does not look like a number/) } - it { is_expected.to run.with_params(1).and_return(true) } - it { is_expected.to run.with_params('1').and_return(true) } - it { is_expected.to run.with_params(1.5).and_return(true) } - it { is_expected.to run.with_params('1.5').and_return(true) } - it { is_expected.to run.with_params(-1).and_return(false) } - it { is_expected.to run.with_params('-1').and_return(false) } - it { is_expected.to run.with_params(-1.5).and_return(false) } - it { is_expected.to run.with_params('-1.5').and_return(false) } - it { is_expected.to run.with_params(0).and_return(false) } - it { is_expected.to run.with_params('0').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, /does not look like a number/) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, /does not look like a number/) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/parsejson_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/parsejson_spec.rb deleted file mode 100755 index a01f1f67b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/parsejson_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper' - -describe 'parsejson' do - it 'should exist' do - is_expected.not_to eq(nil) - end - - it 'should raise an error if called without any arguments' do - is_expected.to run.with_params(). - and_raise_error(/wrong number of arguments/i) - end - - context 'with correct JSON data' do - - it 'should be able to parse a JSON data with a Hash' do - is_expected.to run.with_params('{"a":"1","b":"2"}'). - and_return({'a'=>'1', 'b'=>'2'}) - end - - it 'should be able to parse a JSON data with an Array' do - is_expected.to run.with_params('["a","b","c"]'). - and_return(['a', 'b', 'c']) - end - - it 'should be able to parse empty JSON values' do - is_expected.to run.with_params('[]'). - and_return([]) - is_expected.to run.with_params('{}'). - and_return({}) - end - - it 'should be able to parse a JSON data with a mixed structure' do - is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}'). - and_return({'a' =>'1', 'b' => 2, 'c' => { 'd' => [true, false] } }) - end - - it 'should not return the default value if the data was parsed correctly' do - is_expected.to run.with_params('{"a":"1"}', 'default_value'). - and_return({'a' => '1'}) - end - - end - - context 'with incorrect JSON data' do - it 'should raise an error with invalid JSON and no default' do - is_expected.to run.with_params(''). - and_raise_error(PSON::ParserError) - end - - it 'should support a structure for a default value' do - is_expected.to run.with_params('', {'a' => '1'}). - and_return({'a' => '1'}) - end - - ['', 1, 1.2, nil, true, false, [], {}, :yaml].each do |value| - it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do - is_expected.to run.with_params(value, 'default_value'). - and_return('default_value') - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/parseyaml_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/parseyaml_spec.rb deleted file mode 100755 index fa947ca6a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/parseyaml_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'spec_helper' - -describe 'parseyaml' do - it 'should exist' do - is_expected.not_to eq(nil) - end - - it 'should raise an error if called without any arguments' do - is_expected.to run.with_params(). - and_raise_error(/wrong number of arguments/i) - end - - context 'with correct YAML data' do - it 'should be able to parse a YAML data with a String' do - is_expected.to run.with_params('--- just a string'). - and_return('just a string') - is_expected.to run.with_params('just a string'). - and_return('just a string') - end - - it 'should be able to parse a YAML data with a Hash' do - is_expected.to run.with_params("---\na: '1'\nb: '2'\n"). - and_return({'a' => '1', 'b' => '2'}) - end - - it 'should be able to parse a YAML data with an Array' do - is_expected.to run.with_params("---\n- a\n- b\n- c\n"). - and_return(['a', 'b', 'c']) - end - - it 'should be able to parse a YAML data with a mixed structure' do - is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n d:\n - :a\n - true\n - false\n"). - and_return({'a' => '1', 'b' => 2, 'c' => {'d' => [:a, true, false]}}) - end - - it 'should not return the default value if the data was parsed correctly' do - is_expected.to run.with_params("---\na: '1'\n", 'default_value'). - and_return({'a' => '1'}) - end - - end - - context 'on a modern ruby', :unless => RUBY_VERSION == '1.8.7' do - it 'should raise an error with invalid YAML and no default' do - is_expected.to run.with_params('["one"'). - and_raise_error(Psych::SyntaxError) - end - end - - context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do - it 'should raise an error with invalid YAML and no default' do - is_expected.to run.with_params('["one"'). - and_raise_error(ArgumentError) - end - end - - context 'with incorrect YAML data' do - it 'should support a structure for a default value' do - is_expected.to run.with_params('', {'a' => '1'}). - and_return({'a' => '1'}) - end - - [1, 1.2, nil, true, false, [], {}, :yaml].each do |value| - it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do - is_expected.to run.with_params(value, 'default_value'). - and_return('default_value') - end - end - - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do - ['---', '...', '*8', ''].each do |value| - it "should return the default value for an incorrect #{value.inspect} string parameter" do - is_expected.to run.with_params(value, 'default_value'). - and_return('default_value') - end - end - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/pick_default_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/pick_default_spec.rb deleted file mode 100755 index e2fc64a11..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/pick_default_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'pick_default' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::Error, /Must receive at least one argument/) } - - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('', 'two').and_return('two') } - it { is_expected.to run.with_params(:undef, 'two').and_return('two') } - it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } - it { is_expected.to run.with_params(nil, 'two').and_return('two') } - - [ '', :undef, :undefined, nil, {}, [], 1, 'default' ].each do |value| - describe "when providing #{value.inspect} as default" do - it { is_expected.to run.with_params('one', value).and_return('one') } - it { is_expected.to run.with_params([], value).and_return([]) } - it { is_expected.to run.with_params({}, value).and_return({}) } - it { is_expected.to run.with_params(value, value).and_return(value) } - it { is_expected.to run.with_params(:undef, value).and_return(value) } - it { is_expected.to run.with_params(:undefined, value).and_return(value) } - it { is_expected.to run.with_params(nil, value).and_return(value) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/pick_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/pick_spec.rb deleted file mode 100755 index 2c7caa87e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/pick_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'pick' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) } - it { is_expected.to run.with_params('', nil, :undef, :undefined).and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) } - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('', 'two').and_return('two') } - it { is_expected.to run.with_params(:undef, 'two').and_return('two') } - it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } - it { is_expected.to run.with_params(nil, 'two').and_return('two') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/prefix_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/prefix_spec.rb deleted file mode 100755 index 37610221a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/prefix_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'prefix' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the second.") - is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array or a Hash/) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([''], '').and_return(['']) } - it { is_expected.to run.with_params(['one'], 'pre').and_return(['preone']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'pre').and_return(['preone', 'pretwo', 'prethree']) } - it { is_expected.to run.with_params({}).and_return({}) } - it { is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 }) } - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' }) } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'pre').and_return({ 'prekey' => 'value' }) } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'pre') \ - .and_return({ 'prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3' }) - } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/private_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/private_spec.rb deleted file mode 100644 index a13be6439..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/private_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper' - -describe 'private' do - it 'should issue a warning' do - scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") - begin - subject.call [] - rescue - # ignore this - end - end - - context "when called from inside module" do - it "should not fail" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('foo') - expect { - subject.call [] - }.not_to raise_error - end - end - - context "with an explicit failure message" do - it "prints the failure message on error" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - expect { - subject.call ['failure message!'] - }.to raise_error Puppet::ParseError, /failure message!/ - end - end - - context "when called from private class" do - it "should fail with a class error message" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - scope.source.expects(:name).returns('foo::baz') - scope.source.expects(:type).returns('hostclass') - expect { - subject.call [] - }.to raise_error Puppet::ParseError, /Class foo::baz is private/ - end - end - - context "when called from private definition" do - it "should fail with a class error message" do - scope.expects(:lookupvar).with('module_name').returns('foo') - scope.expects(:lookupvar).with('caller_module_name').returns('bar') - scope.source.expects(:name).returns('foo::baz') - scope.source.expects(:type).returns('definition') - expect { - subject.call [] - }.to raise_error Puppet::ParseError, /Definition foo::baz is private/ - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/pw_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/pw_hash_spec.rb deleted file mode 100644 index df5348c90..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/pw_hash_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper' - -describe 'pw_hash' do - - it { is_expected.not_to eq(nil) } - - context 'when there are less than 3 arguments' do - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('password').and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('password', 'sha-256').and_raise_error(ArgumentError, /wrong number of arguments/i) } - end - - context 'when there are more than 3 arguments' do - it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) } - end - - context 'when the first argument is not a string' do - it { is_expected.to run.with_params([], 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) } - it { is_expected.to run.with_params({}, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) } - it { is_expected.to run.with_params(1, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) } - it { is_expected.to run.with_params(true, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) } - end - - context 'when the first argument is undefined' do - it { is_expected.to run.with_params('', 'sha-256', 'salt').and_return(nil) } - it { is_expected.to run.with_params(nil, 'sha-256', 'salt').and_return(nil) } - end - - context 'when the second argument is not a string' do - it { is_expected.to run.with_params('password', [], 'salt').and_raise_error(ArgumentError, /second argument must be a string/) } - it { is_expected.to run.with_params('password', {}, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) } - it { is_expected.to run.with_params('password', 1, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) } - it { is_expected.to run.with_params('password', true, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) } - end - - context 'when the second argument is not one of the supported hashing algorithms' do - it { is_expected.to run.with_params('password', 'no such algo', 'salt').and_raise_error(ArgumentError, /is not a valid hash type/) } - end - - context 'when the third argument is not a string' do - it { is_expected.to run.with_params('password', 'sha-256', []).and_raise_error(ArgumentError, /third argument must be a string/) } - it { is_expected.to run.with_params('password', 'sha-256', {}).and_raise_error(ArgumentError, /third argument must be a string/) } - it { is_expected.to run.with_params('password', 'sha-256', 1).and_raise_error(ArgumentError, /third argument must be a string/) } - it { is_expected.to run.with_params('password', 'sha-256', true).and_raise_error(ArgumentError, /third argument must be a string/) } - end - - context 'when the third argument is empty' do - it { is_expected.to run.with_params('password', 'sha-512', '').and_raise_error(ArgumentError, /third argument must not be empty/) } - end - - context 'when the third argument contains invalid characters' do - it { is_expected.to run.with_params('password', 'sha-512', 'one%').and_raise_error(ArgumentError, /characters in salt must be in the set/) } - end - - context 'when running on a platform with a weak String#crypt implementation' do - before(:each) { allow_any_instance_of(String).to receive(:crypt).with('$1$1').and_return('a bad hash') } - - it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, /system does not support enhanced salts/) } - end - - if RUBY_PLATFORM == 'java' or 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.' - describe "on systems with enhanced salts support" do - it { is_expected.to run.with_params('password', 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } - it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') } - it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/range_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/range_spec.rb deleted file mode 100755 index 492cad40b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/range_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'spec_helper' - -describe 'range' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the third.") - is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, /Unable to compute range/i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Unknown range format/i) } - end - - describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do - it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params('').and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError) } - it { pending "the puppet 4 implementation"; is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError) } - end - - context 'with characters as bounds' do - it { is_expected.to run.with_params('d', 'a').and_return([]) } - it { is_expected.to run.with_params('a', 'a').and_return(['a']) } - it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) } - it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) } - it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) } - it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) } - it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) } - end - - context 'with strings as bounds' do - it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) } - it { is_expected.to run.with_params('two', 'one').and_return([]) } - it { is_expected.to run.with_params('true', 'false').and_return([]) } - it { is_expected.to run.with_params('false', 'true').and_return(['false']) } - end - - context 'with integers as bounds' do - it { is_expected.to run.with_params(4, 1).and_return([]) } - it { is_expected.to run.with_params(1, 1).and_return([1]) } - it { is_expected.to run.with_params(1, 2).and_return([1, 2]) } - it { is_expected.to run.with_params(1, 4).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, 1).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, '1').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, 2).and_return([1, 3]) } - it { is_expected.to run.with_params(1, 4, -2).and_return([1, 3]) } - it { is_expected.to run.with_params(1, 4, 3).and_return([1, 4]) } - it { is_expected.to run.with_params(1, 4, 4).and_return([1]) } - end - - context 'with integers as strings as bounds' do - it { is_expected.to run.with_params('4', '1').and_return([]) } - it { is_expected.to run.with_params('1', '1').and_return([1]) } - it { is_expected.to run.with_params('1', '2').and_return([1, 2]) } - it { is_expected.to run.with_params('1', '4').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', 1).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', '1').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', 2).and_return([1, 3]) } - it { is_expected.to run.with_params('1', '4', -2).and_return([1, 3]) } - it { is_expected.to run.with_params('1', '4', 3).and_return([1, 4]) } - it { is_expected.to run.with_params('1', '4', 4).and_return([1]) } - end - - context 'with prefixed numbers as strings as bounds' do - it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) } - it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) } - end - - context 'with dash-range syntax' do - it { is_expected.to run.with_params('4-1').and_return([]) } - it { is_expected.to run.with_params('1-1').and_return([1]) } - it { is_expected.to run.with_params('1-2').and_return([1, 2]) } - it { is_expected.to run.with_params('1-4').and_return([1, 2, 3, 4]) } - end - - context 'with two-dot-range syntax' do - it { is_expected.to run.with_params('4..1').and_return([]) } - it { is_expected.to run.with_params('1..1').and_return([1]) } - it { is_expected.to run.with_params('1..2').and_return([1, 2]) } - it { is_expected.to run.with_params('1..4').and_return([1, 2, 3, 4]) } - end - - context 'with three-dot-range syntax' do - it { is_expected.to run.with_params('4...1').and_return([]) } - it { is_expected.to run.with_params('1...1').and_return([]) } - it { is_expected.to run.with_params('1...2').and_return([1]) } - it { is_expected.to run.with_params('1...3').and_return([1, 2]) } - it { is_expected.to run.with_params('1...5').and_return([1, 2, 3, 4]) } - end - - describe 'when passing mixed arguments as bounds' do - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') - is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/) - } - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') - is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/) - } - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') - is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/) - } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/reject_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/reject_spec.rb deleted file mode 100755 index 486305075..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/reject_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'reject' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], 'pattern', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - it { - pending("reject does not actually check this, and raises NoMethodError instead") - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/) - } - it { - pending("reject does not actually check this, and raises NoMethodError instead") - is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/) - } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/reverse_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/reverse_spec.rb deleted file mode 100755 index e00dee92e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/reverse_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'reverse' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } - - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('abc').and_return('cba') } - it { is_expected.to run.with_params('abcd').and_return('dcba') } - - context 'when using a class extending String' do - it 'should call its reverse method' do - value = AlsoString.new('asdfghjkl') - value.expects(:reverse).returns('foo') - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/rstrip_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/rstrip_spec.rb deleted file mode 100755 index d2efac8ea..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/rstrip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'rstrip' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return(' one') } - it { is_expected.to run.with_params(' one').and_return(' one') } - it { is_expected.to run.with_params("\tone").and_return("\tone") } - it { is_expected.to run.with_params("\t one").and_return("\t one") } - it { is_expected.to run.with_params('one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return(' one') } - it { is_expected.to run.with_params(' one ').and_return(' one') } - it { is_expected.to run.with_params("\tone ").and_return("\tone") } - it { is_expected.to run.with_params("\t one ").and_return("\t one") } - it { is_expected.to run.with_params("one\t").and_return('one') } - it { is_expected.to run.with_params(" one\t").and_return(' one') } - it { is_expected.to run.with_params(" one\t").and_return(' one') } - it { is_expected.to run.with_params("\tone\t").and_return("\tone") } - it { is_expected.to run.with_params("\t one\t").and_return("\t one") } - it { is_expected.to run.with_params(' o n e ').and_return(' o n e') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return(' one') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/seeded_rand_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/seeded_rand_spec.rb deleted file mode 100644 index 38e134eb8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/seeded_rand_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'spec_helper' - -describe 'seeded_rand' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(0, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(1.5, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(-10, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params("-10", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params("string", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params([], '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params({}, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) } - it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be a string/) } - it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be a string/) } - it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be a string/) } - - it "provides a random number strictly less than the given max" do - expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i < 3 } - end - - it "provides a random number greater or equal to zero" do - expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i >= 0 } - end - - it "provides the same 'random' value on subsequent calls for the same host" do - expect(seeded_rand(10, 'seed')).to eql(seeded_rand(10, 'seed')) - end - - it "allows seed to control the random value on a single host" do - first_random = seeded_rand(1000, 'seed1') - second_different_random = seeded_rand(1000, 'seed2') - - expect(first_random).not_to eql(second_different_random) - end - - it "should not return different values for different hosts" do - val1 = seeded_rand(1000, 'foo', :host => "first.host.com") - val2 = seeded_rand(1000, 'foo', :host => "second.host.com") - - expect(val1).to eql(val2) - end - - def seeded_rand(max, seed, args = {}) - host = args[:host] || '127.0.0.1' - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - scope.stubs(:lookupvar).with("::fqdn", {}).returns(host) - - scope.function_seeded_rand([max, seed]) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/shuffle_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/shuffle_spec.rb deleted file mode 100755 index ebc3a732d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/shuffle_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe 'shuffle' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - - context 'when running with a specific seed' do - # make tests deterministic - before(:each) { srand(2) } - - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } - - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('abc').and_return('bac') } - it { is_expected.to run.with_params('abcd').and_return('dcba') } - - context 'when using a class extending String' do - it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/size_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/size_spec.rb deleted file mode 100755 index c0047ee21..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/size_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'size' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Unknown type given/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Unknown type given/) } - it { is_expected.to run.with_params('1').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) } - it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) } - it { is_expected.to run.with_params([]).and_return(0) } - it { is_expected.to run.with_params(['a']).and_return(1) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } - - it { is_expected.to run.with_params({}).and_return(0) } - it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } - it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } - - it { is_expected.to run.with_params('').and_return(0) } - it { is_expected.to run.with_params('a').and_return(1) } - it { is_expected.to run.with_params('abc').and_return(3) } - it { is_expected.to run.with_params('abcd').and_return(4) } - - context 'when using a class extending String' do - it 'should call its size method' do - value = AlsoString.new('asdfghjkl') - value.expects(:size).returns('foo') - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/sort_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/sort_spec.rb deleted file mode 100755 index 9abd039c1..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/sort_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'sort' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { pending('stricter input checking'); is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /requires string or array/) } - it { pending('stricter input checking'); is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /requires string or array/) } - it { pending('stricter input checking'); is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /requires string or array/) } - end - - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['c', 'b', 'a']).and_return(['a', 'b', 'c']) } - end - - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('cbda').and_return('abcd') } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/squeeze_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/squeeze_spec.rb deleted file mode 100755 index 7f09c30ff..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/squeeze_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper' - -describe 'squeeze' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) } - it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) } - it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) } - - context 'when squeezing a single string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaa').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') } - end - - context 'when squeezing values in an array' do - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \ - .and_return( ['', 'a', 'a', 'abc']) - } - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \ - .and_return( ['', 'a', 'a', 'abbbbbbbbbbcccccccccc']) - } - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \ - .and_return( ['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc']) - } - end - - context 'when using a class extending String' do - it 'should call its squeeze method' do - value = AlsoString.new('aaaaaaaaa') - value.expects(:squeeze).returns('foo') - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/str2bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/str2bool_spec.rb deleted file mode 100755 index 7d8c47c19..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/str2bool_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'str2bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Unknown type of boolean given/) } - - describe 'when testing values that mean "true"' do - [ 'TRUE','1', 't', 'y', 'true', 'yes', true ].each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - end - - describe 'when testing values that mean "false"' do - [ 'FALSE','', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined' ].each do |value| - it { is_expected.to run.with_params(value).and_return(false) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/str2saltedsha512_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/str2saltedsha512_spec.rb deleted file mode 100755 index 2e1e818b5..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/str2saltedsha512_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'str2saltedsha512' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('password', 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires a String argument/) } - - context 'when running with a specific seed' do - # make tests deterministic - before(:each) { srand(2) } - - it { is_expected.to run.with_params('').and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a') } - it { is_expected.to run.with_params('password').and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956') } - it { is_expected.to run.with_params('verylongpassword').and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039') } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/strftime_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/strftime_spec.rb deleted file mode 100755 index e76774aa3..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/strftime_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'strftime' do - it "should exist" do - expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError)) - end - - it "using %s should be higher then when I wrote this test" do - result = scope.function_strftime(["%s"]) - expect(result.to_i).to(be > 1311953157) - end - - it "using %s should be lower then 1.5 trillion" do - result = scope.function_strftime(["%s"]) - expect(result.to_i).to(be < 1500000000) - end - - it "should return a date when given %Y-%m-%d" do - result = scope.function_strftime(["%Y-%m-%d"]) - expect(result).to match(/^\d{4}-\d{2}-\d{2}$/) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/strip_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/strip_spec.rb deleted file mode 100755 index 689b6dd0c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/strip_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'strip' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params("\tone").and_return('one') } - it { is_expected.to run.with_params("\t one").and_return('one') } - it { is_expected.to run.with_params('one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return('one') } - it { is_expected.to run.with_params("\tone ").and_return('one') } - it { is_expected.to run.with_params("\t one ").and_return('one') } - it { is_expected.to run.with_params("one \t").and_return('one') } - it { is_expected.to run.with_params(" one \t").and_return('one') } - it { is_expected.to run.with_params(" one \t").and_return('one') } - it { is_expected.to run.with_params("\tone \t").and_return('one') } - it { is_expected.to run.with_params("\t one \t").and_return('one') } - it { is_expected.to run.with_params(' o n e ').and_return('o n e') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/suffix_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/suffix_spec.rb deleted file mode 100755 index efba4ab44..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/suffix_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'suffix' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the second.") - is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array/) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([''], '').and_return(['']) } - it { is_expected.to run.with_params(['one'], 'post').and_return(['onepost']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) } - it { - is_expected.to run.with_params({}).and_return({}) - } - it { - is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 }) - } - it { - is_expected.to run.with_params({}, '').and_return({}) - } - it { - is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' }) - } - it { - is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return({ 'keypost' => 'value' }) - } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \ - .and_return({ 'key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3' }) - } -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/swapcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/swapcase_spec.rb deleted file mode 100755 index c175a1588..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/swapcase_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'swapcase' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - describe 'with strings as inputs' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('one').and_return('ONE') } - it { is_expected.to run.with_params('ONE').and_return('one') } - it { is_expected.to run.with_params('oNe').and_return('OnE') } - end - describe 'with arrays as inputs' do - it { is_expected.to run.with_params([]).and_return([]) } - describe 'only containing strings' do - it { is_expected.to run.with_params(['']).and_return(['']) } - it { is_expected.to run.with_params(['one']).and_return(['ONE']) } - it { is_expected.to run.with_params(['ONE']).and_return(['one']) } - it { is_expected.to run.with_params(['oNe']).and_return(['OnE']) } - it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) } - it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) } - it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) } - end - describe 'containing mixed types' do - it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) } - it { is_expected.to run.with_params(['OnE', 1]).and_return(['oNe', 1]) } - it { is_expected.to run.with_params(['OnE', []]).and_return(['oNe', []]) } - it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) } - end - end - it "should accept objects which extend String" do - is_expected.to run.with_params(AlsoString.new("OnE")).and_return('oNe') - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/time_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/time_spec.rb deleted file mode 100755 index d157939e9..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/time_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'time' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - context 'when running at a specific time' do - before(:each) { - # get a value before stubbing the function - test_time = Time.utc(2006, 10, 13, 8, 15, 11) - Time.expects(:new).with().returns(test_time).once - } - it { is_expected.to run.with_params().and_return(1160727311) } - it { is_expected.to run.with_params('').and_return(1160727311) } - it { is_expected.to run.with_params([]).and_return(1160727311) } - it { is_expected.to run.with_params({}).and_return(1160727311) } - it { is_expected.to run.with_params('foo').and_return(1160727311) } - it { is_expected.to run.with_params('UTC').and_return(1160727311) } - it { is_expected.to run.with_params('America/New_York').and_return(1160727311) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/to_bytes_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/to_bytes_spec.rb deleted file mode 100755 index 2be23ff2d..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/to_bytes_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'spec_helper' - -describe 'to_bytes' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('1', 'extras').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([]).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Array (in)?to String/) } - it { is_expected.to run.with_params({}).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Hash (in)?to String/) } - it { is_expected.to run.with_params(true).and_raise_error(TypeError, /(can't convert|no implicit conversion of) (TrueClass|true) (in)?to String/) } - - describe 'when passing numbers' do - it { is_expected.to run.with_params(0).and_return(0) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(-1).and_return(-1) } - it { is_expected.to run.with_params(1.1).and_return(1.1) } - it { is_expected.to run.with_params(-1.1).and_return(-1.1) } - end - - describe 'when passing numbers as strings' do - describe 'without a unit' do - it { is_expected.to run.with_params('1').and_return(1) } - it { is_expected.to run.with_params('-1').and_return(-1) } - # these are so wrong - it { is_expected.to run.with_params('1.1').and_return(1) } - it { is_expected.to run.with_params('-1.1').and_return(-1) } - end - - describe 'with a unit' do - it { is_expected.to run.with_params('1k').and_return(1024) } - it { is_expected.to run.with_params('-1kB').and_return(-1024) } - it { is_expected.to run.with_params('1k').and_return(1024) } - it { is_expected.to run.with_params('1M').and_return(1024*1024) } - it { is_expected.to run.with_params('1G').and_return(1024*1024*1024) } - it { is_expected.to run.with_params('1T').and_return(1024*1024*1024*1024) } - it { is_expected.to run.with_params('1P').and_return(1024*1024*1024*1024*1024) } - it { is_expected.to run.with_params('1E').and_return(1024*1024*1024*1024*1024*1024) } - it { is_expected.to run.with_params('1.5e3M').and_return(1572864000) } - - it { is_expected.to run.with_params('4k').and_return(4*1024) } - it { is_expected.to run.with_params('-4kB').and_return(4*-1024) } - it { is_expected.to run.with_params('4k').and_return(4*1024) } - it { is_expected.to run.with_params('4M').and_return(4*1024*1024) } - it { is_expected.to run.with_params('4G').and_return(4*1024*1024*1024) } - it { is_expected.to run.with_params('4T').and_return(4*1024*1024*1024*1024) } - it { is_expected.to run.with_params('4P').and_return(4*1024*1024*1024*1024*1024) } - it { is_expected.to run.with_params('4E').and_return(4*1024*1024*1024*1024*1024*1024) } - - # these are so wrong - it { is_expected.to run.with_params('1.0001 k').and_return(1024) } - it { is_expected.to run.with_params('-1.0001 kB').and_return(-1024) } - end - - describe 'with a unknown unit' do - it { is_expected.to run.with_params('1KB').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - it { is_expected.to run.with_params('1K').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - it { is_expected.to run.with_params('1mb').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - it { is_expected.to run.with_params('1m').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - it { is_expected.to run.with_params('1%').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - it { is_expected.to run.with_params('1 p').and_raise_error(Puppet::ParseError, /Unknown prefix/) } - end - end - - # these are so wrong - describe 'when passing random stuff' do - it { is_expected.to run.with_params('-1....1').and_return(-1) } - it { is_expected.to run.with_params('-1.e.e.e.1').and_return(-1) } - it { is_expected.to run.with_params('-1+1').and_return(-1) } - it { is_expected.to run.with_params('1-1').and_return(1) } - it { is_expected.to run.with_params('1 kaboom').and_return(1024) } - it { is_expected.to run.with_params('kaboom').and_return(0) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/try_get_value_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/try_get_value_spec.rb deleted file mode 100644 index 38c0efdd2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/try_get_value_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'spec_helper' - -describe 'try_get_value' do - - let(:data) do - { - 'a' => { - 'g' => '2', - 'e' => [ - 'f0', - 'f1', - { - 'x' => { - 'y' => 'z' - } - }, - 'f3', - ] - }, - 'b' => true, - 'c' => false, - 'd' => '1', - } - end - - context 'single values' do - it 'should exist' do - is_expected.not_to eq(nil) - end - - it 'should be able to return a single value' do - is_expected.to run.with_params('test').and_return('test') - end - - it 'should use the default value if data is a single value and path is present' do - is_expected.to run.with_params('test', 'path', 'default').and_return('default') - end - - it 'should return default if there is no data' do - is_expected.to run.with_params(nil, nil, 'default').and_return('default') - end - - it 'should be able to use data structures as default values' do - is_expected.to run.with_params('test', 'path', data).and_return(data) - end - end - - context 'structure values' do - it 'should be able to extracts a single hash value' do - is_expected.to run.with_params(data, 'd', 'default').and_return('1') - end - - it 'should be able to extract a deeply nested hash value' do - is_expected.to run.with_params(data, 'a/g', 'default').and_return('2') - end - - it 'should return the default value if the path is not found' do - is_expected.to run.with_params(data, 'missing', 'default').and_return('default') - end - - it 'should return the default value if the path is too long' do - is_expected.to run.with_params(data, 'a/g/c/d', 'default').and_return('default') - end - - it 'should support an array index in the path' do - is_expected.to run.with_params(data, 'a/e/1', 'default').and_return('f1') - end - - it 'should return the default value if an array index is not a number' do - is_expected.to run.with_params(data, 'a/b/c', 'default').and_return('default') - end - - it 'should return the default value if and index is out of array length' do - is_expected.to run.with_params(data, 'a/e/5', 'default').and_return('default') - end - - it 'should be able to path though both arrays and hashes' do - is_expected.to run.with_params(data, 'a/e/2/x/y', 'default').and_return('z') - end - - it 'should be able to return "true" value' do - is_expected.to run.with_params(data, 'b', 'default').and_return(true) - is_expected.to run.with_params(data, 'm', true).and_return(true) - end - - it 'should be able to return "false" value' do - is_expected.to run.with_params(data, 'c', 'default').and_return(false) - is_expected.to run.with_params(data, 'm', false).and_return(false) - end - - it 'should return "nil" if value is not found and no default value is provided' do - is_expected.to run.with_params(data, 'a/1').and_return(nil) - end - - it 'should be able to use a custom path separator' do - is_expected.to run.with_params(data, 'a::g', 'default', '::').and_return('2') - is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default') - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/type3x_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/type3x_spec.rb deleted file mode 100644 index c3eb1deee..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/type3x_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe 'type3x' do - it "should exist" do - expect(Puppet::Parser::Functions.function("type3x")).to eq("function_type3x") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_type3x([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should return string when given a string" do - result = scope.function_type3x(["aaabbbbcccc"]) - expect(result).to(eq('string')) - end - - it "should return array when given an array" do - result = scope.function_type3x([["aaabbbbcccc","asdf"]]) - expect(result).to(eq('array')) - end - - it "should return hash when given a hash" do - result = scope.function_type3x([{"a"=>1,"b"=>2}]) - expect(result).to(eq('hash')) - end - - it "should return integer when given an integer" do - result = scope.function_type3x(["1"]) - expect(result).to(eq('integer')) - end - - it "should return float when given a float" do - result = scope.function_type3x(["1.34"]) - expect(result).to(eq('float')) - end - - it "should return boolean when given a boolean" do - result = scope.function_type3x([true]) - expect(result).to(eq('boolean')) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/type_of_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/type_of_spec.rb deleted file mode 100644 index cc9ef781c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/type_of_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -if ENV["FUTURE_PARSER"] == 'yes' - describe 'type_of' do - pending 'teach rspec-puppet to load future-only functions under 3.7.5' do - it { is_expected.not_to eq(nil) } - end - end -end - -if Puppet.version.to_f >= 4.0 - describe 'type_of' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) } - - it 'gives the type of a string' do - expect(subject.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType) - end - - it 'gives the type of an integer' do - expect(subject.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/type_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/type_spec.rb deleted file mode 100755 index 4288df09b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/type_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper' - -describe 'type' do - it "should exist" do - expect(Puppet::Parser::Functions.function("type")).to eq("function_type") - end - - it "should give a deprecation warning when called" do - scope.expects(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") - scope.function_type(["aoeu"]) - end - - it "should return string when given a string" do - result = scope.function_type(["aaabbbbcccc"]) - expect(result).to(eq('string')) - end - - it "should return array when given an array" do - result = scope.function_type([["aaabbbbcccc","asdf"]]) - expect(result).to(eq('array')) - end - - it "should return hash when given a hash" do - result = scope.function_type([{"a"=>1,"b"=>2}]) - expect(result).to(eq('hash')) - end - - it "should return integer when given an integer" do - result = scope.function_type(["1"]) - expect(result).to(eq('integer')) - end - - it "should return float when given a float" do - result = scope.function_type(["1.34"]) - expect(result).to(eq('float')) - end - - it "should return boolean when given a boolean" do - result = scope.function_type([true]) - expect(result).to(eq('boolean')) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/union_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/union_spec.rb deleted file mode 100755 index cfd38b602..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/union_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'union' do - describe 'argument checking' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /Every parameter must be an array/) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) } - end - - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one'], []).and_return(['one']) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one'], ['two']).and_return(['one', 'two']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) } - it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/unique_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/unique_spec.rb deleted file mode 100755 index 24257a018..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/unique_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'unique' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - end - - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } - end - - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaba').and_return('ab') } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/unix2dos_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/unix2dos_spec.rb deleted file mode 100644 index 8537a26fa..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/unix2dos_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'unix2dos' do - context 'Checking parameter validity' do - it { is_expected.not_to eq(nil) } - it do - is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/) - end - it do - is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/) - end - it do - is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) - end - end - - context 'Converting from unix to dos format' do - sample_text = "Hello\nWorld\n" - desired_output = "Hello\r\nWorld\r\n" - - it 'should output dos format' do - should run.with_params(sample_text).and_return(desired_output) - end - end - - context 'Converting from dos to dos format' do - sample_text = "Hello\r\nWorld\r\n" - desired_output = "Hello\r\nWorld\r\n" - - it 'should output dos format' do - should run.with_params(sample_text).and_return(desired_output) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/upcase_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/upcase_spec.rb deleted file mode 100755 index 3b7b02d47..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/upcase_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'upcase' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) } - it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) } - end - - describe 'normal string handling' do - it { is_expected.to run.with_params("abc").and_return("ABC") } - it { is_expected.to run.with_params("Abc").and_return("ABC") } - it { is_expected.to run.with_params("ABC").and_return("ABC") } - end - - describe 'handling classes derived from String' do - it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("ABC") } - end - - describe 'strings in arrays handling' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(["One", "twO"]).and_return(["ONE", "TWO"]) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/uriescape_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/uriescape_spec.rb deleted file mode 100755 index f05ec088c..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/uriescape_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'uriescape' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - end - - describe 'handling normal strings' do - it 'should call ruby\'s URI.escape function' do - URI.expects(:escape).with('uri_string').returns('escaped_uri_string').once - is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') - end - end - - describe 'handling classes derived from String' do - it 'should call ruby\'s URI.escape function' do - uri_string = AlsoString.new('uri_string') - URI.expects(:escape).with(uri_string).returns('escaped_uri_string').once - is_expected.to run.with_params(uri_string).and_return("escaped_uri_string") - end - end - - describe 'strings in arrays handling' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(["one}", "two"]).and_return(["one%7D", "two"]) } - it { is_expected.to run.with_params(["one}", 1, true, {}, "two"]).and_return(["one%7D", 1, true, {}, "two"]) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_absolute_path_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_absolute_path_spec.rb deleted file mode 100755 index 4a8404d81..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_absolute_path_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'spec_helper' - -describe 'validate_absolute_path' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - end - - describe "valid paths handling" do - %w{ - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - / - /var/tmp - /var/opt/../lib/puppet - }.each do |path| - it { is_expected.to run.with_params(path) } - it { is_expected.to run.with_params(['/tmp', path]) } - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [ nil ], - [ nil, nil ], - { 'foo' => 'bar' }, - { }, - '', - ].each do |path| - it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - end - end - - context 'relative paths' do - %w{ - relative1 - . - .. - ./foo - ../foo - etc/puppetlabs/puppet - opt/puppet/bin - relative\\windows - }.each do |path| - it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) } - end - end - end -end - diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_array_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_array_spec.rb deleted file mode 100755 index 4ee7754f8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_array_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'validate_array' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params([]) } - it { is_expected.to run.with_params(['one']) } - it { is_expected.to run.with_params([], ['two']) } - it { is_expected.to run.with_params(['one'], ['two']) } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params([], {}).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, /is not an Array/) } - it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, /is not an Array/) } - end - end -end - diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_augeas_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_augeas_spec.rb deleted file mode 100755 index 4236649d6..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_augeas_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'spec_helper' - -describe 'validate_augeas' do - unless Puppet.features.augeas? - skip "ruby-augeas not installed" - else - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) } - end - - describe 'valid inputs' do - inputs = [ - [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns' ], - [ "proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns'], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input) } - end - end - - describe 'valid inputs which fail augeas validation' do - # The intent here is to make sure valid inputs raise exceptions when they - # don't specify an error message to display. This is the behvior in - # 2.2.x and prior. - inputs = [ - [ "root:x:0:0:root\n", 'Passwd.lns' ], - [ "127.0.1.1\n", 'Hosts.lns' ], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /validate_augeas.*?matched less than it should/) } - end - end - - describe "when specifying nice error messages" do - # The intent here is to make sure the function returns the 4th argument - # in the exception thrown - inputs = [ - [ "root:x:0:0:root\n", 'Passwd.lns', [], 'Failed to validate passwd content' ], - [ "127.0.1.1\n", 'Hosts.lns', [], 'Wrong hosts content' ], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /#{input[3]}/) } - end - end - - describe "matching additional tests" do - inputs = [ - [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']], - [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input) } - end - end - - describe "failing additional tests" do - inputs = [ - [ "foobar:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']], - [ "root:x:0:0:root:/root:/bin/sh\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /testing path/) } - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_bool_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_bool_spec.rb deleted file mode 100755 index d9cdf572e..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_bool_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'validate_bool' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - end - - describe 'acceptable values' do - it { is_expected.to run.with_params(true) } - it { is_expected.to run.with_params(false) } - it { is_expected.to run.with_params(true, false, false, true) } - end - - describe 'validation failures' do - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params("true").and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params("false").and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params(true, "false").and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params("true", false).and_raise_error(Puppet::ParseError, /is not a boolean/) } - it { is_expected.to run.with_params("true", false, false, false, false, false).and_raise_error(Puppet::ParseError, /is not a boolean/) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_cmd_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_cmd_spec.rb deleted file mode 100755 index ab0cbc9a7..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_cmd_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'validate_cmd' do - let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' } - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /content must be a string/) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, /checkscript must be a string/) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /custom error message must be a string/) - } - end - - context 'when validation fails' do - context 'with % placeholder' do - it { is_expected.to run.with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)/) } - it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) } - end - context 'without % placeholder' do - it { is_expected.to run.with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)/) } - it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_email_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_email_address_spec.rb deleted file mode 100644 index 762838344..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_email_address_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'validate_email_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('bob@gmail.com') } - it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid email/) } - it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, /is not a valid email/) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_hash_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_hash_spec.rb deleted file mode 100755 index 2e8e59fb8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_hash_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'validate_hash' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params({}) } - it { is_expected.to run.with_params({'key' => 'value'}) } - it { is_expected.to run.with_params({}, {'key' => 'value'}) } - it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2'}) } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, /is not a Hash/) } - it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, /is not a Hash/) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_integer_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_integer_spec.rb deleted file mode 100755 index 4c0a9d7d4..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_integer_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'spec_helper' - -describe 'validate_integer' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', 7.0, -7.0, {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be an Integer/) } - it { is_expected.to run.with_params(invalid, 10).and_raise_error(Puppet::ParseError, /to be an Integer/) } - it { is_expected.to run.with_params(invalid, 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) } - it { is_expected.to run.with_params([0, 1, 2, invalid, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) } - end - - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) } - end - - context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - end - - it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) } - it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) } - it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) } - end - - context 'with no range constraints' do - it { is_expected.to run.with_params(1) } - it { is_expected.to run.with_params(-1) } - it { is_expected.to run.with_params('1') } - it { is_expected.to run.with_params('-1') } - it { is_expected.to run.with_params([1, 2, 3, 4]) } - it { is_expected.to run.with_params([1, '2', '3', 4]) } - end - - context "with a maximum limit of 10" do - describe 'rejects numbers greater than the limit' do - it { is_expected.to run.with_params(11, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(100, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(2**65, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params([1,2,10,100], 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - end - - describe 'accepts numbers less or equal to the limit' do - it { is_expected.to run.with_params(10, 10) } - it { is_expected.to run.with_params(1, 10) } - it { is_expected.to run.with_params(-1, 10) } - it { is_expected.to run.with_params('1', 10) } - it { is_expected.to run.with_params('-1', 10) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10) } - end - - context "with a minimum limit of -10" do - describe 'rejects numbers greater than the upper limit' do - it { is_expected.to run.with_params(11, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(100, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params([1,2,10,100], 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - end - - describe 'rejects numbers smaller than the lower limit' do - it { is_expected.to run.with_params(-11, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params(-100, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params(-2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params([-10, 1,2,10,-100], 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - end - - describe 'accepts numbers between and including the limits' do - it { is_expected.to run.with_params(10, 10, -10) } - it { is_expected.to run.with_params(-10, 10, -10) } - it { is_expected.to run.with_params(1, 10, -10) } - it { is_expected.to run.with_params(-1, 10, -10) } - it { is_expected.to run.with_params('1', 10, -10) } - it { is_expected.to run.with_params('-1', 10, -10) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10, -10) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10, -10) } - end - end - end - - it { is_expected.to run.with_params(10, 10, 10) } - - describe 'empty upper limit is interpreted as infinity' do - it { is_expected.to run.with_params(11, '', 10) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_ip_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_ip_address_spec.rb deleted file mode 100644 index b56ce51c2..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_ip_address_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper' - -describe 'validate_ip_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('0.0.0.0') } - it { is_expected.to run.with_params('8.8.8.8') } - it { is_expected.to run.with_params('127.0.0.1') } - it { is_expected.to run.with_params('10.10.10.10') } - it { is_expected.to run.with_params('194.232.104.150') } - it { is_expected.to run.with_params('244.24.24.24') } - it { is_expected.to run.with_params('255.255.255.255') } - it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') } - it { is_expected.to run.with_params('3ffe:0505:0002::') } - it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } - it { is_expected.to run.with_params('::1/64') } - it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } - context 'with netmasks' do - it { is_expected.to run.with_params('8.8.8.8/0') } - it { is_expected.to run.with_params('8.8.8.8/16') } - it { is_expected.to run.with_params('8.8.8.8/32') } - it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') } - end - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb deleted file mode 100755 index b6170d438..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'validate_ipv4_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('0.0.0.0') } - it { is_expected.to run.with_params('8.8.8.8') } - it { is_expected.to run.with_params('127.0.0.1') } - it { is_expected.to run.with_params('10.10.10.10') } - it { is_expected.to run.with_params('194.232.104.150') } - it { is_expected.to run.with_params('244.24.24.24') } - it { is_expected.to run.with_params('255.255.255.255') } - it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') } - context 'with netmasks' do - it { is_expected.to run.with_params('8.8.8.8/0') } - it { is_expected.to run.with_params('8.8.8.8/16') } - it { is_expected.to run.with_params('8.8.8.8/32') } - it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') } - end - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - it { is_expected.to run.with_params('affe::beef').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb deleted file mode 100755 index 7aaf0060a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper' - -describe 'validate_ipv6_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('3ffe:0505:0002::') } - it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } - it { is_expected.to run.with_params('::1/64') } - it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } - context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, /is not a string/) } - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_numeric_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_numeric_spec.rb deleted file mode 100755 index 9b8eb0eeb..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_numeric_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'spec_helper' - -describe 'validate_numeric' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be a Numeric/) } - it { is_expected.to run.with_params(invalid, 10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) } - it { is_expected.to run.with_params(invalid, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) } - end - - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be a Numeric/) } - end - - context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - end - - it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) } - it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) } - it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) } - end - - context 'with no range constraints' do - it { is_expected.to run.with_params(1) } - it { is_expected.to run.with_params(-1) } - it { is_expected.to run.with_params('1') } - it { is_expected.to run.with_params('-1') } - it { is_expected.to run.with_params([1, 2, 3, 4]) } - it { is_expected.to run.with_params([1, '2', '3', 4]) } - end - - context "with a maximum limit of 10.0" do - describe 'rejects numbers greater than the limit' do - it { is_expected.to run.with_params(11, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(100, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(2**65, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params([1,2,10.0,100], 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - end - - describe 'accepts numbers less or equal to the limit' do - it { is_expected.to run.with_params(10.0, 10.0) } - it { is_expected.to run.with_params(1, 10.0) } - it { is_expected.to run.with_params(-1, 10.0) } - it { is_expected.to run.with_params('1', 10.0) } - it { is_expected.to run.with_params('-1', 10.0) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10.0) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10.0) } - end - - context "with a minimum limit of -10.0" do - describe 'rejects numbers greater than the upper limit' do - it { is_expected.to run.with_params(11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params(2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - it { is_expected.to run.with_params([1,2,10.0,100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) } - end - - describe 'rejects numbers smaller than the lower limit' do - it { is_expected.to run.with_params(-11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params(-100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params(-2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - it { is_expected.to run.with_params([-10.0, 1,2,10.0,-100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) } - end - - describe 'accepts numbers between and including the limits' do - it { is_expected.to run.with_params(10.0, 10.0, -10.0) } - it { is_expected.to run.with_params(-10.0, 10.0, -10.0) } - it { is_expected.to run.with_params(1, 10.0, -10.0) } - it { is_expected.to run.with_params(-1, 10.0, -10.0) } - it { is_expected.to run.with_params('1', 10.0, -10.0) } - it { is_expected.to run.with_params('-1', 10.0, -10.0) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10.0, -10.0) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10.0, -10.0) } - end - end - end - - it { is_expected.to run.with_params(10.0, 10.0, 10.0) } - - describe 'empty upper limit is interpreted as infinity' do - it { is_expected.to run.with_params(11, '', 10.0) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_re_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_re_spec.rb deleted file mode 100755 index 3f9014370..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_re_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe 'validate_re' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('', '') } - it { is_expected.to run.with_params('', ['']) } - it { is_expected.to run.with_params('', [''], 'custom error') } - it { is_expected.to run.with_params('one', '^one') } - it { is_expected.to run.with_params('one', [ '^one', '^two' ]) } - it { is_expected.to run.with_params('one', [ '^one', '^two' ], 'custom error') } - end - - describe 'invalid inputs' do - it { - pending('should implement stricter type checking') - is_expected.to run.with_params([], '').and_raise_error(Puppet::ParseError, /is not a String/) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', {}).and_raise_error(Puppet::ParseError, /is not an Array/) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /is not a String/) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params(nil, nil).and_raise_error(Puppet::ParseError, /is not a String/) - } - it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) } - it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('notone', [ '^one', '^two' ]).and_raise_error(Puppet::ParseError, /does not match/) } - it { is_expected.to run.with_params('notone', [ '^one', '^two' ], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) } - - describe 'non-string inputs' do - [ - 1, # Fixnum - 3.14, # Float - nil, # NilClass - true, # TrueClass - false, # FalseClass - ["10"], # Array - :key, # Symbol - {:key=>"val"}, # Hash - ].each do |input| - it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, /needs to be a String/) } - end - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_slength_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_slength_spec.rb deleted file mode 100755 index 5a8fa6a84..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_slength_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe 'validate_slength' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', 2, 3, 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) } - it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) } - it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) } - it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) } - it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, /argument to be equal to or larger than third argument/) } - end - - context "with a maximum length of 10" do - describe 'rejects strings longer than the limit' do - it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, /Expected length/) } - it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, /Expected length/) } - it { is_expected.to run.with_params([ 'one', '1234567890abcdef' ], 10).and_raise_error(Puppet::ParseError, /Expected length/) } - end - - describe 'accepts strings shorter or equal to the limit' do - it { is_expected.to run.with_params('1234567890', 10) } - it { is_expected.to run.with_params('12345', 10) } - it { is_expected.to run.with_params([ 'one', 'two' ], 10) } - end - - context "with a minimum length of 5" do - describe 'rejects strings longer than the upper limit' do - it { is_expected.to run.with_params('1234567890a', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) } - it { is_expected.to run.with_params('1234567890abcdef', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) } - end - - describe 'rejects numbers shorter than the lower limit' do - it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) } - it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) } - end - - describe 'accepts strings of length between and including the limits' do - it { is_expected.to run.with_params('12345', 10, 5) } - it { is_expected.to run.with_params('123456', 10, 5) } - it { is_expected.to run.with_params('1234567', 10, 5) } - it { is_expected.to run.with_params('12345678', 10, 5) } - it { is_expected.to run.with_params('123456789', 10, 5) } - it { is_expected.to run.with_params('1234567890', 10, 5) } - it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) } - end - end - end - - describe 'corner cases' do - it { pending('this should work'); is_expected.to run.with_params('', 0, 0) } - it { is_expected.to run.with_params('1234567890', 10, 10) } - end - - describe 'empty upper limit is interpreted as infinity' do - it { pending('not implemented'); is_expected.to run.with_params('1234567890ab', '', 10) } - it { pending('not implemented'); is_expected.to run.with_params('12345678', '', 10).and_raise_error(Puppet::ParseError, /Expected length/) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_string_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_string_spec.rb deleted file mode 100755 index f0c500eb1..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_string_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'validate_string' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('') } - it { is_expected.to run.with_params('one') } - it { is_expected.to run.with_params('one', 'two') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb deleted file mode 100755 index eb6331005..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb +++ /dev/null @@ -1,180 +0,0 @@ -require 'spec_helper' - -describe 'validate_x509_rsa_key_pair' do - - let(:valid_cert) do - < 'value' }).and_return(['value']) } - it 'should return the array of values' do - result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }]) - expect(result).to match_array(['value1', 'value2', 'value2']) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/functions/zip_spec.rb b/vagrant/puppet/modules/stdlib/spec/functions/zip_spec.rb deleted file mode 100755 index abca7ee86..000000000 --- a/vagrant/puppet/modules/stdlib/spec/functions/zip_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'zip' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the third.") - is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) } - it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) } - it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) } -end diff --git a/vagrant/puppet/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb b/vagrant/puppet/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb deleted file mode 100755 index 505e24092..000000000 --- a/vagrant/puppet/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb +++ /dev/null @@ -1,9 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'rspec' - -class Object - # This is necessary because the RAL has a 'should' - # method. - alias :must :should - alias :must_not :should_not -end diff --git a/vagrant/puppet/modules/stdlib/spec/monkey_patches/publicize_methods.rb b/vagrant/puppet/modules/stdlib/spec/monkey_patches/publicize_methods.rb deleted file mode 100755 index 3ae59f978..000000000 --- a/vagrant/puppet/modules/stdlib/spec/monkey_patches/publicize_methods.rb +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env ruby -S rspec -# Some monkey-patching to allow us to test private methods. -class Class - def publicize_methods(*methods) - saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods - - self.class_eval { public(*saved_private_instance_methods) } - yield - self.class_eval { private(*saved_private_instance_methods) } - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/spec_helper.rb b/vagrant/puppet/modules/stdlib/spec/spec_helper.rb deleted file mode 100755 index 22d5d689f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/spec_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -#This file is generated by ModuleSync, do not edit. -require 'puppetlabs_spec_helper/module_spec_helper' - -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError -end diff --git a/vagrant/puppet/modules/stdlib/spec/spec_helper_acceptance.rb b/vagrant/puppet/modules/stdlib/spec/spec_helper_acceptance.rb deleted file mode 100755 index eda0d1a14..000000000 --- a/vagrant/puppet/modules/stdlib/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,70 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'beaker-rspec' -require 'beaker/puppet_install_helper' - -UNSUPPORTED_PLATFORMS = [] - -run_puppet_install_helper - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - if ENV['FUTURE_PARSER'] == 'yes' - default[:default_apply_opts] ||= {} - default[:default_apply_opts].merge!({:parser => 'future'}) - end - - copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib') - end -end - -def is_future_parser_enabled? - if default[:type] == 'aio' - return true - elsif default[:default_apply_opts] - return default[:default_apply_opts][:parser] == 'future' - end - return false -end - -def get_puppet_version - (on default, puppet('--version')).output.chomp -end - -RSpec.shared_context "with faked facts" do - let(:facts_d) do - puppet_version = get_puppet_version - if fact('osfamily') =~ /windows/i - if fact('kernelmajversion').to_f < 6.0 - 'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d' - else - 'C:/ProgramData/PuppetLabs/facter/facts.d' - end - elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true" - '/etc/puppetlabs/facter/facts.d' - else - '/etc/facter/facts.d' - end - end - - before :each do - #No need to create on windows, PE creates by default - if fact('osfamily') !~ /windows/i - shell("mkdir -p '#{facts_d}'") - end - end - - after :each do - shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1]) - end - - def fake_fact(name, value) - shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'") - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/spec_helper_local.rb b/vagrant/puppet/modules/stdlib/spec/spec_helper_local.rb deleted file mode 100644 index 023a862ee..000000000 --- a/vagrant/puppet/modules/stdlib/spec/spec_helper_local.rb +++ /dev/null @@ -1,29 +0,0 @@ - -# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples -RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) - -RSpec.configure do |config| - # supply tests with a possibility to test for the future parser - config.add_setting :puppet_future - config.puppet_future = Puppet.version.to_f >= 4.0 - - config.before :each do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages - - RSpec::Mocks.setup - end - - config.after :each do - RSpec::Mocks.verify - RSpec::Mocks.teardown - end -end - -# Helper class to test handling of arguments which are derived from string -class AlsoString < String -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb deleted file mode 100755 index 0afadb25f..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'facter/facter_dot_d' - -describe Facter::Util::DotD do - - context 'returns a simple fact' do - before :each do - Facter.stubs(:version).returns('1.6.1') - subject.stubs(:entries).returns(['/etc/facter/facts.d/fake_fact.txt']) - File.stubs(:readlines).with('/etc/facter/facts.d/fake_fact.txt').returns(['fake_fact=fake fact']) - subject.create - end - - it 'should return successfully' do - expect(Facter.fact(:fake_fact).value).to eq('fake fact') - end - end - - context 'returns a fact with equals signs' do - before :each do - Facter.stubs(:version).returns('1.6.1') - subject.stubs(:entries).returns(['/etc/facter/facts.d/foo.txt']) - File.stubs(:readlines).with('/etc/facter/facts.d/foo.txt').returns(['foo=1+1=2']) - subject.create - end - - it 'should return successfully' do - expect(Facter.fact(:foo).value).to eq('1+1=2') - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/package_provider_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/package_provider_spec.rb deleted file mode 100644 index 3954faf02..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/package_provider_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'puppet/type' -require 'puppet/type/package' - -describe 'package_provider', :type => :fact do - before { Facter.clear } - after { Facter.clear } - - ['4.2.2', '3.7.1 (Puppet Enterprise 3.2.1)'].each do |puppetversion| - describe "on puppet ''#{puppetversion}''" do - before :each do - Facter.stubs(:value).returns puppetversion - end - - context "darwin" do - it "should return pkgdmg" do - provider = Puppet::Type.type(:package).provider(:pkgdmg) - Puppet::Type.type(:package).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:package_provider).value).to eq('pkgdmg') - end - end - - context "centos 7" do - it "should return yum" do - provider = Puppet::Type.type(:package).provider(:yum) - Puppet::Type.type(:package).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:package_provider).value).to eq('yum') - end - end - - context "ubuntu" do - it "should return apt" do - provider = Puppet::Type.type(:package).provider(:apt) - Puppet::Type.type(:package).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:package_provider).value).to eq('apt') - end - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/pe_version_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/pe_version_spec.rb deleted file mode 100755 index c11a1cd09..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/pe_version_spec.rb +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe "PE Version specs" do - before :each do - # Explicitly load the pe_version.rb file which contains generated facts - # that cannot be automatically loaded. Puppet 2.x implements - # Facter.collection.load while Facter 1.x markes Facter.collection.load as - # a private method. - if Facter.collection.respond_to? :load - Facter.collection.load(:pe_version) - else - Facter.collection.loader.load(:pe_version) - end - end - - context "When puppetversion is nil" do - before :each do - Facter.fact(:puppetversion).stubs(:value).returns(nil) - end - - it "pe_version is nil" do - expect(Facter.fact(:puppetversion).value).to be_nil - expect(Facter.fact(:pe_version).value).to be_nil - end - end - - context "If PE is installed" do - %w{ 2.6.1 2.10.300 }.each do |version| - puppetversion = "2.7.19 (Puppet Enterprise #{version})" - context "puppetversion => #{puppetversion}" do - before :each do - Facter.fact(:puppetversion).stubs(:value).returns(puppetversion) - end - - (major,minor,patch) = version.split(".") - - it "Should return true" do - expect(Facter.fact(:is_pe).value).to eq(true) - end - - it "Should have a version of #{version}" do - expect(Facter.fact(:pe_version).value).to eq(version) - end - - it "Should have a major version of #{major}" do - expect(Facter.fact(:pe_major_version).value).to eq(major) - end - - it "Should have a minor version of #{minor}" do - expect(Facter.fact(:pe_minor_version).value).to eq(minor) - end - - it "Should have a patch version of #{patch}" do - expect(Facter.fact(:pe_patch_version).value).to eq(patch) - end - end - end - end - - context "When PE is not installed" do - before :each do - Facter.fact(:puppetversion).stubs(:value).returns("2.7.19") - end - - it "is_pe is false" do - expect(Facter.fact(:is_pe).value).to eq(false) - end - - it "pe_version is nil" do - expect(Facter.fact(:pe_version).value).to be_nil - end - - it "pe_major_version is nil" do - expect(Facter.fact(:pe_major_version).value).to be_nil - end - - it "pe_minor_version is nil" do - expect(Facter.fact(:pe_minor_version).value).to be_nil - end - - it "Should have a patch version" do - expect(Facter.fact(:pe_patch_version).value).to be_nil - end - end - -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/root_home_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/root_home_spec.rb deleted file mode 100755 index a5c2846ec..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/root_home_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'facter/root_home' - -describe Facter::Util::RootHome do - context "solaris" do - let(:root_ent) { "root:x:0:0:Super-User:/:/sbin/sh" } - let(:expected_root_home) { "/" } - - it "should return /" do - Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent) - expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home) - end - end - context "linux" do - let(:root_ent) { "root:x:0:0:root:/root:/bin/bash" } - let(:expected_root_home) { "/root" } - - it "should return /root" do - Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent) - expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home) - end - end - context "windows" do - before :each do - Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil) - end - it "should be nil on windows" do - expect(Facter::Util::RootHome.get_root_home).to be_nil - end - end -end - -describe 'root_home', :type => :fact do - before { Facter.clear } - after { Facter.clear } - - context "macosx" do - before do - Facter.fact(:kernel).stubs(:value).returns("Darwin") - Facter.fact(:osfamily).stubs(:value).returns("Darwin") - end - let(:expected_root_home) { "/var/root" } - sample_dscacheutil = File.read(fixtures('dscacheutil','root')) - - it "should return /var/root" do - Facter::Util::Resolution.stubs(:exec).with("dscacheutil -q user -a name root").returns(sample_dscacheutil) - expect(Facter.fact(:root_home).value).to eq(expected_root_home) - end - end - - context "aix" do - before do - Facter.fact(:kernel).stubs(:value).returns("AIX") - Facter.fact(:osfamily).stubs(:value).returns("AIX") - end - let(:expected_root_home) { "/root" } - sample_lsuser = File.read(fixtures('lsuser','root')) - - it "should return /root" do - Facter::Util::Resolution.stubs(:exec).with("lsuser -c -a home root").returns(sample_lsuser) - expect(Facter.fact(:root_home).value).to eq(expected_root_home) - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/service_provider_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/service_provider_spec.rb deleted file mode 100644 index ad8a5fc53..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/service_provider_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'puppet/type' -require 'puppet/type/service' - -describe 'service_provider', :type => :fact do - before { Facter.clear } - after { Facter.clear } - - context "macosx" do - it "should return launchd" do - provider = Puppet::Type.type(:service).provider(:launchd) - Puppet::Type.type(:service).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:service_provider).value).to eq('launchd') - end - end - - context "systemd" do - it "should return systemd" do - provider = Puppet::Type.type(:service).provider(:systemd) - Puppet::Type.type(:service).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:service_provider).value).to eq('systemd') - end - end - - context "redhat" do - it "should return redhat" do - provider = Puppet::Type.type(:service).provider(:redhat) - Puppet::Type.type(:service).stubs(:defaultprovider).returns provider - - expect(Facter.fact(:service_provider).value).to eq('redhat') - end - end - -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb deleted file mode 100755 index c278b7984..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'facter/util/puppet_settings' - -describe Facter::Util::PuppetSettings do - - describe "#with_puppet" do - context "Without Puppet loaded" do - before(:each) do - Module.expects(:const_get).with("Puppet").raises(NameError) - end - - it 'should be nil' do - expect(subject.with_puppet { Puppet[:vardir] }).to be_nil - end - it 'should not yield to the block' do - Puppet.expects(:[]).never - expect(subject.with_puppet { Puppet[:vardir] }).to be_nil - end - end - context "With Puppet loaded" do - module Puppet; end - let(:vardir) { "/var/lib/puppet" } - - before :each do - Puppet.expects(:[]).with(:vardir).returns vardir - end - - it 'should yield to the block' do - subject.with_puppet { Puppet[:vardir] } - end - it 'should return the nodes vardir' do - expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir - end - end - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb deleted file mode 100644 index b162127d0..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' - -describe "the enclose_ipv6 function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it "should exist" do - expect(Puppet::Parser::Functions.function("enclose_ipv6")).to eq("function_enclose_ipv6") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_enclose_ipv6([]) }.to( raise_error(Puppet::ParseError) ) - end - - it "should raise a ParseError if there is more than 1 arguments" do - expect { scope.function_enclose_ipv6(['argument1','argument2']) }.to( raise_error(Puppet::ParseError) ) - end - - it "should raise a ParseError when given garbage" do - expect { scope.function_enclose_ipv6(['garbage']) }.to( raise_error(Puppet::ParseError) ) - end - - it "should raise a ParseError when given something else than a string or an array" do - expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to( raise_error(Puppet::ParseError) ) - end - - it "should not raise a ParseError when given a single ip string" do - expect { scope.function_enclose_ipv6(['127.0.0.1']) }.to_not raise_error - end - - it "should not raise a ParseError when given * as ip string" do - expect { scope.function_enclose_ipv6(['*']) }.to_not raise_error - end - - it "should not raise a ParseError when given an array of ip strings" do - expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1']]) }.to_not raise_error - end - - it "should not raise a ParseError when given differently notations of ip addresses" do - expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::1]']]) }.to_not raise_error - end - - it "should raise a ParseError when given a wrong ipv4 address" do - expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to( raise_error(Puppet::ParseError) ) - end - - it "should raise a ParseError when given a ipv4 address with square brackets" do - expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to( raise_error(Puppet::ParseError) ) - end - - it "should raise a ParseError when given a wrong ipv6 address" do - expect { scope.function_enclose_ipv6(['fe80:::1']) }.to( raise_error(Puppet::ParseError) ) - end - - it "should embrace ipv6 adresses within an array of ip addresses" do - result = scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::2]']]) - expect(result).to(eq(['127.0.0.1','[fe80::1]','[fe80::2]'])) - end - - it "should embrace a single ipv6 adresse" do - result = scope.function_enclose_ipv6(['fe80::1']) - expect(result).to(eq(['[fe80::1]'])) - end - - it "should not embrace a single ipv4 adresse" do - result = scope.function_enclose_ipv6(['127.0.0.1']) - expect(result).to(eq(['127.0.0.1'])) - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb deleted file mode 100644 index 89312081a..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'spec_helper' - -describe :is_absolute_path do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - let(:function_args) do - [] - end - - let(:function) do - scope.function_is_absolute_path(function_args) - end - - - describe 'validate arity' do - let(:function_args) do - [1,2] - end - it "should raise a ParseError if there is more than 1 arguments" do - lambda { function }.should( raise_error(ArgumentError)) - end - - end - - it "should exist" do - Puppet::Parser::Functions.function(subject).should == "function_#{subject}" - end - - # help enforce good function defination - it 'should contain arity' do - - end - - it "should raise a ParseError if there is less than 1 arguments" do - lambda { function }.should( raise_error(ArgumentError)) - end - - - describe 'should retrun true' do - let(:return_value) do - true - end - - describe 'windows' do - let(:function_args) do - ['c:\temp\test.txt'] - end - it 'should return data' do - function.should eq(return_value) - end - end - - describe 'non-windows' do - let(:function_args) do - ['/temp/test.txt'] - end - - it 'should return data' do - function.should eq(return_value) - end - end - end - - describe 'should return false' do - let(:return_value) do - false - end - describe 'windows' do - let(:function_args) do - ['..\temp\test.txt'] - end - it 'should return data' do - function.should eq(return_value) - end - end - - describe 'non-windows' do - let(:function_args) do - ['../var/lib/puppet'] - end - it 'should return data' do - function.should eq(return_value) - end - end - end -end \ No newline at end of file diff --git a/vagrant/puppet/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb deleted file mode 100755 index fdeaf1a16..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ /dev/null @@ -1,440 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'tempfile' -provider_class = Puppet::Type.type(:file_line).provider(:ruby) -describe provider_class do - context "when adding" do - let :tmpfile do - tmp = Tempfile.new('tmp') - path = tmp.path - tmp.close! - path - end - let :resource do - Puppet::Type::File_line.new( - {:name => 'foo', :path => tmpfile, :line => 'foo'} - ) - end - let :provider do - provider_class.new(resource) - end - - it 'should detect if the line exists in the file' do - File.open(tmpfile, 'w') do |fh| - fh.write('foo') - end - expect(provider.exists?).to be_truthy - end - it 'should detect if the line does not exist in the file' do - File.open(tmpfile, 'w') do |fh| - fh.write('foo1') - end - expect(provider.exists?).to be_nil - end - it 'should append to an existing file when creating' do - provider.create - expect(File.read(tmpfile).chomp).to eq('foo') - end - end - context 'when using replace' do - before :each do - # TODO: these should be ported over to use the PuppetLabs spec_helper - # file fixtures once the following pull request has been merged: - # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files - tmp = Tempfile.new('tmp') - @tmpfile = tmp.path - tmp.close! - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - :replace => false, - } - ) - @provider = provider_class.new(@resource) - end - - it 'should not replace the matching line' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo=blah\nfoo2\nfoo3") - end - expect(@provider.exists?).to be_truthy - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo=blah\nfoo2\nfoo3") - end - - it 'should append the line if no matches are found' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo2") - end - expect(@provider.exists?).to be_nil - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar") - end - - it 'should raise an error with invalid values' do - expect { - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - :replace => 'asgadga', - } - ) - }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./) - end - end - context "when matching" do - before :each do - # TODO: these should be ported over to use the PuppetLabs spec_helper - # file fixtures once the following pull request has been merged: - # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files - tmp = Tempfile.new('tmp') - @tmpfile = tmp.path - tmp.close! - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - } - ) - @provider = provider_class.new(@resource) - end - - describe 'using match' do - it 'should raise an error if more than one line matches, and should not have modified the file' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") - end - expect(@provider.exists?).to be_nil - expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/) - expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz") - end - - it 'should replace all lines that matches' do - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - :multiple => true, - } - ) - @provider = provider_class.new(@resource) - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") - end - expect(@provider.exists?).to be_nil - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar") - end - - it 'should raise an error with invalid values' do - expect { - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - :multiple => 'asgadga', - } - ) - }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./) - end - - it 'should replace a line that matches' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo=blah\nfoo2") - end - expect(@provider.exists?).to be_nil - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") - end - it 'should add a new line if no lines match' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo2") - end - expect(@provider.exists?).to be_nil - @provider.create - expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n") - end - it 'should do nothing if the exact line already exists' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo = bar\nfoo2") - end - expect(@provider.exists?).to be_truthy - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") - end - end - - describe 'using after' do - let :resource do - Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'inserted = line', - :after => '^foo1', - } - ) - end - - let :provider do - provider_class.new(resource) - end - context 'match and after set' do - shared_context 'resource_create' do - let(:match) { '^foo2$' } - let(:after) { '^foo1$' } - let(:resource) { - Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'inserted = line', - :after => after, - :match => match, - } - ) - } - end - before :each do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo2\nfoo = baz") - end - end - describe 'inserts at match' do - include_context 'resource_create' - it { - provider.create - expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo = baz") - } - end - describe 'inserts a new line after when no match' do - include_context 'resource_create' do - let(:match) { '^nevergoingtomatch$' } - end - it { - provider.create - expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo2\nfoo = baz") - } - end - describe 'append to end of file if no match for both after and match' do - include_context 'resource_create' do - let(:match) { '^nevergoingtomatch$' } - let(:after) { '^stillneverafter' } - end - it { - provider.create - expect(File.read(@tmpfile).chomp).to eq("foo1\nfoo2\nfoo = baz\ninserted = line") - } - end - end - context 'with one line matching the after expression' do - before :each do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz") - end - end - - it 'inserts the specified line after the line matching the "after" expression' do - provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") - end - end - - context 'with multiple lines matching the after expression' do - before :each do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo = blah\nfoo2\nfoo1\nfoo = baz") - end - end - - it 'errors out stating "One or no line must match the pattern"' do - expect { provider.create }.to raise_error(Puppet::Error, /One or no line must match the pattern/) - end - - it 'adds the line after all lines matching the after expression' do - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'inserted = line', - :after => '^foo1$', - :multiple => true, - } - ) - @provider = provider_class.new(@resource) - expect(@provider.exists?).to be_nil - @provider.create - expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz") - end - end - - context 'with no lines matching the after expression' do - let :content do - "foo3\nfoo = blah\nfoo2\nfoo = baz\n" - end - - before :each do - File.open(@tmpfile, 'w') do |fh| - fh.write(content) - end - end - - it 'appends the specified line to the file' do - provider.create - expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n") - end - end - end - end - - context "when removing" do - before :each do - # TODO: these should be ported over to use the PuppetLabs spec_helper - # file fixtures once the following pull request has been merged: - # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files - tmp = Tempfile.new('tmp') - @tmpfile = tmp.path - tmp.close! - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo', - :ensure => 'absent', - } - ) - @provider = provider_class.new(@resource) - end - it 'should remove the line if it exists' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo2") - end - - it 'should remove the line without touching the last new line' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2\n") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") - end - - it 'should remove any occurence of the line' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") - end - end - - context "when removing with a match" do - before :each do - # TODO: these should be ported over to use the PuppetLabs spec_helper - # file fixtures once the following pull request has been merged: - # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files - tmp = Tempfile.new('tmp') - @tmpfile = tmp.path - tmp.close! - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo2', - :ensure => 'absent', - :match => 'o$', - :match_for_absence => true, - } - ) - @provider = provider_class.new(@resource) - end - - it 'should remove one line if it matches' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo2") - end - - it 'should raise an error if more than one line matches' do - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") - end - expect { @provider.destroy }.to raise_error(Puppet::Error, /More than one line/) - end - - it 'should remove multiple lines if :multiple is true' do - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo2', - :ensure => 'absent', - :match => 'o$', - :multiple => true, - :match_for_absence => true, - } - ) - @provider = provider_class.new(@resource) - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") - end - - it 'should ignore the match if match_for_absence is not specified' do - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo2', - :ensure => 'absent', - :match => 'o$', - } - ) - @provider = provider_class.new(@resource) - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo\n") - end - - it 'should ignore the match if match_for_absence is false' do - @resource = Puppet::Type::File_line.new( - { - :name => 'foo', - :path => @tmpfile, - :line => 'foo2', - :ensure => 'absent', - :match => 'o$', - :match_for_absence => false, - } - ) - @provider = provider_class.new(@resource) - File.open(@tmpfile, 'w') do |fh| - fh.write("foo1\nfoo\nfoo2") - end - @provider.destroy - expect(File.read(@tmpfile)).to eql("foo1\nfoo\n") - end - - end - -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb deleted file mode 100755 index c738a272b..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env ruby - -require 'spec_helper' - -anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin") - -describe anchor do - it "should stringify normally" do - expect(anchor.to_s).to eq("Anchor[ntp::begin]") - end -end diff --git a/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb b/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb deleted file mode 100755 index 48e2670f8..000000000 --- a/vagrant/puppet/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper' -require 'tempfile' -describe Puppet::Type.type(:file_line) do - let :file_line do - Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path') - end - it 'should accept a line and path' do - file_line[:line] = 'my_line' - expect(file_line[:line]).to eq('my_line') - file_line[:path] = '/my/path' - expect(file_line[:path]).to eq('/my/path') - end - it 'should accept a match regex' do - file_line[:match] = '^foo.*$' - expect(file_line[:match]).to eq('^foo.*$') - end - it 'should accept a match regex that does not match the specified line' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'foo', - :path => '/my/path', - :line => 'foo=bar', - :match => '^bar=blah$' - )}.not_to raise_error - end - it 'should accept a match regex that does match the specified line' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'foo', - :path => '/my/path', - :line => 'foo=bar', - :match => '^\s*foo=.*$' - )}.not_to raise_error - end - it 'should accept posix filenames' do - file_line[:path] = '/tmp/path' - expect(file_line[:path]).to eq('/tmp/path') - end - it 'should not accept unqualified path' do - expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/) - end - it 'should require that a line is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /line is a required attribute/) - end - it 'should not require that a line is specified when matching for absence' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error - end - it 'should require that a file is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) - end - it 'should default to ensure => present' do - expect(file_line[:ensure]).to eq :present - end - it 'should default to replace => true' do - expect(file_line[:replace]).to eq :true - end - - it "should autorequire the file it manages" do - catalog = Puppet::Resource::Catalog.new - file = Puppet::Type.type(:file).new(:name => "/tmp/path") - catalog.add_resource file - catalog.add_resource file_line - - relationship = file_line.autorequire.find do |rel| - (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s) - end - expect(relationship).to be_a Puppet::Relationship - end - - it "should not autorequire the file it manages if it is not managed" do - catalog = Puppet::Resource::Catalog.new - catalog.add_resource file_line - expect(file_line.autorequire).to be_empty - end -end