Debian Codegraph @

ansible_collections/theforeman/foreman/README.md

raw symbols SCIP
1 # Foreman Ansible Modules ![Build Status](https://github.com/theforeman/foreman-ansible-modules/workflows/CI/badge.svg)
2
3 Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello.
4
5 ## Documentation
6
7 A list of all modules and their documentation can be found at [theforeman.org/plugins/foreman-ansible-modules](https://theforeman.org/plugins/foreman-ansible-modules/).
8
9 ## Support
10
11 ### Supported Foreman and plugins versions
12
13 Modules should support any currently stable Foreman release and the matching set of plugins.
14 Some modules have additional features/arguments that are only applied when the corresponding plugin is installed.
15
16 We actively test the modules against the latest stable Foreman release and the matching set of plugins.
17
18 ### Supported Ansible Versions
19
20 The supported Ansible versions are aligned with currently maintained Ansible versions that support Collections (2.10+).
21 You can find the list of maintained Ansible versions [here](https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html).
22
23 ### Supported Python Versions
24
25 The supported Python versions are aligned with the currently supported Python versions by maintained Ansible releases.
26 You can find the list of maintained Ansible releases and their supported Python versions versions [here](https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html).
27
28 ### Known issues
29
30 * Some modules, e.g. `repository_sync` and `content_view_version`, trigger long running tasks on the server side. It might be beneficial to your playbook to wait for their completion in an asynchronous manner.
31 As Ansible has facilities to do so, the modules will wait unconditionally. See the [Ansible documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html) for putting tasks in the background.
32 Please make sure to set a high enough `async` value, as otherwise Ansible might abort the execution of the module while there is still a task running on the server, making status reporting fail.
33
34 * According to [Ansible documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html), using loop over Ansible resources can leak sensitive data. This applies to all modules, but especially those which require more secrets than the API credentials (`auth_source_ldap`, `compute_resource`, `host`, `hostgroup`, `http_proxy`, `image`, `repository`, `scc_account`, `user`). You can prevent this by using `no_log: true` on the task.
35
36 eg:
37
38 ```yaml
39 - name: Create compute resources
40 theforeman.foreman.compute_resource:
41 server_url: https://foreman.example.com
42 username: admin
43 password: changeme
44 validate_certs: true
45 name: "{{ item.name }}"
46 organizations: "{{ item.organizations | default(omit) }}"
47 locations: "{{ item.locations | default(omit) }}"
48 description: "{{ item.description | default(omit) }}"
49 provider: "{{ item.provider }}"
50 provider_params: "{{ item.provider_params | default(omit) }}"
51 state: "{{ item.state | default('present') }}"
52 loop: "{{ compute_resources }}"
53 no_log: true
54 ```
55 * Modules require write access to `~/.cache` (or wherever `$XDG_CACHE_HOME` points at). Otherwise the API documentation cannot be downloaded and you get errors like `[Errno 13] Permission denied: '/home/runner/.cache/apypie`. If on your system `~/.cache` is not writeable, please set the `$XDG_CACHE_HOME` environment variable to a directory Ansible can write to.
56
57 ## Installation
58
59 There are currently two ways to use the modules in your setup: install directly from Ansible Galaxy or via packages.
60
61 ### Installation from Ansible Galaxy
62
63 You can install the collection from [Ansible Galaxy](https://galaxy.ansible.com/theforeman/foreman) by running `ansible-galaxy collection install theforeman.foreman`.
64
65 After the installation, the modules are available as `theforeman.foreman.<module_name>`. Please see the [Using Ansible collections documentation](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for further details.
66
67 ### Installation via packages
68
69 The collection is also available as `ansible-collection-theforeman-foreman` from the `plugins` repository on `yum.theforeman.org` for Enterprise Linux systems and from the `plugins` repository on `deb.theforeman.org` for Debian and Ubuntu systems.
70
71 After installing the package, you can use the modules in the same way as when they are installed directly from Ansible Galaxy.
72
73 ## Installation From Source
74
75 For development or testing purposes, you can install the collection from source git repository. For production usage, see the instructions above on installing the latest stable release.
76
77 ### Installation from Github Repository
78
79 With Ansible >= 2.10, you can install from a Github repository (such as this one or your fork):
80
81 ```console
82 $ ansible-galaxy collection install git+https://github.com/theforeman/foreman-ansible-modules.git
83 ```
84
85 If you have configured GitHub to use SSH instead of HTTPS, you can do:
86
87 ```console
88 $ ansible-galaxy collection install [email protected]/theforeman/foreman-ansible-modules.git
89 ```
90
91 You can also specify a branch to use such as `devel` (below) or a feature branch that you are working with:
92
93 ```console
94 $ ansible-galaxy collection install git+https://github.com/theforeman/foreman-ansible-modules.git,devel
95 ```
96
97 To install from a `requirements.yml` file (useful when installing multiple collections) add a snippet to your `requirements.yml` like
98
99 ```yaml
100 ---
101 collections:
102 - name: https://github.com/theforeman/foreman-ansible-modules.git
103 type: git
104 version: develop
105 ```
106
107 And install all specified requirements with `ansible-galaxy install -r requirements.yml`
108
109 ### Building and Installing the Collection Locally
110
111 For all currently supported versions of Ansible, you can build the collection locally:
112
113 ```console
114 $ make dist
115 ```
116
117 And install it with:
118
119 ```console
120 $ ansible-galaxy collection install ./theforeman-foreman-*.tar.gz
121 ```
122
123 ## Dependencies
124
125 These dependencies are required for the Ansible controller, not the Foreman server.
126
127 * [`PyYAML`](https://pypi.org/project/PyYAML/)
128 * [`requests`](https://pypi.org/project/requests/)
129 * `rpm` for the RPM support in the `content_upload` module
130 * `debian` for the DEB support in the `content_upload` module
131
132 ## Module defaults groups
133
134 With ansible-core >= 2.12 and version >= 3.4.0 of the collection it is possible to specify defaults parameters for all modules in this collection using [Module defaults groups](https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups). Use it like this:
135
136 ```yaml
137 ---
138 - name: Configure Foreman
139 hosts: foreman.example.com
140
141 module_defaults:
142 group/theforeman.foreman.foreman:
143 server_url: "https://foreman.example.com"
144 username: "admin"
145 password: "changeme"
146
147 tasks:
148 - name: Setup architecture
149 theforeman.foreman.architecture:
150 name: "x86_64"
151 - name: Setup sync plan
152 theforeman.foreman.sync_plan:
153 organization: "Default Organization"
154 name: "Daily"
155 interval: "daily"
156 enabled: true
157 sync_date: "2025-07-10 00:00:00 +0000"
158 ```
159
160 # Foreman Ansible Roles
161
162 Roles using the Foreman Ansible Modules to configure Foreman and its plugins.
163
164 ## Documentation
165
166 For individual role documentation, check the README defined at `roles/rolename/README.md`.
167
168 ### Common Role Variables
169
170 - `foreman_server_url`: URL of the Foreman server. If the variable is not specified, the value of environment variable `FOREMAN_SERVER_URL` will be used instead.
171 - `foreman_username`: Username accessing the Foreman server. If the variable is not specified, the value of environment variable `FOREMAN_USERNAME` will be used instead.
172 - `foreman_password`: Password of the user accessing the Foreman server. If the variable is not specified, the value of environment variable `FOREMAN_PASSWORD` will be used instead.
173 - `foreman_validate_certs`: Whether or not to verify the TLS certificates of the Foreman server. If the variable is not specified, the value of environment variable `FOREMAN_VALIDATE_CERTS` will be used instead.
174 - `foreman_organization`: Organization where configuration will be applied.