diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..d136f74 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @puppetlabs/night-s-watch diff --git a/README.md b/README.md new file mode 100644 index 0000000..4869d70 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# install-puppet + +One-shot shell script that can be used to install puppet-agent on a supported +POSIX platform. + +## Description + +This repository contains a Ruby script (`install.rb`), which when executed will +generate an `install.sh` file to be used for installing puppet-agent on +supported FOSS POSIX platforms. + +The script leverages Bolt tasks from the +[puppet_agent](https://forge.puppet.com/modules/puppetlabs/puppet_agent) and +[facts](https://forge.puppet.com/modules/puppetlabs/facts) modules, and +attempts to change as few things as possible in order to create a working shell +script which can be used with little to no external dependencies + +## Getting Started + +### Dependencies + +* A non-Windows platform for which Puppet provides official packages (see the full list [here](https://puppet.com/docs/puppet/latest/system_requirements.html#supported_operating_systems-packaged-platforms)) +* one of wget/curl/fetch/perl-LWP-Simple in order to download packages + +### Usage + +```sh +curl -sSL https://raw.githubusercontent.com/puppetlabs/install-puppet/main/install.sh | bash +``` + +Piping to `bash` is a controversial practice, so you are encouraged to inspect +the [contents of the +script](https://github.com/puppetlabs/install-puppet/blob/main/install.sh) +before executing it. + + +### Script arguments + +If run with no arguments, the script will install the latest stable version of puppet-agent. + +You can install a specific version using: +```sh +curl -sSL https://raw.githubusercontent.com/puppetlabs/install-puppet/main/install.sh | bash -s -- -v 6.24.0 +``` + +Below is the full list of configurable options: + +* `-v`/`--version` - install a specific puppet-agent version +* `-c`/`--collection` - install a specific puppet-agent collection (e.g. puppet7) +* `-n`/`--noop` - do a dry run, do not change any files +* `--cleanup` - remove the puppetlabs repository after installation finishes + +## Development + +The Ruby script uses parts of the `bash.sh` task from the +[facts](https://forge.puppet.com/modules/puppetlabs/facts) module, and the +`install_shell.sh` task from the +[puppet_agent](https://forge.puppet.com/modules/puppetlabs/puppet_agent) module +to generate the `install.sh` file. The modules are vendored as git submodules; +in order to initialize them, run `git submodule update --init` after cloning +this repository. + +After making your changes, run the following command to regenerate the shell script: +```sh +ruby install.rb +``` + +You can also run shellcheck on the resulting script, it will skip the vendored +task parts and only warn on code specific to this repository. + +```sh +shellcheck install.sh +``` + +## License + +This project is licensed under the Apache 2.0 License - see the LICENSE file for details diff --git a/install.rb b/install.rb index 92e6a3c..c7f7b12 100644 --- a/install.rb +++ b/install.rb @@ -33,22 +33,22 @@ HEREDOC } while [[ "$#" -gt 0 ]]; do - case $1 in - -v|--version) PT_version="$2"; shift ; - if beginswith "6." "$PT_version"; then - PT_collection="puppet6" - elif beginswith "7." "$PT_version"; then - PT_collection="puppet7" - else - PT_collection="puppet" - fi ;; - -c|--collection) PT_collection="$2"; shift ;; - --cleanup) PT_cleanup=true; shift ;; - -n|--noop) PT__noop=true; shift ;; - -h|--help) usage; exit ;; - *) echo "Unknown parameter passed: $1"; usage; exit 1 ;; - esac - shift + case $1 in + -v|--version) PT_version="$2"; shift ; + if beginswith "6." "$PT_version"; then + PT_collection="puppet6" + elif beginswith "7." "$PT_version"; then + PT_collection="puppet7" + else + PT_collection="puppet" + fi ;; + -c|--collection) PT_collection="$2"; shift ;; + --cleanup) PT_cleanup=true; shift ;; + -n|--noop) PT__noop=true; shift ;; + -h|--help) usage; exit ;; + *) echo "Unknown parameter passed: $1"; usage; exit 1 ;; + esac + shift done # shellcheck disable=SC1000-SC9999 @@ -71,4 +71,3 @@ if [[ $PT__noop != true ]]; then fi fi SH - diff --git a/install.sh b/install.sh index a3e7c0d..7f4557a 100755 --- a/install.sh +++ b/install.sh @@ -19,22 +19,22 @@ HEREDOC } while [[ "$#" -gt 0 ]]; do - case $1 in - -v|--version) PT_version="$2"; shift ; - if beginswith "6." "$PT_version"; then - PT_collection="puppet6" - elif beginswith "7." "$PT_version"; then - PT_collection="puppet7" - else - PT_collection="puppet" - fi ;; - -c|--collection) PT_collection="$2"; shift ;; - --cleanup) PT_cleanup=true; shift ;; - -n|--noop) PT__noop=true; shift ;; - -h|--help) usage; exit ;; - *) echo "Unknown parameter passed: $1"; usage; exit 1 ;; - esac - shift + case $1 in + -v|--version) PT_version="$2"; shift ; + if beginswith "6." "$PT_version"; then + PT_collection="puppet6" + elif beginswith "7." "$PT_version"; then + PT_collection="puppet7" + else + PT_collection="puppet" + fi ;; + -c|--collection) PT_collection="$2"; shift ;; + --cleanup) PT_cleanup=true; shift ;; + -n|--noop) PT__noop=true; shift ;; + -h|--help) usage; exit ;; + *) echo "Unknown parameter passed: $1"; usage; exit 1 ;; + esac + shift done # shellcheck disable=SC1000-SC9999