Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use bootstrap.py for registrations #58

Merged
merged 2 commits into from
Sep 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 29 additions & 72 deletions playbooks/satellite/roles/client-scripts/files/clients.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
remote_user: root
gather_facts: no
vars:
{% if client_reg_server is defined %}server: {{ client_reg_server }}{% endif %}

bootstrap_foreman_fqdn: {% raw %}{{ server }}{% endraw %}
bootstrap_download_method: http
bootstrap_org: "Default_Organization"
#when not passing username/password, org has to be the label, otherwise the name:
#bootstrap_org: "Default Organization"
bootstrap_location: "World"
bootstrap_activationkey: "ActivationKey"
bootstrap_login: ""
bootstrap_password: ""
bootstrap_hostgroup: "HostGroup"
bootstrap_additional_args: "--force"
bootstrap_target_path: /root/bootstrap.py

marker: "{% raw %}{{ marker }}{% endraw %}"

recorder_server: "{{ recorder_server }}"
Expand Down Expand Up @@ -67,29 +82,10 @@
tags:
- REG
- FIXREG
- name: "Clean subscription-manager stuff"
shell:
subscription-manager clean
tags: REG
- name: "Remove katello-ca-consumer package"
shell: |
if rpm -qa | grep katello-ca-consumer; then
yum --disablerepo=\* -y remove katello-ca-consumer-\*
fi
tags: REG
- name: "Remove other repos which might be broken"
shell:
rm -f /etc/yum.repos.d/*.repo
tags: REG
- name: "Install katello-ca-consumer"
action:
shell
rpm -Uvh "http://{% raw %}{{ server }}{% endraw %}/pub/katello-ca-consumer-latest.noarch.rpm"
register: installed
until: "installed.rc is defined and installed.rc == 0"
retries: 10
delay: 10
tags: REG
- name: Increase the RHSM timeout
lineinfile:
dest: /usr/lib64/python2.7/site-packages/rhsm/config.py
Expand All @@ -102,9 +98,20 @@
# Start registering with RHSM and attach to the
# pool
#################################################
- name: "Register"
shell:
subscription-manager register --org Default_Organization --environment Library --username admin --password changeme --force
- name: download bootstrap.py from {{ bootstrap_foreman_fqdn }}
get_url:
dest: "{% raw %}{{ bootstrap_target_path }}{% endraw %}"
url: "{% raw %}{{ bootstrap_download_method }}://{{ bootstrap_foreman_fqdn }}/pub/bootstrap.py{% endraw %}"
tags: REG

- name: generate bootstrap.py arguments
set_fact:
bootstrap_args: "{% raw %}--server {{ bootstrap_foreman_fqdn }} --organization '{{ bootstrap_org }}' --location '{{ bootstrap_location }}' --activationkey '{{ bootstrap_activationkey }}' --download-method {{ bootstrap_download_method }}{% endraw %}"
bootstrap_foreman_args: "{% raw %}{% if bootstrap_password != '' %}--login '{{ bootstrap_login }}' --password '{{ bootstrap_password }}' --hostgroup '{{ bootstrap_hostgroup }}'{% else %}--skip foreman{% endif %}{% endraw %}"
tags: REG

- name: run bootstrap.py
command: "{% raw %}python {{ bootstrap_target_path }} {{ bootstrap_args }} {{ bootstrap_foreman_args }} {{ bootstrap_additional_args }}{% endraw %}"
register: reg
until: "reg.rc is defined and reg.rc == 0"
retries: 50
Expand All @@ -114,56 +121,6 @@
debug:
msg="Register {% raw %}{{ reg.start }}{% endraw %} to {% raw %}{{ reg.end }}{% endraw %}"
tags: REG
- name: "Determine RHEL pool ID"
command:
subscription-manager list --available --all --matches "{{ content_rhel_name }}" --pool-only
register: pool_id_rhel
until: "pool_id_rhel.rc is defined and pool_id_rhel.rc == 0"
retries: 10
delay: 10
run_once: yes
tags: REG
- name: "Determine Satellite Tools pool ID"
command:
subscription-manager list --available --all --matches "{{ content_sattools_name }}" --pool-only
register: pool_id_tools
until: "pool_id_tools.rc is defined and pool_id_tools.rc == 0"
retries: 10
delay: 10
run_once: yes
tags: REG
- name: "Attach to RHEL product"
shell:
subscription-manager attach --pool "{% raw %}{{ pool_id_rhel.stdout }}{% endraw %}"
register: att_rhel
until: "att_rhel.rc is defined and att_rhel.rc == 0"
retries: 10
delay: 10
tags: REG
#- name: "Attach to RHEL product - timings"
# debug:
# msg="AttachRHEL {% raw %}{{ att.start }}{% endraw %} to {% raw %}{{ att.end }}{% endraw %}"
# tags: REG
- name: "Attach to 6.2 Tools custom product"
shell:
subscription-manager attach --pool "{% raw %}{{ pool_id_tools.stdout }}{% endraw %}"
register: att_tools
until: "att_tools.rc is defined and att_tools.rc == 0"
retries: 10
delay: 10
tags: REG
#- name: "Attach to 6.2 Tools custom product - timings"
# debug:
# msg="AttachTools {% raw %}{{ att.start }}{% endraw %} to {% raw %}{{ att.end }}{% endraw %}"
# tags: REG
- name: "If recorder is defined, upload timings we just measured"
shell: |
curl -X PUT "{% raw %}http://{{ recorder_server }}/Sat6ScaleLabExperiments/1/1/subscription-manager_register/{{ marker|urlencode() }}/$( hostname )/{{ reg.start|urlencode() }}/{{ reg.end|urlencode() }}/{{ reg.rc|urlencode() }}{% endraw %}"
curl -X PUT "{% raw %}http://{{ recorder_server }}/Sat6ScaleLabExperiments/1/1/subscription-manager_attach_RHEL/{{ marker|urlencode() }}/$( hostname )/{{ att_rhel.start|urlencode() }}/{{ att_rhel.end|urlencode() }}/{{ att_rhel.rc|urlencode() }}{% endraw %}"
curl -X PUT "{% raw %}http://{{ recorder_server }}/Sat6ScaleLabExperiments/1/1/subscription-manager_attach_Tools/{{ marker|urlencode() }}/$( hostname )/{{ att_tools.start|urlencode() }}/{{ att_tools.end|urlencode() }}/{{ att_tools.rc|urlencode() }}{% endraw %}"
when: recorder_server != ''
ignore_errors: true
tags: REG

##################################################
# Fix registration if needed
Expand Down