| 1 | theforeman.foreman.repositories |
| 2 | =============================== |
| 3 | |
| 4 | This role defines Products and Custom Repositories and enables Red Hat Repositories. |
| 5 | |
| 6 | Role Variables |
| 7 | -------------- |
| 8 | |
| 9 | This role supports the [Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables). |
| 10 | |
| 11 | - `foreman_products`: List of products to manage. |
| 12 | Each product is represented as a dictionary and can include `repository_sets` which represent Red Hat Repositories and should be used when the product name matches an existing Red Hat Product. |
| 13 | Each element of `repository_sets` must have a `name` and should specify the `basearch` and/or `releasever` only when multiple versions are available for that Product. |
| 14 | All repository sets for a Red Hat Product can be enabled by omitting `repository_sets` and instead specifying that the Product has `all_repositories: true`. When using this option it is also necessary to specify a list of repository `label`s for the Product (e.g. rhel-7-server-rpms). Be wary that this option can result in enabling a large number of unused repositories that, if added to sync plans, can greatly increase sync times and rapidly fill disk space. |
| 15 | Custom (i.e. non Red Hat) Products can also be defined, with associated `repositories` which represent custom repositories, and are required to have a `name`, `url`, and `content_type`; they may require additional fields and can take any parameter supported by [theforeman.foreman.repository](https://theforeman.github.io/foreman-ansible-modules/develop/plugins/repository_module.html). |
| 16 | The `organization` field can be specified for a product and repositories. The `organization` field defaults to `foreman_organization` variable for a product and defaults to the `organization` field of the product for repositories. |
| 17 | A variety of examples are demonstrated in the data structure below: |
| 18 | |
| 19 | ```yaml |
| 20 | foreman_products: |
| 21 | - name: Red Hat Enterprise Linux Server |
| 22 | repository_sets: |
| 23 | - name: Red Hat Enterprise Linux 7 Server (RPMs) |
| 24 | basearch: x86_64 |
| 25 | releasever: 7Server |
| 26 | - name: Red Hat Enterprise Linux 6 Server (RPMs) |
| 27 | basearch: x86_64 |
| 28 | releasever: 6Server |
| 29 | - name: Red Hat Enterprise Linux 7 Server - Extras (RPMs) |
| 30 | basearch: x86_64 |
| 31 | - name: Red Hat Enterprise Linux 7 Server - Optional (RPMs) |
| 32 | basearch: x86_64 |
| 33 | releasever: 7Server |
| 34 | - name: Red Hat Software Collections (for RHEL Server) |
| 35 | repository_sets: |
| 36 | - name: Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server |
| 37 | basearch: x86_64 |
| 38 | releasever: 7Server |
| 39 | - name: Red Hat Software Collections RPMs for Red Hat Enterprise Linux 6 Server |
| 40 | basearch: x86_64 |
| 41 | releasever: 6Server |
| 42 | - name: Red Hat Enterprise Linux for x86_64 |
| 43 | repository_sets: |
| 44 | - name: Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) |
| 45 | releasever: 8 |
| 46 | - name: Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) |
| 47 | releasever: 8 |
| 48 | - name: Red Hat Software Collections (for RHEL Server) |
| 49 | all_repositories: true |
| 50 | labels: |
| 51 | - rhel-server-rhscl-7-rpms |
| 52 | - name: CentOS Stream 8 |
| 53 | repositories: |
| 54 | - name: BaseOS x86_64 |
| 55 | content_type: yum |
| 56 | url: http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/ |
| 57 | - name: AppStream x86_64 |
| 58 | content_type: yum |
| 59 | url: http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/ |
| 60 | - name: Debian 10 |
| 61 | repositories: |
| 62 | - name: Debian 10 main |
| 63 | content_type: deb |
| 64 | url: http://deb.debian.org/debian |
| 65 | deb_components: main |
| 66 | deb_architectures: amd64 |
| 67 | deb_releases: buster |
| 68 | - name: Foreman Client |
| 69 | repositories: |
| 70 | - name: Foreman Client Debian 10 |
| 71 | url: https://apt.atix.de/debian |
| 72 | content_type: deb |
| 73 | deb_components: main |
| 74 | deb_architectures: amd64 |
| 75 | deb_releases: stable |
| 76 | - name: Foreman Client CentOS 7 |
| 77 | url: https://yum.theforeman.org/client/latest/el7/x86_64/ |
| 78 | content_type: yum |
| 79 | ``` |
| 80 | |
| 81 | Example Playbooks |
| 82 | ----------------- |
| 83 | |
| 84 | This example enables several Red Hat Repositories. There are a few important points to note about the structure of the data in the example: |
| 85 | - RHEL 8 repos have a different product name than previous RHEL versions. |
| 86 | - The RHEL 8 product already contains the `basearch` so it should not be specified on the RHEL 8 `repository_sets`, and the naming convention for `releasever` changed with RHEL 8 since system purpose removes the need for separate distributions like `Server` and `Workstation`. |
| 87 | - The optional and extras repositories do not have point releases so `releasever` should be omitted. |
| 88 | - The second Product is explicitly specified for "Other Organization" and thereby overwrites the default value of `foreman_organization`. |
| 89 | |
| 90 | ```yaml |
| 91 | - hosts: localhost |
| 92 | roles: |
| 93 | - role: theforeman.foreman.repositories |
| 94 | vars: |
| 95 | foreman_server_url: https://foreman.example.com |
| 96 | foreman_username: "admin" |
| 97 | foreman_password: "changeme" |
| 98 | foreman_organization: "Default Organization" |
| 99 | foreman_products: |
| 100 | - name: Red Hat Enterprise Linux Server |
| 101 | repository_sets: |
| 102 | - name: Red Hat Enterprise Linux 7 Server (RPMs) |
| 103 | basearch: x86_64 |
| 104 | releasever: 7Server |
| 105 | - name: Red Hat Enterprise Linux 6 Server (RPMs) |
| 106 | basearch: x86_64 |
| 107 | releasever: 6Server |
| 108 | - name: Red Hat Enterprise Linux 7 Server - Extras (RPMs) |
| 109 | basearch: x86_64 |
| 110 | - name: Red Hat Enterprise Linux 7 Server - Optional (RPMs) |
| 111 | basearch: x86_64 |
| 112 | releasever: 7Server |
| 113 | - name: Red Hat Enterprise Linux for x86_64 |
| 114 | organization: "Other Organization" |
| 115 | repository_sets: |
| 116 | - name: Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) |
| 117 | releasever: 8 |
| 118 | - name: Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) |
| 119 | releasever: 8 |
| 120 | ``` |