Ondřej Ezr
2020-03-11 79b829fe8df1b087365841eaddcadd1e9e9932d6
Satellite lifecycle role using foreman-ansible-modules (#1303)

1 files deleted
1 files added
2 files modified
127 ■■■■■ changed files
ansible/roles/satellite-manage-lifecycle/README.adoc 75 ●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-lifecycle/tasks/main.yml 6 ●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-lifecycle/tasks/version_6.4.yml 29 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-lifecycle/tasks/version_6.x.yml 17 ●●●●● patch | view | raw | blame | history
ansible/roles/satellite-manage-lifecycle/README.adoc
@@ -3,19 +3,18 @@
:tag1: configure_satellite
:tag2: configure_satellite_lifecycle
:main_file: tasks/main.yml
:version_file: tasks/version_6.4.yml
:version_file: tasks/version_6.7.yml
Role: {role}
============
This role creates lifecycle environment path.
This role creates lifecycle environment path.
Requirements
------------
. Satellite must be install and setup.
. Hammer cli config must be configured/updated with privileged user and password to run the satellite cli.
. Satellite must be install and setup.
Role Variables
--------------
@@ -23,11 +22,11 @@
|===
|satellite_version: "Digit" |Required |satellite version
|org: "String" |Required |Organization name
|org_label: "String" |Not-required | Organization label in string without space
|org_description: "String" |Not-required | Organization description
|org_label: "String" |Optional | Organization label in string without space
|org_description: "String" |Optional | Organization description
|lifecycle_environment_path: [List] |Required | Contains nested list with dictinary keys and values
|name: "String" |Required |Name of environment
|label: "String" |Required |label of environment
|label: "String" |Required |label of environment
|descritpion: "String" |Required |Description for environment
|prior_env: "String" |Required |Name of the prior environment
@@ -37,23 +36,23 @@
[source=text]
----
satellite_version: 6.4
satellite_version: 6.7
org: "gpte"
org_label: "gpte"
org_description: "Global Partner Training and Enablement"
lifecycle_environment_path:
    - name: "Dev"
      label: "dev"
      description: "Development Environment"
      prior_env: "Library"
    - name: "QA"
      label: "qa"
      description: "Quality Environment"
      prior_env: "Dev"
    - name: "Prod"
      label: "prod"
      description: "Production Enviornment"
      prior_env: "QA"
  - name: "Development"
    label: "dev"
    description: "Development Environment"
    prior_env: "Library"
  - name: "Staging"
    label: "qa"
    description: "Quality Environment"
    prior_env: "Development"
  - name: "Production"
    label: "prod"
    description: "Production Enviornment"
    prior_env: "Staging"
----
Tags
@@ -69,10 +68,10 @@
[source=text]
----
## Tagged jobs
ansible-playbook playbook.yml --tags configure_satellite
ansible-playbook playbook.yml --tags configure_satellite,configure_satellite_lifecycle
## Skip tagged jobs
ansible-playbook playbook.yml --skip-tags configure_satellite
ansible-playbook playbook.yml --skip-tags configure_satellite_lifecycle
----
@@ -85,30 +84,30 @@
[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"
lifecycle_environment_path:
    - name: "Dev"
      label: "dev"
      description: "Development Environment"
      prior_env: "Library"
    - name: "QA"
      label: "qa"
      description: "Quality Environment"
      prior_env: "Dev"
    - name: "Prod"
      label: "prod"
      description: "Production Enviornment"
      prior_env: "QA"
  - name: "Development"
    label: "dev"
    description: "Development Environment"
    prior_env: "Library"
  - name: "Staging"
    label: "qa"
    description: "Quality Environment"
    prior_env: "Development"
  - name: "Production"
    label: "prod"
    description: "Production Enviornment"
    prior_env: "Staging"
[user@desktop ~]$ cat playbook.yml
- hosts: satellite.example.com
  vars_files:
    - sample_vars.yml
  roles:
    - satellite-manage-organization
    - satellite-manage-organization
[user@desktop ~]$ ansible-playbook playbook.yml
----
@@ -116,9 +115,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
To extend role works for other version, if needed 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] and link:{version_file}[version_6.4.yml]
for reference look at link:{main_file[main.yml] and link:{version_file}[version_6.x.yml]
Author Information
ansible/roles/satellite-manage-lifecycle/tasks/main.yml
@@ -1,8 +1,8 @@
---
## 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 >= 6.4
  tags:
    - configure_satellite
    - configure_satellite_lifecycle
    - configure_satellite_lifecycle
ansible/roles/satellite-manage-lifecycle/tasks/version_6.4.yml
File was deleted
ansible/roles/satellite-manage-lifecycle/tasks/version_6.x.yml
New file
@@ -0,0 +1,17 @@
---
- name: "Add lifecycle environments"
  theforeman.foreman.katello_lifecycle_environment:
    username: "{{ satellite_admin }}"
    password: "{{ satellite_admin_password }}"
    server_url: "https://{{ publicname }}"
    validate_certs: no
    name: "{{ item.name }}"
    label: "{{ item.label }}"
    organization: "{{ org }}"
    prior: "{{ item.prior_env }}"
    description: "{{ item.description }}"
    state: "present"
  with_items: "{{ lifecycle_environment_path }}"
  tags:
    - configure_satellite
    - configure_satellite_lifecycle