├── .gitignore ├── mitamae ├── files │ ├── avatar.png │ ├── private_gitconfig │ ├── wpa_supplicant_override.conf │ ├── 1k5_gitconfig │ ├── yubico-stable-400 │ └── 99-usb-audio.conf ├── apt.rb ├── definitions │ ├── add_user_to_group.rb │ ├── rustup.rb │ ├── go_get.rb │ ├── gossm_install.rb │ ├── rust_tool_install.rb │ ├── mcfly_install.rb │ ├── starship_install.rb │ ├── k9s_install.rb │ ├── terraform_docs_install.rb │ ├── helm_install.rb │ ├── docker_creds_install.rb │ ├── tflint_install.rb │ ├── go_chromecast_install.rb │ ├── fzf_install.rb │ └── aws_cli_install.rb ├── docker.rb ├── hashicorp.rb ├── udev.rb ├── apparmor.rb ├── mitamae.rb ├── mpv_inhibit_plugin.rb ├── vars.yml ├── repos.rb ├── gsettings.rb ├── configuration.rb └── packages.rb ├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .rubocop.yml ├── mocks ├── gsettings └── systemctl ├── .gitmodules ├── run ├── LICENSE.md ├── Vagrantfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /.vagrant 2 | -------------------------------------------------------------------------------- /mitamae/files/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moritzheiber/laptop-provisioning/HEAD/mitamae/files/avatar.png -------------------------------------------------------------------------------- /mitamae/files/private_gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | email = hello@heiber.im 3 | name = Moritz Heiber 4 | signingkey = E3D5E107 5 | [commit] 6 | gpgsign = true 7 | -------------------------------------------------------------------------------- /mitamae/files/wpa_supplicant_override.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart= 3 | ExecStart=/usr/sbin/wpa_supplicant -q -u -s -O "DIR=/run/wpa_supplicant GROUP=netdev" 4 | -------------------------------------------------------------------------------- /mitamae/files/1k5_gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | email = moritz.heiber@1komma5grad.com 3 | name = Moritz Heiber 4 | signingkey = E9F5CB10 5 | [commit] 6 | gpgsign = true 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | -------------------------------------------------------------------------------- /mitamae/files/yubico-stable-400: -------------------------------------------------------------------------------- 1 | Package: * 2 | Pin: release o=LP-PPA-yubico-stable 3 | Pin-Priority: 400 4 | 5 | 6 | Package: libpam-u2f libu2f-host0 pamu2fcfg 7 | Pin: release o=LP-PPA-yubico-stable 8 | Pin-Priority: 500 9 | -------------------------------------------------------------------------------- /mitamae/apt.rb: -------------------------------------------------------------------------------- 1 | apt_conf = <&1").read.strip).nil? 4 | end 5 | end 6 | 7 | define :gossm_install, checksum: nil do 8 | version = params[:name] 9 | dest = "/tmp/gossm_#{version}.tar.gz" 10 | cs = params[:checksum] 11 | installed = GossmHelper.package_installed?(version) 12 | 13 | download "https://github.com/gjbae1212/gossm/releases/download/v#{version}/gossm_#{version}_Linux_x86_64.tar.gz" do 14 | destination dest 15 | checksum cs if cs 16 | not_if { installed } 17 | end 18 | 19 | execute "Extracting #{dest}" do 20 | command "tar xf #{dest} -C /usr/bin/ gossm" 21 | not_if { installed } 22 | end 23 | 24 | file dest do 25 | action :delete 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /mitamae/definitions/rust_tool_install.rb: -------------------------------------------------------------------------------- 1 | module RustToolHelper 2 | def self.package_installed?(command, version) 3 | !(Regexp.compile(version) =~ IO.popen("#{command} --version 2>&1").read.strip).nil? 4 | end 5 | end 6 | 7 | define :rust_tool_install, checksum: nil, version: nil, url: nil do 8 | name = params[:name] 9 | version = params[:version] 10 | url = params[:url] 11 | cs = params[:checksum] 12 | 13 | dest = "/tmp/rust_tool_#{name}_#{version}.tar.gz" 14 | installed = RustToolHelper.package_installed?(name, version) 15 | 16 | download url do 17 | destination dest 18 | checksum cs if cs 19 | not_if { installed } 20 | end 21 | 22 | execute "Extracting #{dest}" do 23 | command "tar xf #{dest} -C /usr/bin/" 24 | not_if { installed } 25 | end 26 | 27 | file dest do 28 | action :delete 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /mitamae/definitions/mcfly_install.rb: -------------------------------------------------------------------------------- 1 | module McflyHelper 2 | def self.package_installed?(command = 'mcfly', version) 3 | !(Regexp.compile(version) =~ IO.popen("#{command} --version").read.strip).nil? 4 | end 5 | end 6 | 7 | define :mcfly_install, checksum: nil do 8 | version = params[:name] 9 | dest = "/tmp/mcfly-#{version}.tar.gz" 10 | cs = params[:checksum] 11 | installed = McflyHelper.package_installed?(version) 12 | 13 | download "https://github.com/cantino/mcfly/releases/download/v#{node[:mcfly_version]}/mcfly-v#{node[:mcfly_version]}-x86_64-unknown-linux-musl.tar.gz" do 14 | destination dest 15 | checksum cs if cs 16 | not_if { installed } 17 | end 18 | 19 | execute "Extracting #{dest}" do 20 | command "tar xf #{dest} -C /usr/bin/ mcfly" 21 | not_if { installed } 22 | end 23 | 24 | file dest do 25 | action :delete 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /mitamae/definitions/starship_install.rb: -------------------------------------------------------------------------------- 1 | module StarshipHelper 2 | def self.package_installed?(command = 'starship', version) 3 | !(Regexp.compile(version) =~ IO.popen("#{command} --version").read.strip).nil? 4 | end 5 | end 6 | 7 | define :starship_install, checksum: nil do 8 | version = params[:name] 9 | dest = "/tmp/starship-#{version}.tar.gz" 10 | cs = params[:checksum] 11 | installed = StarshipHelper.package_installed?(version) 12 | 13 | download "https://github.com/starship/starship/releases/download/v#{node[:starship_version]}/starship-x86_64-unknown-linux-musl.tar.gz" do 14 | destination dest 15 | checksum cs if cs 16 | not_if { installed } 17 | end 18 | 19 | execute "Extracting #{dest}" do 20 | command "tar xf #{dest} -C /usr/bin/ starship" 21 | not_if { installed } 22 | end 23 | 24 | file dest do 25 | action :delete 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /mitamae/definitions/k9s_install.rb: -------------------------------------------------------------------------------- 1 | module K9sHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile(version) =~ `#{binary} version 2> /dev/null`).nil? 4 | end 5 | end 6 | 7 | define :k9s_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | 16 | tmp_dest = "/tmp/k9s_#{version}.tar.gz" 17 | installed = K9sHelper.package_installed?("#{destination}/k9s", version) 18 | 19 | download source_url do 20 | destination tmp_dest 21 | checksum cs if cs 22 | not_if { installed } 23 | end 24 | execute "Extracting #{tmp_dest}" do 25 | command "tar xf #{tmp_dest} -C #{destination}/ k9s" 26 | not_if { installed } 27 | end 28 | 29 | file tmp_dest do 30 | action :delete 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /mitamae/definitions/terraform_docs_install.rb: -------------------------------------------------------------------------------- 1 | module TerraformDocsHelper 2 | def self.package_installed?(command = 'terraform-docs', version) 3 | !(Regexp.compile(version) =~ IO.popen("#{command} --version 2>&1").read.strip).nil? 4 | end 5 | end 6 | 7 | define :terraform_docs_install, checksum: nil do 8 | version = params[:name] 9 | dest = "/tmp/terraform_docs_#{version}.tar.gz" 10 | cs = params[:checksum] 11 | installed = TerraformDocsHelper.package_installed?(version) 12 | 13 | download "https://github.com/terraform-docs/terraform-docs/releases/download/v#{version}/terraform-docs-v#{version}-linux-amd64.tar.gz" do 14 | destination dest 15 | checksum cs if cs 16 | not_if { installed } 17 | end 18 | 19 | execute "Extracting #{dest}" do 20 | command "tar xf #{dest} -C /usr/bin/ terraform-docs" 21 | not_if { installed } 22 | end 23 | 24 | file dest do 25 | action :delete 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /mitamae/definitions/helm_install.rb: -------------------------------------------------------------------------------- 1 | module HelmHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile("v#{version}") =~ `#{binary} version -c 2> /dev/null`.lines.first).nil? 4 | end 5 | end 6 | 7 | define :helm_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | 16 | tmp_dest = "/tmp/helm_#{version}.tar.gz" 17 | installed = HelmHelper.package_installed?("#{destination}/helm", version) 18 | 19 | download source_url do 20 | destination tmp_dest 21 | checksum cs if cs 22 | not_if { installed } 23 | end 24 | execute "Extracting #{tmp_dest}" do 25 | command "tar xf #{tmp_dest} -C #{destination}/ --strip-components=1 linux-amd64/helm" 26 | not_if { installed } 27 | end 28 | 29 | file tmp_dest do 30 | action :delete 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /mitamae/definitions/docker_creds_install.rb: -------------------------------------------------------------------------------- 1 | module DockerCredsHelper 2 | def self.package_installed?(version) 3 | !(/#{version}/ =~ `#{location} version 2> /dev/null`.gsub("\n", '')).nil? 4 | end 5 | 6 | def self.location 7 | '/usr/bin/docker-credential-secretservice' 8 | end 9 | end 10 | 11 | define :docker_creds_install, checksum: nil, source_url: nil do 12 | version = params[:name] 13 | source_url = params[:source_url] 14 | dest = "/tmp/docker_creds_#{version}.tar.gz" 15 | cs = params[:checksum] 16 | installed = DockerCredsHelper.package_installed?(version) 17 | 18 | download source_url do 19 | destination dest 20 | checksum cs if cs 21 | not_if { installed } 22 | end 23 | 24 | execute "Extracting #{dest}" do 25 | command "tar xf #{dest} -C /usr/bin/" 26 | not_if { installed } 27 | end 28 | 29 | file DockerCredsHelper.location do 30 | mode '755' 31 | end 32 | 33 | file dest do 34 | action :delete 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /mitamae/definitions/tflint_install.rb: -------------------------------------------------------------------------------- 1 | module TflintCliHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile(version) =~ `#{binary} --version 2> /dev/null`.lines.first).nil? 4 | end 5 | end 6 | 7 | define :tflint_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | install_dest = destination.split('/')[0...-1].join('/') 16 | installed = TflintCliHelper.package_installed?(destination, version) 17 | tmp_file = "/tmp/tflint_#{version}.zip" 18 | 19 | download source_url do 20 | destination tmp_file 21 | checksum cs if cs 22 | not_if { installed } 23 | end 24 | 25 | execute 'Unzip tflint' do 26 | command "unzip -uo #{tmp_file} tflint -d #{install_dest}/" 27 | not_if { installed } 28 | end 29 | 30 | file tmp_file do 31 | action :delete 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /mitamae/definitions/go_chromecast_install.rb: -------------------------------------------------------------------------------- 1 | module GoChromecastHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile("v#{version}") =~ `#{binary} --version 2> /dev/null`.lines.first).nil? 4 | end 5 | end 6 | 7 | define :go_chromecast_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | 16 | tmp_dest = "/tmp/go_chromecast_#{version}.tar.gz" 17 | installed = GoChromecastHelper.package_installed?("#{destination}/go-chromecast", version) 18 | 19 | download source_url do 20 | destination tmp_dest 21 | checksum cs if cs 22 | not_if { installed } 23 | end 24 | execute "Extracting #{tmp_dest}" do 25 | command "tar xf #{tmp_dest} -C #{destination}/ go-chromecast" 26 | not_if { installed } 27 | end 28 | 29 | file tmp_dest do 30 | action :delete 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /mitamae/definitions/fzf_install.rb: -------------------------------------------------------------------------------- 1 | module FzfHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile(version) =~ `#{binary} --version 2> /dev/null`.lines.first).nil? 4 | end 5 | end 6 | 7 | define :fzf_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | install_dest = destination.split('/')[0...-1].join('/') 16 | 17 | tmp_dest = "/tmp/fzf_#{version}.tar.gz" 18 | installed = FzfHelper.package_installed?(destination, version) 19 | 20 | download source_url do 21 | destination tmp_dest 22 | checksum cs if cs 23 | not_if { installed } 24 | end 25 | execute "Extracting #{tmp_dest}" do 26 | command "tar xf #{tmp_dest} -C #{install_dest}/" 27 | user node[:login_user] 28 | not_if { installed } 29 | end 30 | 31 | file tmp_dest do 32 | action :delete 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mitamae/plugins/itamae-plugin-resource-pip"] 2 | path = mitamae/plugins/itamae-plugin-resource-pip 3 | url = https://github.com/moritzheiber/itamae-plugin-resource-pip.git 4 | [submodule "mitamae/plugins/mitamae-plugin-resource-apt-repository"] 5 | path = mitamae/plugins/mitamae-plugin-resource-apt-repository 6 | url = https://github.com/moritzheiber/mitamae-plugin-resource-apt-repository.git 7 | [submodule "mitamae/plugins/mitamae-plugin-resource-alternatives"] 8 | path = mitamae/plugins/mitamae-plugin-resource-alternatives 9 | url = https://github.com/moritzheiber/mitamae-plugin-resource-alternatives 10 | [submodule "mitamae/plugins/mitamae-plugin-resource-apt"] 11 | path = mitamae/plugins/mitamae-plugin-resource-apt 12 | url = https://github.com/moritzheiber/mitamae-plugin-resource-apt.git 13 | [submodule "mitamae/plugins/mitamae-plugin-resource-download"] 14 | path = mitamae/plugins/mitamae-plugin-resource-download 15 | url = https://github.com/moritzheiber/mitamae-plugin-resource-download.git 16 | -------------------------------------------------------------------------------- /mitamae/apparmor.rb: -------------------------------------------------------------------------------- 1 | apparmor_content = <<~APPARMOR 2 | /sys/class/ r, 3 | /sys/bus/ r, 4 | /sys/class/hidraw/ r, 5 | /run/udev/data/c24{1,7,9}:* r, 6 | /sys/devices/**/hidraw/hidraw*/uevent r, 7 | /dev/hidraw* rw, 8 | 9 | # Launching URLs from browser 10 | /usr/lib/**/gio-launch-desktop ixr, 11 | /usr/bin/env ixr, 12 | /usr/bin/snap ixr, 13 | /run/snapd.socket wr, 14 | 15 | @{PROC}/[0-9]*/oom_score_adj rw, 16 | @{PROC}/[0-9]*/cgroup r, 17 | APPARMOR 18 | 19 | apparmor_local_dir = '/etc/apparmor.d/local' 20 | firefox_apparmor_file = "#{apparmor_local_dir}/usr.bin.firefox" 21 | 22 | directory apparmor_local_dir do 23 | owner 'root' 24 | group 'root' 25 | mode '0755' 26 | end 27 | 28 | file firefox_apparmor_file do 29 | action :edit 30 | block do |content| 31 | content << apparmor_content 32 | end 33 | not_if "grep -qFx '#{apparmor_content.lines.first.strip}' #{firefox_apparmor_file}" 34 | notifies :restart, 'service[apparmor]', :immediately 35 | end 36 | 37 | service 'apparmor' do 38 | action :nothing 39 | end 40 | -------------------------------------------------------------------------------- /mitamae/mitamae.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'definitions/add_user_to_group' 2 | include_recipe 'definitions/go_get' 3 | include_recipe 'definitions/rustup' 4 | include_recipe 'definitions/docker_creds_install' 5 | include_recipe 'definitions/fzf_install' 6 | include_recipe 'definitions/helm_install' 7 | include_recipe 'definitions/go_chromecast_install' 8 | include_recipe 'definitions/k9s_install' 9 | include_recipe 'definitions/rust_tool_install' 10 | include_recipe 'definitions/gossm_install' 11 | include_recipe 'definitions/terraform_docs_install' 12 | include_recipe 'definitions/aws_cli_install' 13 | include_recipe 'definitions/starship_install' 14 | include_recipe 'definitions/mcfly_install' 15 | include_recipe 'definitions/tflint_install' 16 | 17 | include_recipe 'apt' 18 | include_recipe 'repos' 19 | include_recipe 'packages' 20 | include_recipe 'apparmor' 21 | include_recipe 'docker' 22 | include_recipe 'hashicorp' 23 | include_recipe 'configuration' 24 | include_recipe 'udev' 25 | include_recipe 'gsettings' 26 | include_recipe 'mpv_inhibit_plugin' 27 | -------------------------------------------------------------------------------- /mitamae/mpv_inhibit_plugin.rb: -------------------------------------------------------------------------------- 1 | plugin_name = 'mpv_inhibit_gnome.so' 2 | git_dir = '/tmp/mpv_inhibit_gnome' 3 | dest = "/home/#{node[:login_user]}/.config/mpv/scripts" 4 | plugin_file = "#{dest}/#{plugin_name}" 5 | 6 | directory dest do 7 | user node[:login_user] 8 | owner node[:login_user] 9 | group node[:login_user] 10 | end 11 | 12 | git git_dir do 13 | repository 'https://github.com/Guldoman/mpv_inhibit_gnome.git' 14 | not_if "test -f #{plugin_file}" 15 | user node[:login_user] 16 | notifies :run, 'execute[make_gnome_plugin]', :immediately 17 | end 18 | 19 | execute 'make_gnome_plugin' do 20 | cwd git_dir 21 | user node[:login_user] 22 | action :nothing 23 | command 'make' 24 | notifies :run, 'execute[mpv_plugin_install]', :immediately 25 | end 26 | 27 | execute 'mpv_plugin_install' do 28 | command "install -m0755 -o #{node[:login_user]} -g #{node[:login_user]} #{git_dir}/lib/#{plugin_name} #{plugin_file}" 29 | action :nothing 30 | user node[:login_user] 31 | end 32 | 33 | directory 'git_directory' do 34 | action :delete 35 | path git_dir 36 | end 37 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -Eeu -o pipefail 4 | 5 | MITAMAE_PATH="/usr/bin/mitamae" 6 | MITAMAE_VERSION="1.14.0" 7 | MITAMAE_CHECKSUM="318968af9995c83929a5aedd3216e9c4ecb14db2e53340efaac4444ff5e18bde" 8 | LOG_LEVEL="${LOG_LEVEL:-info}" 9 | OVERRIDES="${OVERRIDES:-}" 10 | NODE_ATTRIBUTES="--node-yaml vars.yml ${OVERRIDES}" 11 | 12 | _cleanup() { 13 | rm -f /tmp/mitamae 14 | } 15 | 16 | install_mitamae() { 17 | trap _cleanup EXIT TERM 18 | 19 | if [ -x "${MITAMAE_PATH}" ] ; then 20 | if ${MITAMAE_PATH} version | grep -vq ${MITAMAE_VERSION} ; then 21 | _run_install 22 | fi 23 | else 24 | _run_install 25 | fi 26 | } 27 | 28 | _run_install() { 29 | wget -O /tmp/mitamae "https://github.com/itamae-kitchen/mitamae/releases/download/v${MITAMAE_VERSION}/mitamae-x86_64-linux" && 30 | echo "${MITAMAE_CHECKSUM} /tmp/mitamae" | sha256sum -c - && 31 | sudo install -m 0755 /tmp/mitamae "${MITAMAE_PATH}" 32 | } 33 | 34 | install_mitamae 35 | 36 | ( 37 | cd mitamae/ 38 | # shellcheck disable=SC2086 39 | sudo -E mitamae local -l "${LOG_LEVEL}" ${NODE_ATTRIBUTES} mitamae.rb 40 | ) 41 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | on: 3 | pull_request: 4 | paths-ignore: 5 | - "README.md" 6 | - "LICENSE.md" 7 | - ".github/**" 8 | branches: 9 | - "*" 10 | push: 11 | paths-ignore: 12 | - "README.md" 13 | - "LICENSE.md" 14 | - ".github/**" 15 | branches: 16 | - main 17 | 18 | jobs: 19 | test: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v4 23 | with: 24 | submodules: recursive 25 | - name: Update and install dependencies 26 | shell: bash 27 | env: 28 | DEBIAN_FRONTEND: noninteractive 29 | run: | 30 | sudo apt update 31 | sudo -E apt install -y --no-install-recommends curl ca-certificates software-properties-common 32 | curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - 33 | sudo -E apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" 34 | sudo apt update -qq 35 | sudo -E apt install --no-install-recommends vagrant 36 | - name: Test 37 | shell: bash 38 | run: | 39 | vagrant up 40 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © 2017 Moritz Heiber 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /mitamae/definitions/aws_cli_install.rb: -------------------------------------------------------------------------------- 1 | module AwsCliHelper 2 | def self.package_installed?(binary, version) 3 | !(Regexp.compile(version) =~ `#{binary} --version 2> /dev/null`.lines.first).nil? 4 | end 5 | end 6 | 7 | define :aws_cli_install, 8 | checksum: nil, 9 | destination: nil, 10 | source_url: nil do 11 | version = params[:name] 12 | source_url = params[:source_url] 13 | cs = params[:checksum] 14 | destination = params[:destination] 15 | install_dest = destination.split('/')[0...-1].join('/') 16 | installed = AwsCliHelper.package_installed?(destination, version) 17 | 18 | tmp_directory = "/tmp/awscliv2_#{version}" 19 | tmp_dest = "#{tmp_directory}.zip" 20 | 21 | download source_url do 22 | destination tmp_dest 23 | checksum cs if cs 24 | not_if { installed } 25 | end 26 | 27 | directory tmp_directory do 28 | action :create 29 | user node[:login_user] 30 | not_if { installed } 31 | end 32 | 33 | execute 'Unzip AWS CLI v2' do 34 | command "unzip #{tmp_dest} -d #{tmp_directory}/" 35 | user node[:login_user] 36 | not_if { installed } 37 | end 38 | 39 | execute 'Install AWS CLI v2' do 40 | command "#{tmp_directory}/aws/install -u --install-dir #{install_dest}/aws-cli --bin-dir ~/.local/bin" 41 | user node[:login_user] 42 | not_if { installed } 43 | end 44 | 45 | directory tmp_directory do 46 | action :delete 47 | end 48 | 49 | file tmp_dest do 50 | action :delete 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | initial_user = 'mheiber' 2 | provisioning_script = <