Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elreydetoda/8f8e60506756a47e468bf461fe72073d to your computer and use it in GitHub Desktop.
Save elreydetoda/8f8e60506756a47e468bf461fe72073d to your computer and use it in GitHub Desktop.
pulp_default_admin_password: password
pulp_install_source: pip
pulp_settings:
secret_key: secret
content_origin: "https://{{ inventory_hostname }}"
x_pulp_api_host: 127.0.0.1
x_pulp_api_port: 24817
x_pulp_api_user: "admin"
x_pulp_api_password: "{{ pulp_default_admin_password }}"
x_pulp_api_prefix: "pulp_ansible/galaxy/automation-hub/api"
galaxy_require_content_approval: "False"
pulp_token_auth_disabled: "True"
galaxy_api_default_distribution_base_path: "published"
pulp_install_plugins:
pulp-ansible: {}
galaxy-ng: {}
pulp-container: {}
pulp_api_workers: 4
galaxy_importer_settings: {}
---
- hosts: all
roles:
- pulp.pulp_installer.pulp_all_services
environment:
DJANGO_SETTINGS_MODULE: pulpcore.app.settings
pre_tasks:
- name: Install RHEL7 redis
set_fact:
pulp_redis_package_name: 'rh-redis5'
pulp_redis_server_name: 'rh-redis5-redis'
pulp_redis_conf_file: '/etc/opt/rh/rh-redis5/redis.conf'
when: ansible_distribution_major_version == '7'
- hosts: all
tasks:
- name: Clean OpenAPI cache
file:
path: "{{ lookup('env', 'XDG_CACHE_HOME') | default('~/.cache') }}/squeezer"
state: absent
- name: Get services
service_facts:
- name: Restart all pulpcore* services
systemd:
daemon_reload: true
name: "{{ item.value.name }}"
state: restarted
when: "item.value.name != '[email protected]'"
with_dict: '{{ ansible_facts.services|dict2items|selectattr("key", "contains", "pulpcore")|list|items2dict }}'
become: true
---
- hosts: all
roles:
- ansible.galaxy_collection.post_install_config
pre_tasks:
- name: Reload systemd
systemd:
daemon_reload: true
become: true
- name: Restart all pulpcore* services
command: systemctl restart pulpcore*
become: true
- name: Clean OpenAPI cache
file:
path: "{{ lookup('env', 'XDG_CACHE_HOME') | default('~/.cache') }}/squeezer"
state: absent
# Options
pulp_devel_supplement_bashrc: true
pulp_default_admin_password: password
pulp_api_workers: 4
pulp_settings:
secret_key: "unsafe_default"
content_origin: "http://{{ ansible_fqdn }}"
x_pulp_api_host: 127.0.0.1
x_pulp_api_port: 24817
x_pulp_api_user: "admin"
x_pulp_api_password: "{{ pulp_default_admin_password }}"
x_pulp_api_prefix: "pulp_ansible/galaxy/automation-hub/api"
galaxy_require_content_approval: "False"
pulp_token_auth_disabled: "True"
galaxy_api_default_distribution_base_path: "published"
pulp_install_plugins:
pulp-ansible:
source_dir: "/home/vagrant/devel/pulp_ansible"
galaxy-ng:
source_dir: "/home/vagrant/devel/galaxy_ng"
pulp-container:
source_dir: "/home/vagrant/devel/pulp_container"
# Vagrant source install Required
pulp_user: "vagrant"
developer_user: "vagrant"
developer_user_home: "/home/vagrant"
pulp_source_dir: "/home/vagrant/devel/pulpcore"
---
- hosts: all
vars:
galaxy_api_url: http://localhost:5001/api/automation-hub/
galaxy_username: admin
galaxy_password: password
galaxy_namespace:
name: "newswangerd"
description: "Example collections"
galaxy_collection_path: newswangerd-collection_demo-1.0.10.tar.gz
tasks:
- name: Authenticate and get an API token
uri:
url: "{{ galaxy_api_url }}v3/auth/token/"
method: POST
url_username: "{{ galaxy_username }}"
url_password: "{{ galaxy_password }}"
force_basic_auth: yes
status_code: 200
body_format: json
return_content: yes
register: galaxy_auth_response
- set_fact:
galaxy_token: "{{ galaxy_auth_response['json']['token'] }}"
- set_fact:
galaxy_auth_header: "Token {{ galaxy_token }}"
- name: Check if the namespace exists
uri:
url: "{{galaxy_api_url}}v3/namespaces/{{ galaxy_namespace.name }}/"
method: GET
headers:
Authorization: "{{ galaxy_auth_header }}"
register: galaxy_namespace_check
ignore_errors: yes
- name: Create a namespace
uri:
url: "{{galaxy_api_url}}v3/namespaces/"
method: POST
headers:
Authorization: "{{ galaxy_auth_header }}"
body_format: json
body:
name: "{{ galaxy_namespace.name }}"
description: "{{ galaxy_namespace.description }}"
groups:
- name: "system:partner-engineers"
return_content: yes
status_code: 201
register: galaxy_namespace_response
when: galaxy_namespace_check.status == 404
- debug:
var: galaxy_namespace_response
- name: create ansible.cfg
copy:
dest: ansible.cfg
content: |
[galaxy]
server_list = local_server
[galaxy_server.local_server]
url={{ galaxy_api_url }}
token={{ galaxy_token }}
- name: publish a collection with ansible-galaxy
shell:
cmd: ANSIBLE_CONFIG=./ansible.cfg ansible-galaxy collection publish -v {{ galaxy_collection_path }}
pulp_default_admin_password: password
pulp_settings:
secret_key: secret
content_origin: "https://{{ inventory_hostname }}"
x_pulp_api_host: 127.0.0.1
x_pulp_api_port: 24817
x_pulp_api_user: "admin"
x_pulp_api_password: "{{ pulp_default_admin_password }}"
x_pulp_api_prefix: "pulp_ansible/galaxy/automation-hub/api"
galaxy_require_content_approval: "False"
pulp_token_auth_disabled: "True"
galaxy_api_default_distribution_base_path: "published"
pulp_pkg_repo: 'https://yum.theforeman.org/pulpcore/3.15/el{{ ansible_distribution_major_version }}/x86_64'
pulp_install_source: packages
pulp_install_plugins:
pulp-ansible: {}
galaxy-ng: {}
pulp-container: {}
pulp_api_workers: 4
galaxy_importer_settings: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment