|
1 |
| -Role Name |
2 |
| -========= |
| 1 | +# tower_configuration.license |
| 2 | +## Description |
| 3 | +An Ansible Role to deploy a license to Ansible Tower. |
3 | 4 |
|
4 |
| -A brief description of the role goes here. |
| 5 | +## Requirements |
| 6 | +ansible-galaxy collection install -r tests/collections/requirements.yml to be installed |
| 7 | +Currently: |
| 8 | + awx.awx |
5 | 9 |
|
6 |
| -Requirements |
7 |
| ------------- |
| 10 | +## Variables |
| 11 | +|Variable Name|Default Value|Required|Description|Example| |
| 12 | +|:---:|:---:|:---:|:---:|:---:| |
| 13 | +|`tower_hostname`|""|yes|URL to the Ansible Tower Server.|127.0.0.1| |
| 14 | +|`validate_certs`|`False`|no|Whether or not to validate the Ansible Tower Server's SSL certificate.|| |
| 15 | +|`tower_username`|""|yes|Admin User on the Ansible Tower Server.|| |
| 16 | +|`tower_password`|""|yes|Tower Admin User's password on the Ansible Tower Server. This should be stored in an Ansible Vault at vars/tower-secrets.yml or elsewhere and called from a parent playbook.|| |
| 17 | +|`tower_oauthtoken`|""|yes|Tower Admin User's token on the Ansible Tower Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook.|| |
| 18 | +|`tower_license`|`see below`|yes|Data structure describing your license for Tower, described below.|| |
8 | 19 |
|
9 |
| -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. |
| 20 | +### Secure Logging Variables |
| 21 | +The following Variables compliment each other. |
| 22 | +If Both variables are not set, secure logging defaults to false. |
| 23 | +The role defaults to False as normally the add credential input source task does not include sensative information. |
| 24 | +tower_configuration_credential_input_sources_secure_logging defaults to the value of tower_configuration_secure_logging if it is not explicitly called. This allows for secure logging to be toggled for the entire suite of tower configuration roles with a single variable, or for the user to selectively use it. |
10 | 25 |
|
11 |
| -Role Variables |
12 |
| --------------- |
| 26 | +|Variable Name|Default Value|Required|Description| |
| 27 | +|:---:|:---:|:---:|:---:| |
| 28 | +|`tower_configuration_license_secure_logging`|`False`|no|Whether or not to include the sensative license role tasks in the log. Set this value to `True` if you will be providing your sensitive values from elsewhere.| |
| 29 | +|`tower_configuration_secure_logging`|`False`|no|This variable enables secure logging as well, but is shared accross multiple roles, see above.| |
13 | 30 |
|
14 |
| -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. |
| 31 | +## Data Structure |
| 32 | +### Varibles |
| 33 | +|Variable Name|Default Value|Required|Type|Description| |
| 34 | +|:---:|:---:|:---:|:---:|:---:| |
| 35 | +|`data`|""|yes|obj|The contents of the license file (Suggested usage with lookup plugin)| |
| 36 | +|`eula_accepted`|""|yes|bool|Whether to accept the End User License Agreement for Ansible Tower| |
15 | 37 |
|
16 |
| -Dependencies |
17 |
| ------------- |
| 38 | +For further details on fields see https://docs.ansible.com/ansible-tower/latest/html/userguide/credential_plugins.html |
18 | 39 |
|
19 |
| -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. |
| 40 | +### Standard Project Data Structure |
| 41 | +#### Json Example |
| 42 | +```json |
| 43 | +--- |
| 44 | +{ |
| 45 | + "tower_license": { |
| 46 | + "data": "{{ lookup('file', '/tmp/my_tower.license') }}", |
| 47 | + "eula_accepted": true |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | +#### Yaml Example |
| 52 | +```yaml |
| 53 | +--- |
| 54 | +tower_credential_input_sources: |
| 55 | + data: "{{ lookup('file', '/tmp/my_tower.license') }}" |
| 56 | + eula_accepted: true |
| 57 | +``` |
20 | 58 |
|
21 |
| -Example Playbook |
22 |
| ----------------- |
| 59 | +## Playbook Examples |
| 60 | +### Standard Role Usage |
| 61 | +```yaml |
| 62 | +--- |
| 63 | +- name: Add License to Tower |
| 64 | + hosts: localhost |
| 65 | + gather_facts: false |
| 66 | + connection: local |
23 | 67 |
|
24 |
| -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: |
| 68 | + # Bring in vaulted Ansible Tower secrets |
| 69 | + vars_files: |
| 70 | + - "../var/tower-secrets.yml" |
25 | 71 |
|
26 |
| - - hosts: servers |
27 |
| - roles: |
28 |
| - - { role: username.rolename, x: 42 } |
| 72 | + tasks: |
29 | 73 |
|
30 |
| -License |
31 |
| -------- |
| 74 | + - name: Get token for use during play |
| 75 | + uri: |
| 76 | + url: "https://{{ tower_hostname }}/api/v2/tokens/" |
| 77 | + method: POST |
| 78 | + user: "{{ tower_username }}" |
| 79 | + password: "{{ tower_passname }}" |
| 80 | + force_basic_auth: true |
| 81 | + status_code: 201 |
| 82 | + validate_certs: false |
| 83 | + register: user_token |
| 84 | + no_log: true |
32 | 85 |
|
33 |
| -BSD |
| 86 | + - name: Set Tower oath Token |
| 87 | + set_fact: |
| 88 | + tower_oauthtoken: "{{ user_token.json.token }}" |
34 | 89 |
|
35 |
| -Author Information |
36 |
| ------------------- |
| 90 | + - name: Import vars |
| 91 | + include_vars: |
| 92 | + file: "vars/extra_vars.yml" |
37 | 93 |
|
38 |
| -An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
| 94 | + - name: Import JSON |
| 95 | + include_vars: |
| 96 | + file: "json/license.json" |
| 97 | + name: "license_json" |
| 98 | + |
| 99 | + - name: Add License |
| 100 | + include_role: |
| 101 | + name: redhat_cop.tower_configuration.license |
| 102 | + vars: |
| 103 | + tower_credential_input_sources: "{{ license_json.tower_license }}" |
| 104 | +``` |
| 105 | +## License |
| 106 | +[MIT](LICENSE) |
| 107 | +
|
| 108 | +## Author |
| 109 | +[Tom Page](https://github.com/Tompage1994) |
0 commit comments