---
|
- name: Fetching list of names available in Content-Views
|
shell: >-
|
hammer --output cve
|
content-view list
|
--organization "{{ORG}}" | grep Name
|
register: content_view_list
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
- name: Creating list fact of names available in Content-Views
|
set_fact:
|
content_view_exist: "{{ content_view_exist + [item.split(':')[1].lstrip(' ')]}}"
|
loop: "{{content_view_list.stdout_lines}}"
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
- name: Print fact
|
debug: var=content_view_exist
|
|
- name: Creating Content-view if not exist
|
command: >-
|
hammer content-view create
|
--name "{{CONTENT_VIEW_NAME}}"
|
--organization "{{ORG}}"
|
when: CONTENT_VIEW_NAME not in content_view_exist
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
#######################################
|
|
- name: Fetching list of enabled Repo IDs from subscription
|
shell: >-
|
hammer --output cve
|
repository list
|
--organization "{{ORG}}" |grep Id
|
ignore_errors: yes
|
register: repo_list
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
- name: Creating list fact of enabled Repo IDs from subscription
|
set_fact:
|
sub_repos_name_exist: "{{ sub_repos_name_exist + [ item.split(':')[1].lstrip(' ')] }}"
|
loop: "{{repo_list.stdout_lines}}"
|
when: repo_list is defined
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
# - name: list of enabled repo ID in subscription
|
# debug: var=sub_repos_name_exist
|
######################################
|
|
- name: Fetching list of existing Repository IDs from Content-View
|
shell: >-
|
hammer --output cve
|
content-view list
|
--organization "{{ORG}}"
|
--name "{{CONTENT_VIEW_NAME}}" |grep "Repository IDs"
|
ignore_errors: yes
|
register: content_view_repos_list
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
- name: Creating list fact of existing Repository IDs from Content-View
|
set_fact:
|
content_view_repos_exist: "{{ content_view_repos_exist + [item.lstrip(' ')]}}"
|
loop: "{{ content_view_repos_list.stdout_lines[0].split(':')[1].split(',') }}"
|
when: content_view_repos_list is defined
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
# - name: list existing repos in content view
|
# debug: var=content_view_repos_exist
|
|
- name: adding repo to content-view
|
command: >-
|
hammer content-view add-repository
|
--organization "{{ORG}}"
|
--name "{{CONTENT_VIEW_NAME}}"
|
--repository-id "{{ item }}"
|
when: item not in content_view_repos_exist
|
loop: "{{ sub_repos_name_exist }}"
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
#######################
|
- name: Fetching list of published versions of Content-View
|
shell: >-
|
hammer --output cve
|
content-view version list
|
--organization "{{ORG}}"
|
--content-view "{{CONTENT_VIEW_NAME}}" |grep Version
|
ignore_errors: yes
|
register: published_versions
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
- name: Creating facts list of published versions of Content-View
|
set_fact:
|
published_content_view_versions: "{{ published_content_view_versions + [ item.split(':')[1].strip(' ') | int ] }}"
|
loop: "{{ published_versions.stdout_lines }} "
|
when: published_versions is defined
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|
|
|
- name: Publishing content-view
|
command: >-
|
hammer content-view publish
|
--organization "{{ORG}}"
|
--name "{{CONTENT_VIEW_NAME}}"
|
--async
|
when: published_content_view_versions | length == 0
|
tags:
|
- configure_satellite
|
- configure_satellite_content_view
|