Ondřej Ezr
2020-03-16 6b6a7d7b212ba56870049184aa41b2245201ef0a
Satellite activation key using foreman-ansible-modules (#1339)

2 files deleted
1 files added
2 files modified
138 ■■■■ changed files
ansible/roles/satellite-manage-activationkey/README.adoc 42 ●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-activationkey/files/activationkey_script_version_6.4.sh 42 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-activationkey/tasks/main.yml 6 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-activationkey/tasks/version_6.4.yml 31 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-activationkey/tasks/version_6.x.yml 17 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-activationkey/README.adoc
@@ -3,8 +3,7 @@
:tag1: configure_satellite
:tag2: configure_satellite_activationkey
:main_file: tasks/main.yml
:version_file: tasks/version_6.4.yml
:script_file: files/activationkey_script_version_6.4.sh
:version_file: tasks/version_6.x.yml
Role: {role}
============
@@ -16,15 +15,15 @@
Following are the requirements:
. Satellite must be install and setup.
. Hammer cli config must be configured/updated with privileged user and password to run the satellite cli.
. Subscription, Life-cycle, and content-view should be exist.
. Satellite installed and setted up.
. foreman-ansible-modules ansible collection available on satellite hosts
. Subscription, Life-cycle, and content-view should exist.
Role Variables
--------------
* Following are the variable which needs to be defined
* Following are the variable which needs to be defined
|===
|satellite_version: "Digit" |Required |satellite version
@@ -36,24 +35,24 @@
|life_cycle: "String" | Required | Name of life_cycle for activation key
|subscriptions: [List] | Required | List of subscriptions to add in activation key
|===
* Example variables
[source=text]
----
satellite_version: 6.4
satellite_version: 6.7
org: "gpte"
org_label: "gpte"
org_description: "Global Partner Training and Enablement"
satellite_content:
  - name:             "Ansible server"
    life_cycle:       "Prod"
    life_cycle:       "Production"
    content_view:     "Ansible servers content"
    activation_key:   "capsule_server_key"
    subscriptions:
      - "Employee SKU
      - "Employee SKU
  - name:             "Three Tier App"
    life_cycle:       "Dev"
    life_cycle:       "Development"
    content_view:     "Three Tier App"
    activation_key:   "three_tier_app"
    subscriptions:
@@ -87,19 +86,19 @@
[source=text]
----
[user@desktop ~]$ cat sample_vars.yml
satellite_version: 6.4
satellite_version: 6.7
org: "gpte"
org_label: "gpte"
org_description: "Global Partner Training and Enablement"
satellite_content:
  - name:             "Ansible server"
    life_cycle:       "Prod"
    life_cycle:       "Production"
    content_view:     "Ansible servers content"
    activation_key:   "capsule_server_key"
    subscriptions:
      - "Employee SKU
      - "Employee SKU
  - name:             "Three Tier App"
    life_cycle:       "Dev"
    life_cycle:       "Development"
    content_view:     "Three Tier App"
    activation_key:   "three_tier_app"
    subscriptions:
@@ -109,8 +108,11 @@
- hosts: satellite.example.com
  vars_files:
    - sample_vars.yml
  roles:
    - satellite-manage-activationkey
  tasks:
    - include_role:
        name: "{{ item }}"
      with_items:
        - satellite-manage-activationkey
[user@desktop ~]$ ansible-playbook playbook.yml
----
@@ -118,9 +120,9 @@
Tips to update Role
------------------
To extend role works for other version, create new file named  version_{{satellite_version}}.yml and import newly created file in main.yml . Create new script in files directory for activation key action.
To extend role works for other version, if necessary create new file named version_{{satellite_version}}.yml and import newly created file in main.yml .
for reference look at link:{main_file}[main.yml] , link:{version_file}[version_6.4.yml] and link:{script_file}[script]
for reference look at link:{main_file}[main.yml] and link:{version_file}[version_6.x.yml]
Author Information
ansible/roles/satellite-manage-activationkey/files/activationkey_script_version_6.4.sh
File was deleted
ansible/roles/satellite-manage-activationkey/tasks/main.yml
@@ -1,8 +1,6 @@
---
## Import for version satellite 6.4 ##
- import_tasks: version_6.4.yml
  when: satellite_version == 6.4
- import_tasks: version_6.x.yml
  when: satellite_version is version_compare('6.4', '>=')
  tags:
    - configure_satellite
    - configure_satellite_activationkey
ansible/roles/satellite-manage-activationkey/tasks/version_6.4.yml
File was deleted
ansible/roles/satellite-manage-activationkey/tasks/version_6.x.yml
New file
@@ -0,0 +1,17 @@
---
- name: "Create or update activation key"
  theforeman.foreman.katello_activation_key:
    username: "{{ satellite_admin }}"
    password: "{{ satellite_admin_password }}"
    server_url: "https://{{ publicname }}"
    validate_certs: no
    name: "{{ item.activation_key }}"
    organization: "{{ org }}"
    lifecycle_environment: "{{ item.life_cycle }}"
    content_view: "{{ item.content_view }}"
    subscriptions: "{{ item.subscriptions }}"
    auto_attach: yes
  with_items: "{{ satellite_content }}"
  tags:
    - configure_satellite
    - configure_satellite_activationkey