├── .editorconfig ├── .envrc ├── .gitattributes ├── .github ├── CODEOWNERS ├── lock.yml └── workflows │ ├── ci.yml │ ├── conventional-commits.yml │ ├── copilot-setup-steps.yml │ ├── prevent-file-change.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .markdownlint-cli2.yaml ├── .overcommit.yml ├── .release-please-manifest.json ├── .yamllint ├── Berksfile ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── TESTING.md ├── attributes └── default.rb ├── chefignore ├── documentation └── packagecloud_repo.md ├── kitchen.dokken.yml ├── kitchen.exec.yml ├── kitchen.global.yml ├── kitchen.yml ├── libraries └── helper.rb ├── metadata.rb ├── release-please-config.json ├── renovate.json ├── resources └── repo.rb ├── templates └── default │ ├── apt.erb │ └── yum.erb └── test ├── fixtures └── cookbooks │ └── test │ ├── metadata.rb │ └── recipes │ ├── default.rb │ └── distro_deps.rb └── integration └── default ├── controls └── default_spec.rb ├── inspec.yml └── jakedotrb_spec.rb /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root=true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # 2 space indentation 12 | indent_style = space 13 | indent_size = 2 14 | 15 | # Avoid issues parsing cookbook files later 16 | charset = utf-8 17 | 18 | # Avoid cookstyle warnings 19 | trim_trailing_whitespace = true 20 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use chefworkstation 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @sous-chefs/maintainers 2 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | --- 2 | daysUntilLock: 365 3 | exemptLabels: [] 4 | lockLabel: false 5 | lockComment: > 6 | This thread has been automatically locked since there has not been 7 | any recent activity after it was closed. Please open a new issue for 8 | related bugs. 9 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: ci 3 | 4 | "on": 5 | pull_request: 6 | push: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | lint-unit: 12 | uses: sous-chefs/.github/.github/workflows/lint-unit.yml@5.0.3 13 | permissions: 14 | actions: write 15 | checks: write 16 | pull-requests: write 17 | statuses: write 18 | issues: write 19 | 20 | integration: 21 | needs: lint-unit 22 | runs-on: ubuntu-latest 23 | strategy: 24 | matrix: 25 | os: 26 | - "almalinux-8" 27 | - "almalinux-9" 28 | - "centos-7" 29 | - "centos-stream-8" 30 | - "centos-stream-9" 31 | - "debian-10" 32 | - "debian-11" 33 | - "rockylinux-8" 34 | - "rockylinux-9" 35 | - "ubuntu-1804" 36 | - "ubuntu-2004" 37 | - "ubuntu-2204" 38 | suite: 39 | - "default" 40 | fail-fast: false 41 | 42 | steps: 43 | - name: Check out code 44 | uses: actions/checkout@v5 45 | - name: Install Chef 46 | uses: actionshub/chef-install@3.0.1 47 | - name: Dokken 48 | uses: actionshub/test-kitchen@3.0.0 49 | env: 50 | CHEF_LICENSE: accept-no-persist 51 | KITCHEN_LOCAL_YAML: kitchen.dokken.yml 52 | with: 53 | suite: ${{ matrix.suite }} 54 | os: ${{ matrix.os }} 55 | -------------------------------------------------------------------------------- /.github/workflows/conventional-commits.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: conventional-commits 3 | 4 | "on": 5 | pull_request: 6 | types: 7 | - opened 8 | - reopened 9 | - edited 10 | - synchronize 11 | 12 | jobs: 13 | conventional-commits: 14 | uses: sous-chefs/.github/.github/workflows/conventional-commits.yml@5.0.3 15 | -------------------------------------------------------------------------------- /.github/workflows/copilot-setup-steps.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'Copilot Setup Steps' 3 | 4 | "on": 5 | workflow_dispatch: 6 | push: 7 | paths: 8 | - .github/workflows/copilot-setup-steps.yml 9 | pull_request: 10 | paths: 11 | - .github/workflows/copilot-setup-steps.yml 12 | 13 | jobs: 14 | copilot-setup-steps: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | contents: read 18 | steps: 19 | - name: Check out code 20 | uses: actions/checkout@v5 21 | - name: Install Chef 22 | uses: actionshub/chef-install@main 23 | - name: Install cookbooks 24 | run: berks install 25 | -------------------------------------------------------------------------------- /.github/workflows/prevent-file-change.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: prevent-file-change 3 | 4 | "on": 5 | pull_request: 6 | types: 7 | - opened 8 | - reopened 9 | - edited 10 | - synchronize 11 | 12 | jobs: 13 | prevent-file-change: 14 | uses: sous-chefs/.github/.github/workflows/prevent-file-change.yml@5.0.3 15 | secrets: 16 | token: ${{ secrets.GITHUB_TOKEN }} 17 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: release 3 | 4 | "on": 5 | push: 6 | branches: 7 | - main 8 | 9 | permissions: 10 | contents: write 11 | issues: write 12 | pull-requests: write 13 | packages: write 14 | attestations: write 15 | id-token: write 16 | 17 | jobs: 18 | release: 19 | uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@5.0.3 20 | secrets: 21 | token: ${{ secrets.PORTER_GITHUB_TOKEN }} 22 | supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }} 23 | supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }} 24 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Mark stale issues and pull requests 3 | 4 | "on": 5 | schedule: [cron: "0 0 * * *"] 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/stale@v10 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | close-issue-message: > 15 | Closing due to inactivity. 16 | If this is still an issue please reopen or open another issue. 17 | Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! 18 | Thanks, Sous-Chefs. 19 | days-before-close: 7 20 | days-before-stale: 365 21 | stale-issue-message: > 22 | Marking stale due to inactivity. 23 | Remove stale label or comment or this will be closed in 7 days. 24 | Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! 25 | Thanks, Sous-Chefs. 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | .config 3 | InstalledFiles 4 | pkg 5 | test/tmp 6 | test/version_tmp 7 | tmp 8 | _Store 9 | *~ 10 | *# 11 | .#* 12 | \#*# 13 | *.un~ 14 | *.tmp 15 | *.bk 16 | *.bkup 17 | 18 | # editor files 19 | .idea 20 | .*.sw[a-z] 21 | 22 | # ruby/bundler/rspec files 23 | .ruby-version 24 | .ruby-gemset 25 | .rvmrc 26 | Gemfile.lock 27 | .bundle 28 | *.gem 29 | coverage 30 | spec/reports 31 | 32 | # YARD / rdoc artifacts 33 | .yardoc 34 | _yardoc 35 | doc/ 36 | rdoc 37 | 38 | # chef infra stuff 39 | Berksfile.lock 40 | .kitchen 41 | kitchen.local.yml 42 | vendor/ 43 | .coverage/ 44 | .zero-knife.rb 45 | Policyfile.lock.json 46 | 47 | # vagrant stuff 48 | .vagrant/ 49 | .vagrant.d/ 50 | -------------------------------------------------------------------------------- /.markdownlint-cli2.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | ul-indent: false # MD007 3 | line-length: false # MD013 4 | no-duplicate-heading: false # MD024 5 | reference-links-images: false # MD052 6 | no-multiple-blanks: 7 | maximum: 2 8 | ignores: 9 | - .github/copilot-instructions.md 10 | -------------------------------------------------------------------------------- /.overcommit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | PreCommit: 3 | TrailingWhitespace: 4 | enabled: true 5 | YamlLint: 6 | enabled: true 7 | required_executable: "yamllint" 8 | ChefSpec: 9 | enabled: true 10 | required_executable: "chef" 11 | command: ["chef", "exec", "rspec"] 12 | Cookstyle: 13 | enabled: true 14 | required_executable: "cookstyle" 15 | command: ["cookstyle"] 16 | MarkdownLint: 17 | enabled: false 18 | required_executable: "npx" 19 | command: ["npx", "markdownlint-cli2", "'**/*.md'"] 20 | include: ["**/*.md"] 21 | 22 | CommitMsg: 23 | HardTabs: 24 | enabled: true 25 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "2.0.10" 3 | } 4 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | rules: 4 | line-length: 5 | max: 256 6 | level: warning 7 | document-start: disable 8 | braces: 9 | forbid: false 10 | min-spaces-inside: 0 11 | max-spaces-inside: 1 12 | min-spaces-inside-empty: -1 13 | max-spaces-inside-empty: -1 14 | comments: 15 | min-spaces-from-content: 1 16 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'test', path: 'test/fixtures/cookbooks/test' 7 | end 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # packagecloud 2 | 3 | This is the Changelog for the packagecloud cookbook 4 | 5 | ## [2.0.10](https://github.com/sous-chefs/packagecloud/compare/2.0.9...v2.0.10) (2025-10-16) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * **ci:** Update workflows to use release pipeline ([#86](https://github.com/sous-chefs/packagecloud/issues/86)) ([26779c5](https://github.com/sous-chefs/packagecloud/commit/26779c5cfa48e20335e275273b040d112c4adafe)) 11 | 12 | ## 2.0.2 - *2023-04-26* 13 | 14 | * Add metadata check from the shard workflow 15 | 16 | ## 2.0.1 - *2023-04-03* 17 | 18 | * Update README 19 | 20 | ## 2.0.0 - *2023-04-03* 21 | 22 | * Sous Chefs Adoption 23 | * Require Chef 15.3+ 24 | * Add standard files 25 | 26 | ## v1.0.1 (2018-10-25) 27 | 28 | Fix issues with newer versions of Chef (11+) by conditionally defining `source_url` and `issues_url` in metadata.rb 29 | 30 | ## v1.0.0 (2018-03-12) 31 | 32 | Lots of internal refactoring and fixes. Bumping the major number just incase, 33 | but the changes should not break anyone using this cookbook. 34 | 35 | ## v0.3.0 (2017-03-08) 36 | 37 | Fix force_os and force_dist for Ubuntu/Debian. Drop support for Ubuntu Lucid. Add support for Ubuntu Xenial. Ensure lsb_release is installed on Ubuntu/Debian. 38 | 39 | ## v0.2.5 (2016-08-11) 40 | 41 | Check for empty node hostname. Display error when a node's fully qualified hostname is not set; as returned by `hostname -f` 42 | 43 | ## v0.2.4 (2016-07-05) 44 | 45 | Add `proxy_host` and `proxy_port` attributes so that the cookbook can contact the packagecloud server. 46 | 47 | ## v0.2.3 (2016-06-01) 48 | 49 | Try to fix `metadata_expire` type (set as String) 50 | 51 | ## v0.2.2 (2016-06-01) 52 | 53 | Try to fix `metadata_expire` type (set as Integer) 54 | 55 | ## v0.2.1 (2016-05-31) 56 | 57 | Set `metadata_expire` option to default of 300 (5 minutes) to match the generated configs produced by the bash and manual install instructions. 58 | 59 | ## v0.2.0 (2016-02-17) 60 | 61 | Rework GPG paths to support new GPG endpoints for repos with repo-specific GPG keys. Old endpoints/URLs still work, too. 62 | 63 | ## v0.1.0 (2015-09-08) 64 | 65 | packagecloud cookbook versions 0.0.19 used an attribute called `default['packagecloud']['hostname']` for caching the local machine's hostname to avoid regenerating read tokens. 66 | 67 | This attribute has been removed as it is confusing and in some edge cases, buggy. 68 | 69 | Beginning in 0.1.0, you can use `default['packagecloud']['hostname_override']` to specify a hostname if ohai is unable to determine the hostname of the node on its own. 70 | 71 | ## v0.0.1 (2014-06-05) 72 | 73 | Initial release. 74 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Community Guidelines 2 | 3 | This project follows the Chef Community Guidelines 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Please refer to 4 | [https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # packagecloud cookbook 2 | 3 | [![Cookbook Version](https://img.shields.io/cookbook/v/packagecloud.svg)](https://supermarket.chef.io/cookbooks/packagecloud) 4 | [![CI State](https://github.com/sous-chefs/packagecloud/workflows/ci/badge.svg)](https://github.com/sous-chefs/packagecloud/actions?query=workflow%3Aci) 5 | [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) 6 | 7 | This cookbook provides a resource for installing repositories. 8 | 9 | ## Usage 10 | 11 | ## Resources 12 | 13 | - [packagecloud_repo](documentation/packagecloud_repo.md) 14 | 15 | ## Credits 16 | 17 | Computology, LLC. 18 | 19 | ## License 20 | 21 | ```text 22 | Licensed under the Apache License, Version 2.0 (the "License"); 23 | you may not use this file except in compliance with the License. 24 | You may obtain a copy of the License at 25 | 26 | http://www.apache.org/licenses/LICENSE-2.0 27 | 28 | Unless required by applicable law or agreed to in writing, software 29 | distributed under the License is distributed on an "AS IS" BASIS, 30 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 31 | See the License for the specific language governing permissions and 32 | limitations under the License. 33 | ``` 34 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | Please refer to [the community cookbook documentation on testing](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD). 4 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['packagecloud']['base_repo_path'] = '/install/repositories/' 2 | default['packagecloud']['gpg_key_path'] = '/gpgkey' 3 | default['packagecloud']['hostname_override'] = nil 4 | default['packagecloud']['proxy_host'] = nil 5 | default['packagecloud']['proxy_port'] = nil 6 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a Chef Infra Server or Supermarket. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | ehthumbs.db 9 | Icon? 10 | nohup.out 11 | Thumbs.db 12 | .envrc 13 | 14 | # EDITORS # 15 | ########### 16 | .#* 17 | .project 18 | .settings 19 | *_flymake 20 | *_flymake.* 21 | *.bak 22 | *.sw[a-z] 23 | *.tmproj 24 | *~ 25 | \#* 26 | REVISION 27 | TAGS* 28 | tmtags 29 | .vscode 30 | .editorconfig 31 | 32 | ## COMPILED ## 33 | ############## 34 | *.class 35 | *.com 36 | *.dll 37 | *.exe 38 | *.o 39 | *.pyc 40 | *.so 41 | */rdoc/ 42 | a.out 43 | mkmf.log 44 | 45 | # Testing # 46 | ########### 47 | .circleci/* 48 | .codeclimate.yml 49 | .delivery/* 50 | .foodcritic 51 | .kitchen* 52 | .mdlrc 53 | .overcommit.yml 54 | .rspec 55 | .rubocop.yml 56 | .travis.yml 57 | .watchr 58 | .yamllint 59 | azure-pipelines.yml 60 | Dangerfile 61 | examples/* 62 | features/* 63 | Guardfile 64 | kitchen*.yml 65 | mlc_config.json 66 | Procfile 67 | Rakefile 68 | spec/* 69 | test/* 70 | 71 | # SCM # 72 | ####### 73 | .git 74 | .gitattributes 75 | .gitconfig 76 | .github/* 77 | .gitignore 78 | .gitkeep 79 | .gitmodules 80 | .svn 81 | */.bzr/* 82 | */.git 83 | */.hg/* 84 | */.svn/* 85 | 86 | # Berkshelf # 87 | ############# 88 | Berksfile 89 | Berksfile.lock 90 | cookbooks/* 91 | tmp 92 | 93 | # Bundler # 94 | ########### 95 | vendor/* 96 | Gemfile 97 | Gemfile.lock 98 | 99 | # Policyfile # 100 | ############## 101 | Policyfile.rb 102 | Policyfile.lock.json 103 | 104 | # Documentation # 105 | ############# 106 | CODE_OF_CONDUCT* 107 | CONTRIBUTING* 108 | documentation/* 109 | TESTING* 110 | UPGRADING* 111 | 112 | # Vagrant # 113 | ########### 114 | .vagrant 115 | Vagrantfile 116 | -------------------------------------------------------------------------------- /documentation/packagecloud_repo.md: -------------------------------------------------------------------------------- 1 | # `pacakgecloud_repo` 2 | 3 | The packagecloud_repo resource manages the installation of package repositories on various systems, including Debian, RHEL, Fedora, and Amazon Linux. It supports deb, rpm, and gem package types. 4 | Properties 5 | 6 | The following table provides an overview of the available properties for packagecloud_repo: 7 | 8 | | Property | Type | Description | Default | 9 | |-----------------|---------|------------------------------------------------------------------------------------------------|---------------------------| 10 | | repository | String | The name of the repository to install. | | 11 | | master_token | String | The master token for the repository. This is only required for private repositories. | | 12 | | force_os | String | The OS to force for the repository. This is only required for some repositories. | | 13 | | force_dist | String | The distribution to force for the repository. This is only required for some repositories. | | 14 | | type | String | The type of repository to install. Valid values are `deb`, `rpm`, and `gem`. | | 15 | | base_url | String | The base URL for the repository. This is only required for packagecloud:enterprise users. | `https://packagecloud.io` | 16 | | priority | Integer | The priority of the repository. This is only required for Debian-based systems. | false | 17 | | metadata_expire | String | The metadata expiration time for the repository. This is only required for RHEL-based systems. | 300 | 18 | 19 | ## Examples 20 | 21 | ```ruby 22 | packagecloud_repo "computology/packagecloud-cookbook-test" do 23 | type "deb" 24 | end 25 | ``` 26 | 27 | ### Public Repository 28 | 29 | ```ruby 30 | packagecloud_repo "computology/packagecloud-cookbook-test-public" 31 | ``` 32 | 33 | ### Private Repositories 34 | 35 | For private repositories, you need to supply a `master_token`: 36 | 37 | ```ruby 38 | packagecloud_repo "computology/packagecloud-cookbook-test-private" do 39 | master_token "762748f7ae0bfdb086dd539575bdc8cffdca78c6a9af0db9" 40 | end 41 | ``` 42 | 43 | ### Enterprise Users 44 | 45 | For packagecloud:enterprise users, add `base_url` to your resource: 46 | 47 | ```ruby 48 | packagecloud_repo "computology/packagecloud-cookbook-test-private" do 49 | base_url "https://packages.example.com" 50 | master_token "762748f7ae0bfdb086dd539575bdc8cffdca78c6a9af0db9" 51 | end 52 | ``` 53 | 54 | ### Force OS and Dist 55 | 56 | For forcing the os and dist for repository install: 57 | 58 | ```ruby 59 | packagecloud_repo 'computology/packagecloud-cookbook-test-public' do 60 | force_os 'rhel' 61 | force_dist '6.5' 62 | end 63 | ``` 64 | 65 | This cookbook performs checks to determine if a package exists before attempting to install it. To enable proxy support _for these checks_ (not to be confused with proxy support for your package manager of choice), add the following attributes to your cookbook: 66 | 67 | ```ruby 68 | default['packagecloud']['proxy_host'] = 'myproxy.organization.com' 69 | default['packagecloud']['proxy_port'] = '80' 70 | ``` 71 | -------------------------------------------------------------------------------- /kitchen.dokken.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: dokken 3 | privileged: true 4 | chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> 5 | 6 | transport: { name: dokken } 7 | provisioner: { name: dokken } 8 | 9 | platforms: 10 | - name: almalinux-8 11 | driver: 12 | image: dokken/almalinux-8 13 | pid_one_command: /usr/lib/systemd/systemd 14 | 15 | - name: almalinux-9 16 | driver: 17 | image: dokken/almalinux-9 18 | pid_one_command: /usr/lib/systemd/systemd 19 | 20 | - name: amazonlinux-2023 21 | driver: 22 | image: dokken/amazonlinux-2023 23 | pid_one_command: /usr/lib/systemd/systemd 24 | 25 | - name: centos-7 26 | driver: 27 | image: dokken/centos-7 28 | pid_one_command: /usr/lib/systemd/systemd 29 | 30 | - name: centos-stream-8 31 | driver: 32 | image: dokken/centos-stream-8 33 | pid_one_command: /usr/lib/systemd/systemd 34 | 35 | - name: centos-stream-9 36 | driver: 37 | image: dokken/centos-stream-9 38 | pid_one_command: /usr/lib/systemd/systemd 39 | 40 | - name: debian-9 41 | driver: 42 | image: dokken/debian-9 43 | pid_one_command: /bin/systemd 44 | 45 | - name: debian-10 46 | driver: 47 | image: dokken/debian-10 48 | pid_one_command: /bin/systemd 49 | 50 | - name: debian-11 51 | driver: 52 | image: dokken/debian-11 53 | pid_one_command: /bin/systemd 54 | 55 | - name: debian-12 56 | driver: 57 | image: dokken/debian-12 58 | pid_one_command: /bin/systemd 59 | 60 | - name: fedora-latest 61 | driver: 62 | image: dokken/fedora-latest 63 | pid_one_command: /usr/lib/systemd/systemd 64 | 65 | - name: opensuse-leap-15 66 | driver: 67 | image: dokken/opensuse-leap-15 68 | pid_one_command: /usr/lib/systemd/systemd 69 | 70 | - name: oraclelinux-7 71 | driver: 72 | image: dokken/oraclelinux-7 73 | pid_one_command: /usr/lib/systemd/systemd 74 | 75 | - name: oraclelinux-8 76 | driver: 77 | image: dokken/oraclelinux-8 78 | pid_one_command: /usr/lib/systemd/systemd 79 | 80 | - name: oraclelinux-9 81 | driver: 82 | image: dokken/oraclelinux-9 83 | pid_one_command: /usr/lib/systemd/systemd 84 | 85 | - name: rockylinux-8 86 | driver: 87 | image: dokken/rockylinux-8 88 | pid_one_command: /usr/lib/systemd/systemd 89 | 90 | - name: rockylinux-9 91 | driver: 92 | image: dokken/rockylinux-9 93 | pid_one_command: /usr/lib/systemd/systemd 94 | 95 | - name: ubuntu-18.04 96 | driver: 97 | image: dokken/ubuntu-18.04 98 | pid_one_command: /bin/systemd 99 | 100 | - name: ubuntu-20.04 101 | driver: 102 | image: dokken/ubuntu-20.04 103 | pid_one_command: /bin/systemd 104 | 105 | - name: ubuntu-22.04 106 | driver: 107 | image: dokken/ubuntu-22.04 108 | pid_one_command: /bin/systemd 109 | 110 | - name: ubuntu-23.04 111 | driver: 112 | image: dokken/ubuntu-23.04 113 | pid_one_command: /bin/systemd 114 | -------------------------------------------------------------------------------- /kitchen.exec.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: { name: exec } 3 | transport: { name: exec } 4 | 5 | platforms: 6 | - name: macos-latest 7 | - name: windows-latest 8 | -------------------------------------------------------------------------------- /kitchen.global.yml: -------------------------------------------------------------------------------- 1 | --- 2 | provisioner: 3 | name: chef_infra 4 | product_name: chef 5 | product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> 6 | channel: stable 7 | install_strategy: once 8 | chef_license: accept 9 | enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %> 10 | multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %> 11 | deprecations_as_errors: true 12 | log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> 13 | 14 | verifier: 15 | name: inspec 16 | 17 | platforms: 18 | - name: almalinux-8 19 | - name: almalinux-9 20 | - name: amazonlinux-2023 21 | - name: centos-7 22 | - name: centos-stream-8 23 | - name: centos-stream-9 24 | - name: debian-9 25 | - name: debian-10 26 | - name: debian-11 27 | - name: debian-12 28 | - name: fedora-latest 29 | - name: opensuse-leap-15 30 | - name: oraclelinux-7 31 | - name: oraclelinux-8 32 | - name: oraclelinux-9 33 | - name: rockylinux-8 34 | - name: rockylinux-9 35 | - name: ubuntu-18.04 36 | - name: ubuntu-20.04 37 | - name: ubuntu-22.04 38 | - name: ubuntu-23.04 39 | -------------------------------------------------------------------------------- /kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | 5 | provisioner: 6 | name: chef_infra 7 | product_name: <%= ENV['CHEF_PRODUCT_NAME'] || 'chef' %> 8 | product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> 9 | chef_license: accept-no-persist 10 | enforce_idempotency: true 11 | multiple_converge: 2 12 | deprecations_as_errors: true 13 | log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> 14 | 15 | verifier: 16 | name: inspec 17 | 18 | platforms: 19 | - name: almalinux-8 20 | - name: amazonlinux-2 21 | - name: debian-10 22 | - name: debian-11 23 | - name: centos-7 24 | - name: centos-stream-8 25 | - name: fedora-latest 26 | - name: ubuntu-18.04 27 | - name: ubuntu-20.04 28 | - name: ubuntu-22.04 29 | - name: rockylinux-8 30 | - name: opensuse-leap-15 31 | 32 | suites: 33 | - name: default 34 | run_list: 35 | - recipe[test::default] 36 | -------------------------------------------------------------------------------- /libraries/helper.rb: -------------------------------------------------------------------------------- 1 | module PackageCloud 2 | module Helper 3 | require 'net/https' 4 | 5 | def get(uri, params) 6 | uri.query = URI.encode_www_form(params) 7 | req = Net::HTTP::Get.new(uri.request_uri) 8 | 9 | req.basic_auth uri.user, uri.password if uri.user 10 | 11 | proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port') 12 | http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first)) 13 | http.use_ssl = true 14 | 15 | resp = http.start { |h| h.request(req) } 16 | 17 | case resp 18 | when Net::HTTPSuccess 19 | resp 20 | else 21 | raise resp.inspect 22 | end 23 | end 24 | 25 | def post(uri, params) 26 | req = Net::HTTP::Post.new(uri.request_uri) 27 | req.form_data = params 28 | 29 | req.basic_auth uri.user, uri.password if uri.user 30 | 31 | proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port') 32 | http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first)) 33 | http.use_ssl = true 34 | 35 | resp = http.start { |h| h.request(req) } 36 | 37 | case resp 38 | when Net::HTTPSuccess 39 | resp 40 | else 41 | raise resp.inspect 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'packagecloud' 2 | maintainer 'Sous Chefs' 3 | maintainer_email 'help@sous-chefs.org' 4 | license 'Apache-2.0' 5 | version '2.0.10' 6 | source_url 'https://github.com/sous-chefs/packagecloud' 7 | issues_url 'https://github.com/sous-chefs/packagecloud/issues' 8 | description 'Installs/Configures packagecloud.io repositories.' 9 | chef_version '>= 15.3' 10 | 11 | supports 'amazon' 12 | supports 'centos' 13 | supports 'debian' 14 | supports 'fedora' 15 | supports 'oracle' 16 | supports 'redhat' 17 | supports 'scientific' 18 | supports 'ubuntu' 19 | -------------------------------------------------------------------------------- /release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": { 3 | ".": { 4 | "package-name": "packagecloud", 5 | "changelog-path": "CHANGELOG.md", 6 | "release-type": "ruby", 7 | "include-component-in-tag": false, 8 | "version-file": "metadata.rb" 9 | } 10 | }, 11 | "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" 12 | } 13 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["config:base"], 4 | "packageRules": [ 5 | { 6 | "groupName": "Actions", 7 | "matchUpdateTypes": ["minor", "patch", "pin"], 8 | "automerge": true, 9 | "addLabels": ["Release: Patch", "Skip: Announcements"] 10 | }, 11 | { 12 | "groupName": "Actions", 13 | "matchUpdateTypes": ["major"], 14 | "automerge": false, 15 | "addLabels": ["Release: Patch", "Skip: Announcements"] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /resources/repo.rb: -------------------------------------------------------------------------------- 1 | unified_mode true 2 | 3 | property :repository, 4 | String, 5 | name_property: true 6 | 7 | property :master_token, 8 | String 9 | 10 | property :force_os, 11 | String 12 | 13 | property :force_dist, 14 | String 15 | 16 | property :type, 17 | String, 18 | equal_to: %w(deb rpm gem), 19 | default: lazy { 20 | value_for_platform_family( 21 | 'debian' => 'deb', 22 | %w(rhel fedora amazon) => 'rpm' 23 | ) 24 | } 25 | 26 | property :base_url, 27 | String, 28 | default: 'https://packagecloud.io' 29 | 30 | property :priority, 31 | [Integer, true, false], 32 | default: false 33 | 34 | property :metadata_expire, 35 | String, 36 | regex: [/^\d+[d|h|m]?$/], 37 | default: '300' 38 | 39 | action :add do 40 | case new_resource.type 41 | when 'deb' 42 | install_deb 43 | when 'rpm' 44 | install_rpm 45 | when 'gem' 46 | install_gem 47 | else 48 | raise "#{new_resource.type} is an unknown package type." 49 | end 50 | end 51 | 52 | action_class do 53 | include ::PackageCloud::Helper 54 | 55 | require 'uri' 56 | 57 | def gpg_url(base_url, repo, format, master_token) 58 | base_install_url = ::File.join(base_url, node['packagecloud']['base_repo_path']) 59 | ext = (format == :deb) ? 'list' : 'repo' 60 | gpg_key_url_endpoint = construct_uri_with_options(base_url: base_install_url, repo: repo, endpoint: "gpg_key_url.#{ext}") 61 | unless master_token.nil? 62 | gpg_key_url_endpoint.user = master_token 63 | gpg_key_url_endpoint.password = '' 64 | end 65 | 66 | URI(get(gpg_key_url_endpoint, install_endpoint_params).body.chomp) 67 | end 68 | 69 | def install_deb 70 | base_url = new_resource.base_url 71 | repo_url = construct_uri_with_options(base_url: base_url, repo: new_resource.repository, endpoint: os_platform) 72 | 73 | Chef::Log.debug("#{new_resource.name} deb repo url = #{repo_url}") 74 | 75 | package 'wget' 76 | package 'apt-transport-https' 77 | package 'lsb-release' 78 | 79 | ohai "reload-lsb-#{filename}" do 80 | plugin 'lsb' 81 | action :nothing 82 | subscribes :reload, 'package[lsb-release]', :immediately 83 | end 84 | 85 | repo_url = read_token(repo_url) 86 | 87 | template "/etc/apt/sources.list.d/#{filename}.list" do 88 | source 'apt.erb' 89 | cookbook 'packagecloud' 90 | mode '0644' 91 | variables( 92 | base_url: repo_url.to_s, 93 | distribution: dist_name, 94 | component: 'main' 95 | ) 96 | 97 | notifies :run, "execute[apt-key-add-#{filename}]", :immediately 98 | notifies :run, "execute[apt-get-update-#{filename}]", :immediately 99 | end 100 | 101 | execute "apt-key-add-#{filename}" do 102 | command lazy { 103 | gpg_url = gpg_url(new_resource.base_url, new_resource.repository, :deb, new_resource.master_token) 104 | "wget --auth-no-challenge -qO - #{gpg_url} | apt-key add -" 105 | } 106 | action :nothing 107 | end 108 | 109 | execute "apt-get-update-#{filename}" do 110 | command "apt-get update -o Dir::Etc::sourcelist=\"sources.list.d/#{filename}.list\"" \ 111 | ' -o Dir::Etc::sourceparts="-"' \ 112 | ' -o APT::Get::List-Cleanup="0"' 113 | action :nothing 114 | end 115 | end 116 | 117 | def install_rpm 118 | given_base_url = new_resource.base_url 119 | base_repo_url = ::File.join(given_base_url, node['packagecloud']['base_repo_path']) 120 | base_url_endpoint = construct_uri_with_options(base_url: base_repo_url, repo: new_resource.repository, endpoint: 'rpm_base_url') 121 | 122 | if new_resource.master_token 123 | base_url_endpoint.user = new_resource.master_token 124 | base_url_endpoint.password = '' 125 | end 126 | 127 | base_url = URI(get(base_url_endpoint, install_endpoint_params).body.chomp) 128 | 129 | Chef::Log.debug("#{new_resource.name} rpm base url = #{base_url}") 130 | 131 | package 'pygpgme' do 132 | ignore_failure true 133 | only_if { node['platform_version'].to_i < 8 } 134 | end 135 | 136 | log 'pygpgme_warning' do 137 | message 'The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. ' \ 138 | 'To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. ' \ 139 | 'More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F and https://github.com/opscode-cookbooks/yum-epel' 140 | 141 | level :warn 142 | not_if 'rpm -qa | grep -qw pygpgme' 143 | only_if { node['platform_version'].to_i < 8 } 144 | end 145 | 146 | gpg_url = gpg_url(new_resource.base_url, new_resource.repository, :rpm, new_resource.master_token) 147 | 148 | template "/etc/yum.repos.d/#{filename}.repo" do 149 | source 'yum.erb' 150 | cookbook 'packagecloud' 151 | mode '0644' 152 | variables base_url: base_url.to_s, 153 | name: filename, 154 | gpg_url: gpg_url.to_s, 155 | repo_gpgcheck: 1, 156 | description: filename, 157 | priority: new_resource.priority, 158 | metadata_expire: new_resource.metadata_expire 159 | 160 | notifies :run, "execute[yum-makecache-#{filename}]", :immediately 161 | notifies :run, "ruby_block[yum-cache-reload-#{filename}]", :immediately 162 | end 163 | 164 | # get the metadata for this repo only 165 | execute "yum-makecache-#{filename}" do 166 | command "yum -q makecache -y --disablerepo=* --enablerepo=#{filename}" 167 | action :nothing 168 | end 169 | 170 | # reload internal Chef yum cache 171 | ruby_block "yum-cache-reload-#{filename}" do 172 | block do 173 | if node['platform_version'].to_i >= 8 174 | Chef::Provider::Package::Dnf::PythonHelper.instance.restart 175 | else 176 | Chef::Provider::Package::Yum::YumCache.instance.reload 177 | end 178 | end 179 | action :nothing 180 | end 181 | end 182 | 183 | def install_gem 184 | repo_url = construct_uri_with_options(base_url: new_resource.base_url, repo: new_resource.repository) 185 | repo_url = read_token(repo_url).to_s 186 | 187 | execute "install packagecloud #{new_resource.name} repo as gem source" do 188 | command "gem source --add #{repo_url}" 189 | not_if "gem source --list | grep #{repo_url}" 190 | end 191 | end 192 | 193 | def read_token(repo_url) 194 | return repo_url unless new_resource.master_token 195 | 196 | base_url = new_resource.base_url 197 | 198 | base_repo_url = ::File.join(base_url, node['packagecloud']['base_repo_path']) 199 | 200 | uri = construct_uri_with_options(base_url: base_repo_url, repo: new_resource.repository, endpoint: 'tokens.text') 201 | uri.user = new_resource.master_token 202 | uri.password = '' 203 | 204 | resp = post(uri, install_endpoint_params) 205 | 206 | Chef::Log.debug("#{new_resource.name} TOKEN = #{resp.body.chomp}") 207 | 208 | repo_url.user = resp.body.chomp 209 | repo_url.password = '' 210 | repo_url 211 | end 212 | 213 | def install_endpoint_params 214 | dist = dist_name 215 | 216 | hostname = node['packagecloud']['hostname_override'] || 217 | node['fqdn'] || 218 | node['hostname'] 219 | 220 | if !hostname || hostname.empty? 221 | raise("Can't determine hostname! Set node['packagecloud']['hostname_override'] " \ 222 | 'if it cannot be automatically determined by Ohai.') 223 | end 224 | 225 | { os: os_platform, 226 | dist: dist, 227 | name: hostname } 228 | end 229 | 230 | def os_platform 231 | new_resource.force_os || node['platform'] 232 | end 233 | 234 | def dist_name 235 | new_resource.force_dist || value_for_platform_family( 236 | 'debian' => node['lsb']['codename'], 237 | 'amazon' => '6', 238 | %w(rhel fedora) => node['platform_version'] 239 | ) 240 | end 241 | 242 | def filename 243 | new_resource.name.gsub(/[^0-9A-Za-z.\-]/, '_') 244 | end 245 | 246 | def construct_uri_with_options(options) 247 | required_options = [:base_url, :repo] 248 | 249 | required_options.each do |opt| 250 | unless options[opt] 251 | raise ArgumentError, 252 | "A required option :#{opt} was not specified" 253 | end 254 | end 255 | 256 | options[:base_url] = append_trailing_slash(options[:base_url]) 257 | options[:repo] = append_trailing_slash(options[:repo]) 258 | 259 | URI.join(options.delete(:base_url), options.inject([]) { |acc, elem| acc << elem[1] }.join) 260 | end 261 | 262 | def append_trailing_slash(str) 263 | str.end_with?('/') ? str : str + '/' 264 | end 265 | end 266 | -------------------------------------------------------------------------------- /templates/default/apt.erb: -------------------------------------------------------------------------------- 1 | deb <%= @base_url %> <%= @distribution %> <%= @component %> 2 | deb-src <%= @base_url %> <%= @distribution %> <%= @component %> 3 | -------------------------------------------------------------------------------- /templates/default/yum.erb: -------------------------------------------------------------------------------- 1 | [<%= @name %>] 2 | name=<%= @description %> 3 | baseurl=<%= @base_url %> 4 | repo_gpgcheck=<%= @repo_gpgcheck %> 5 | <% if @priority -%> 6 | priority=<%=@priority %> 7 | <% end -%> 8 | gpgcheck=0 9 | enabled=1 10 | gpgkey=<%= @gpg_url %> 11 | sslverify=1 12 | sslcacert=/etc/pki/tls/certs/ca-bundle.crt 13 | <% if @metadata_expire %> 14 | metadata_expire=<%= @metadata_expire %> 15 | <% end %> 16 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | 3 | depends 'yum' 4 | depends 'packagecloud' 5 | version '0.1.0' 6 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | apt_update 2 | 3 | include_recipe 'test::distro_deps' 4 | 5 | packagecloud_repo 'damacus/packagecloud-test' 6 | 7 | packagecloud_repo 'damacus/packagecloud-test-private' do 8 | master_token '81aa4bd4e1bcc8eac6daf9862c46965c538e0ff74456ddb7' 9 | end 10 | 11 | packagecloud_repo 'damacus/packagecloud-test' do 12 | type 'gem' 13 | end 14 | 15 | packagecloud_repo 'damacus/packagecloud-test-private' do 16 | type 'gem' 17 | master_token '81aa4bd4e1bcc8eac6daf9862c46965c538e0ff74456ddb7' 18 | end 19 | 20 | package 'jake' # Private 21 | package 'packagecloud-test' # Public 22 | 23 | # gem_package 'jakedotrb' do 24 | # options '--bindir /usr/local/bin' 25 | # version '0.0.1' 26 | # source 'https://packagecloud.io/damacus/packagecloud-test-private' 27 | # end 28 | 29 | gem_package 'packagecloud-test-gem' do 30 | source 'https://packagecloud.io/damacus/packagecloud-test' 31 | options '--bindir /opt/bin' 32 | end 33 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/distro_deps.rb: -------------------------------------------------------------------------------- 1 | case node['platform_family'] 2 | when 'rhel', 'fedora', 'amazon' 3 | package %w(ruby rubygems) 4 | when 'debian' 5 | package %w(ruby dpkg-dev rubygems) 6 | end 7 | -------------------------------------------------------------------------------- /test/integration/default/controls/default_spec.rb: -------------------------------------------------------------------------------- 1 | describe command('ls /usr/local/bin/jake') do 2 | its(:exit_status) { should eq 0 } 3 | end 4 | 5 | describe command('/usr/local/bin/jake') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should eq "as it so happens, jake douglas is a very nice young man.\n" } 8 | end 9 | 10 | describe package('packagecloud-test') do 11 | it { should be_installed } 12 | end 13 | -------------------------------------------------------------------------------- /test/integration/default/inspec.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: packagecloud-integration-tests 3 | title: Integration tests for packagecloud cookbook 4 | summary: This InSpec profile contains integration tests for packagecloud cookbook 5 | supports: 6 | - os-family: linux 7 | -------------------------------------------------------------------------------- /test/integration/default/jakedotrb_spec.rb: -------------------------------------------------------------------------------- 1 | describe command('/usr/local/bin/jakedotrb') do 2 | its('exit_status') { should eq 0 } 3 | its('stdout') { should match /jake douglas is a very nice young man./ } 4 | end 5 | 6 | describe command('gem list jakedotrb') do 7 | its('exit_status') { should eq 0 } 8 | end 9 | --------------------------------------------------------------------------------