-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bdb0a0e
Showing
11 changed files
with
629 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 2 | ||
max_line_length = 100 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile ~/.gitignore_global | ||
|
||
# OS Specifics | ||
*~ | ||
*.bak | ||
Thumbs.db | ||
desktop.ini | ||
.DS_Store | ||
|
||
# Build | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Contributing | ||
|
||
When contributing to this repository, please first discuss the change you wish to make via issue, | ||
email, or any other method with the owners of this repository before making a change. | ||
|
||
Please note we have a code of conduct, please follow it in all your interactions with the project. | ||
|
||
## Pull Request Process | ||
|
||
1. Ensure any install or build dependencies are removed before the end of the layer when doing a | ||
build. | ||
2. Update the README.md with details of changes to the interface, this includes new environment | ||
variables, exposed ports, useful file locations and container parameters. | ||
3. Increase the version numbers in any examples files and the README.md to the new version that this | ||
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). | ||
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you | ||
do not have permission to do that, you may request the second reviewer to merge it for you. | ||
|
||
## Contributor Covenant Code of Conduct | ||
|
||
### Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers | ||
pledge to making participation in our project and our community a harassment-free experience for | ||
everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity | ||
and expression, level of experience, education, socio-economic status, nationality, personal | ||
appearance, race, religion, or sexual identity and orientation. | ||
|
||
### Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic address, without explicit | ||
permission | ||
* Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
### Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are | ||
expected to take appropriate and fair corrective action in response to any instances of unacceptable | ||
behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, | ||
code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or | ||
to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
### Scope | ||
|
||
This Code of Conduct applies within all project spaces, and it also applies when an individual is | ||
representing the project or its community in public spaces. Examples of representing a project or | ||
community include using an official project e-mail address, posting via an official social media | ||
account, or acting as an appointed representative at an online or offline event. Representation of a | ||
project may be further defined and clarified by project maintainers. | ||
|
||
### Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting | ||
the project team at [INSERT EMAIL ADDRESS]. All complaints will be reviewed and investigated and | ||
will result in a response that is deemed necessary and appropriate to the circumstances. The project | ||
team is obligated to maintain confidentiality with regard to the reporter of an incident. Further | ||
details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face | ||
temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
### Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at | ||
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html | ||
|
||
[homepage]: https://www.contributor-covenant.org | ||
|
||
For answers to common questions about this code of conduct, see | ||
https://www.contributor-covenant.org/faq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Copyright (c) 2019, Daniel Pereira | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.PHONY =: clean package rpm deb deps release | ||
.DEFAULT_GOAL := package | ||
.SILENT : clean package rpm deb deps release | ||
|
||
# Temporary paths for building the artifacts | ||
build_dir=build/pkg | ||
dist_dir=build/dist | ||
|
||
# Variables that are replaced in build time | ||
bin_path=/usr/bin | ||
lib_path=/usr/lib/ansible-bundler | ||
etc_path=/etc/ansible-bundler | ||
version=$(file < VERSION) | ||
|
||
# Package variables | ||
package_name=ansible-bundler | ||
package_license=3-Clause BSD | ||
package_vendor=Daniel Pereira | ||
package_maintainer=<[email protected]> | ||
package_url=https://github.com/kriansa/ansible-bundler | ||
|
||
deps: | ||
docker pull skandyla/fpm | ||
|
||
clean: | ||
rm -rf $(build_dir) $(dist_dir) | ||
rmdir $(shell dirname $(build_dir)) 2> /dev/null || true | ||
|
||
package: | ||
@test -d $(build_dir) && echo "Build dir already exists! Run make clean before." && exit 1 || true | ||
mkdir -p $(build_dir)/{etc,usr/lib} | ||
cp -r app/bin $(build_dir)/usr | ||
cp -r app/etc $(build_dir)/etc/ansible-bundler | ||
cp -r app/lib $(build_dir)/usr/lib/ansible-bundler | ||
sed -i \ | ||
-e 's#LIB_PATH=.*#LIB_PATH=$(lib_path)#' \ | ||
-e 's#ETC_PATH=.*#ETC_PATH=$(etc_path)#' \ | ||
-e 's#VERSION=.*#VERSION=$(version)#' \ | ||
-e 's/%VERSION%/$(version)/' \ | ||
$(build_dir)/usr/bin/bundle-playbook | ||
echo "Built package v$(version) on directory '$(build_dir)'" | ||
|
||
deb: | ||
test -d $(dist_dir) || mkdir -p $(dist_dir) | ||
docker run -it --rm -v "$(shell pwd):/mnt" --entrypoint '' skandyla/fpm \ | ||
/bin/bash -c 'fpm -n "$(package_name)" -s dir -t deb -v $(version) \ | ||
--config-files /etc/ansible-bundler/ansible.cfg --deb-no-default-config-files \ | ||
--license "$(package_license)" --vendor "$(package_vendor)" \ | ||
--maintainer "$(package_maintainer)" --url "$(package_url)" \ | ||
-p /mnt/$(dist_dir) -C /mnt/$(build_dir) . > /dev/null \ | ||
&& chown $(shell id -u):$(shell id -g) /mnt/$(dist_dir)/*.deb' | ||
echo "DEB package build successfully into $(dist_dir)" | ||
|
||
rpm: | ||
test -d $(dist_dir) || mkdir -p $(dist_dir) | ||
docker run -it --rm -v "$(shell pwd):/mnt" --entrypoint '' skandyla/fpm \ | ||
/bin/bash -c 'fpm -n "$(package_name)" -s dir -t rpm -v $(version) \ | ||
--config-files /etc/ansible-bundler/ansible.cfg \ | ||
--license "$(package_license)" --vendor "$(package_vendor)" \ | ||
--maintainer "$(package_maintainer)" --url "$(package_url)" \ | ||
-p /mnt/$(dist_dir) -C /mnt/$(build_dir) . > /dev/null \ | ||
&& chown $(shell id -u):$(shell id -g) /mnt/$(dist_dir)/*.rpm' | ||
echo "RPM package build successfully into $(dist_dir)" | ||
|
||
release: | ||
# Get only the artifacts for this release version | ||
$(eval rpm_package := $(shell ls $(dist_dir)/ansible-bundler-$(version)*.rpm)) | ||
$(eval deb_package := $(shell ls $(dist_dir)/ansible-bundler_$(version)*.deb)) | ||
|
||
# This task uses my own release helper, available here: | ||
# https://github.com/kriansa/dotfiles/blob/master/plugins/git/bin/git-release | ||
git release $(version) --use-version-file --artifact="$(rpm_package)" --artifact="$(deb_package)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# :package: Ansible Bundler | ||
|
||
Ansible Bundler embeds together a full playbook and its dependencies so you can run it it from a | ||
single binary on _any*_ computer, having just Python as a host dependency - you don't even need | ||
Ansible! | ||
|
||
The closest that Ansible provides natively for this is `ansible-pull`, but it requires the host to | ||
have Ansible properly installed, and you need to manage the playbook location yourself. | ||
|
||
While playbooks were never meant to be used as standalone packages, Ansible offers tools to help on | ||
more complex deployments, such as [Tower](https://www.ansible.com/products/tower) and | ||
[AWX](https://github.com/ansible/awx) _(Tower's open-source upstream project)_. | ||
|
||
<sub>* Well, we currently only support Unix based OSes.</sub> | ||
|
||
## Use case | ||
|
||
Ansible is awesome. It's so powerful and flexible that we can use from server provisioning to | ||
automating mundane tasks such as bootstraping [your own](https://github.com/kriansa/dotfiles) | ||
computer. | ||
|
||
One thing that it lacks though is the ability to be used for simple auto scaling deployments where | ||
you just want to pull a playbook and run it easily. Currently, you need to setup Ansible, ensure you | ||
have a repository to download the files, manage the right permissions to it and then run | ||
`ansible-pull`. This can get harder when you have more complex playbooks with several dependencies. | ||
|
||
Ansible Bundler makes these steps easier by having a single binary that takes care of setting up | ||
Ansible on the host and executing the playbook without having to do anything globally (such as | ||
installing ansible). You can simply pull the playbook binary and execute it right away. | ||
|
||
## Usage | ||
|
||
##### Generate a new self-contained playbook: | ||
|
||
```shell | ||
$ bundle-playbook -f playbook.yml | ||
``` | ||
|
||
##### Run it on the host: | ||
|
||
```shell | ||
$ ./playbook.run | ||
``` | ||
|
||
> You will need Python on the host in order to run the final executable. :+1: | ||
##### Build with dependencies | ||
|
||
```shell | ||
$ bundle-playbook --playbook-file=playbook.yml \ | ||
--requirements-file=requirements.yml \ | ||
--extra-deps=files | ||
``` | ||
|
||
> You can pass multiple `--extra-deps` (short `-d`) parameters. | ||
## Installation | ||
|
||
Currently you can download and install it using the pre-built packages that are available in RPM and | ||
DEB formats on [Github releases](https://github.com/kriansa/ansible-bundler/releases). They should | ||
work on most RHEL-based distros (CentOS, Fedora, Amazon Linux, etc) as well as on Debian-based | ||
distros (Ubuntu, Mint, etc). There's also a [PKGBUILD | ||
available](https://github.com/kriansa/PKGBUILDs/tree/master/pkgs/ansible-bundler) if you're using | ||
Arch. | ||
|
||
If your distro is not compatible with the prebuilt packages, please refer to [Building](#building) | ||
below. | ||
|
||
## Building | ||
|
||
You will need Docker installed on your machine. When you have it installed, you can proceed | ||
installing the dependencies with: | ||
|
||
```shell | ||
$ make deps | ||
``` | ||
|
||
This is only required once. After that you're good to go. You can currently build the package in a | ||
directory structure that you can later copy to your root filesystem. This is very useful as a base | ||
for building OS packages for most package managers such as RPM or DEB. | ||
|
||
```shell | ||
$ make | ||
``` | ||
|
||
> The output will be at `build/pkg` | ||
In fact, we offer support for building `deb` and `rpm` artifacts out of the box: | ||
|
||
```shell | ||
$ make deb rpm | ||
``` | ||
|
||
> The output will be at `build/dist` | ||
## Contributing | ||
|
||
Pull requests are welcome. For major changes, please open an issue first to discuss what you would | ||
like to change. | ||
|
||
Please make sure to update tests as appropriate. For more information, please refer to | ||
[Contributing](CONTRIBUTING.md). | ||
|
||
## License | ||
|
||
This project is licensed under the BSD 3-Clause License - see the [LICENSE.md](LICENSE.md) file for | ||
details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Oops, something went wrong.