Skip to content

Commit

Permalink
added new role to build for dev spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
adworjan committed Dec 1, 2023
1 parent f421af3 commit 0c4d2de
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .ansible-sign/sha256sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ e7282f4ae9f746f2f962f83e8362230b5796e3cecd1b7d7320a9cb024eb4c0d9 roles/build_sh
dfc5b5bd8bca161bb5eb0070a57368a51aabe34f27a1265ce3b7051ea3fa0268 roles/build_shadowmande/templates/execution-environment.yml.j2
6f273601ee34e1968ff8708287f00723f16152ced76b9494d4d2bf312a5ead80 roles/build_shadowmande/templates/requirements.txt.j2
f46e5f6f46cb53820c812cec1a28a59825476c846d13f65fda8dde4105087f3a roles/build_shadowmande/templates/requirements.yml.j2
bb79735d36584fceef8e28f77a85cb19d7bec94f71c0c834348f088293a1af53 roles/build_shadowmandevspaces/defaults/main.yml
b3e28a736267063aab070e2bbd0d38da5d889d9ea16844968395e54f62b2ae4f roles/build_shadowmandevspaces/tasks/main.yml
e78d092fe7df758f58cada57dfd2c97fadcc8dfbdc85f94db62c7b2742c3e5f7 roles/build_shadowmandevspaces/templates/.bashrc.j2
9ba220badf4c14eb524d3ddcec9474e329147c880e50c14d5899367178613e33 roles/build_shadowmandevspaces/templates/ansible.cfg.j2
17850229c3d90fd93f419d4a9f32b267207c52d5c1e5fceaf4a8470d8852945f roles/build_shadowmandevspaces/templates/bindep.txt.j2
dfc5b5bd8bca161bb5eb0070a57368a51aabe34f27a1265ce3b7051ea3fa0268 roles/build_shadowmandevspaces/templates/execution-environment.yml.j2
6f273601ee34e1968ff8708287f00723f16152ced76b9494d4d2bf312a5ead80 roles/build_shadowmandevspaces/templates/requirements.txt.j2
f46e5f6f46cb53820c812cec1a28a59825476c846d13f65fda8dde4105087f3a roles/build_shadowmandevspaces/templates/requirements.yml.j2
d819e57a6d12fd03b6a6efaac051889db057daf9d4fb1fde06e414c50ca6f69c roles/build_shadowmandevspaces/templates/shells.j2
2adf1aec14431be9889dfbed1b02225922bc7279c3e3aa940b5267dda717907c roles/build_shadowmanee/defaults/main.yml
2e3b21325488ff21a2e32fe9820e59089fd0f79df537373537db8ef03a40ec26 roles/build_shadowmanee/tasks/main.yml
9ba220badf4c14eb524d3ddcec9474e329147c880e50c14d5899367178613e33 roles/build_shadowmanee/templates/ansible.cfg.j2
Expand Down
22 changes: 11 additions & 11 deletions .ansible-sign/sha256sum.txt.sig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-----BEGIN PGP SIGNATURE-----

iQGzBAABCAAdFiEE/bJvyFHKKJdaZDOLTiIiIXrUDNEFAmVNRfgACgkQTiIiIXrU
DNFGcwv9E27tPzmZ4somALbAjJ86sSOnDBu0IQHdXt3ZU4Ye2Ea02kTrUigKE17q
hjqG33X6vfiJmoXA/64Q/YQzvtYoYPcN4NoTviJGkVmhF5Q6zis/m2p2B09mWCD4
RHHrTj4wAT/8puMXeqIeFagi6bDYZnW7Bx5vDLkVVQew8cg2UNKf55S/FSzmGMzt
f8UfUAwJEpuwQWb/HFNi/yP/9IDfRbR7JMhZhXOcNZ352epTYrzMUWG5GFklziTI
eA8g2CeFTJb2z+am6viHP5D2QQtKU9LyojVhk+9f0YyUkEsD5BTpBiR0ZfZHbbAS
TrOgBWSHkSFdDMjyyubTOQmu9AExEdDx+c3rW6lpNZC/KsuP6MbbWmJ2X4oXWZDC
jkZ7xIcTo5XQlxONA2NZHAEfYgr7NOdDSRFr4HWaDIQ8vx7GdhLXWkGU8Leo40wu
q4zn3u3CaDKpboqWF9sfvEzyGXoL6pWlSPdy6U4rGFd1qC5SdrZuo8NZeVzVN0B2
cC2OsWVG
=wS52
iQGzBAABCAAdFiEE/bJvyFHKKJdaZDOLTiIiIXrUDNEFAmVqCc4ACgkQTiIiIXrU
DNFHBgwArCxo9FM4VSLHk2RYQ+R0AfvSsLqmx9lhSurCErHQ6NTNp2bQjIkc8na5
ee5ZmyqVz9Uso+B/sNei7q7RbB7xTaU02Z5trbTJ9sXbTqlcab/U/svInvScrQCL
CNecgAv8hNfn2Mc6yx4KKNCuyf4/kErP1EKuUrVwvMIrpyl9RFNEnz8EcEx9qxAP
cRWNucHsRRu1CQrxuIZf2EsE5AsL1NSgYuMWMBFfLmoCot0FzGakUTG+a1C2n1Cg
nRtrvozbLLD9a1rbvVWtahHybGuz+BCVHbtLGndxNSHH0s5iGFAHDXSwC+tPuSXH
knVOBulIU7Fg3xG6TvLuTI/mEEMN0qR+U2r65TSlUXAnG8h11CC2oMYEljZrNMGh
iB3b1UFFG6OOHg3Le06RjJdVFSoSSTW9ylGrDIpiSJsAnp3lWwWoT3LQ/jehsr22
fVGJ10O0yM/0Y+UCDomv7FRODb51JgI+t+l9iGda0WklHAA23NuQEuekQGkm/oJr
IgUeStCS
=N8pD
-----END PGP SIGNATURE-----
89 changes: 89 additions & 0 deletions roles/build_shadowmandevspaces/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
ee_version: 3
dest_dir: /home/adworjan/ansible/builder/shadowmaneedev/
pah_name: towerpah.shadowman.dev
image_name: shadowmaneedev
bindep_file: bindep.txt
python_requirements_file: requirements.txt
galaxy_requirements_file: requirements.yml
ee_base_image: towerpah.shadowman.dev/ansible-automation-platform/ee-minimal-rhel8:2.15
ee_base_sig_name: registry.redhat.io/ansible-automation-platform/ee-minimal-rhel8:2.15
galaxy_keyring: /home/adworjan/ansible/builder/shadowmanee/fullkeyring.kbx
ee_package_manager_path: /usr/bin/microdnf
ee_build_files:
- src: /home/adworjan/ansible/builder/shadowmaneedev/ansible.cfg
dest: configs
- src: /home/adworjan/ansible/builder/shadowmaneedev/.bashrc
dest: configs
- src: /home/adworjan/ansible/builder/shadowmaneedev/shells
dest: configs
ee_bindep:
- python3-jinja2 [platform:rpm]
- which [platform:rpm]
- git [platform:rpm]
- libcurl-devel [platform:rpm]
- gcc [platform:rpm]
- python39-devel [platform:rpm]
- openssl-devel [platform:rpm]
- libxml2-devel [platform:rpm]
- libxslt-devel [platform:rpm]
ee_python:
- scp
- pyats
- genie
- python-jenkins
- pan-os-python==1.8.0
- pan-python==0.17.0
- panos-upgrade-assurance==0.3.0
ee_collections:
- name: ansible.windows
- name: community.windows
- name: microsoft.ad
- name: ansible.posix
- name: vmware.vmware_rest
version: 1.0.1
- name: ansible.netcommon
- name: ansible.utils
- name: community.crypto
- name: community.general
- name: community.vmware
- name: cloud.terraform
- name: servicenow.itsm
- name: vyos.vyos
- name: cisco.ios
- name: arista.eos
- name: infra.osbuild
- name: azure.azcollection
- name: f5networks.f5_modules
- name: citrix.adc
- name: shadowman.reports
- name: redhat.rhv
- name: redhat.satellite
- name: redhat.insights
- name: ansible.controller
- name: paloaltonetworks.panos
- name: ibm.qradar
- name: containers.podman
- name: community.postgresql
- name: redhat.openshift
ee_prepend_galaxy:
- ADD _build/configs/ansible.cfg /etc/ansible/ansible.cfg
ee_prepend_builder:
- ENV PKGMGR_OPTS "--nodocs --setopt install_weak_deps=0 --enablerepo=rhocp-4.13-for-rhel-8-x86_64-rpms"
ee_prepend_final:
- ENV PKGMGR_OPTS "--nodocs --setopt install_weak_deps=0 --enablerepo=rhocp-4.13-for-rhel-8-x86_64-rpms"
ee_append_final:
- RUN microdnf install -y yum-utils
- RUN dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
- RUN dnf install -y terraform
- RUN microdnf reinstall tzdata -y
- RUN git clone -b citrix.adc --single-branch https://github.com/netscaler/ansible-collection-netscaleradc.git /tmp/citrix
- RUN pip3 install /tmp/citrix/deps/nitro-python-1.0_kamet.tar.gz
- RUN rm -rf /tmp/citrix/
- RUN rm -f /etc/ansible/ansible.cfg
- RUN microdnf clean all
- RUN dnf clean all
- COPY _build/configs/shells /etc/shells
- COPY _build/configs/.bashrc /home/runner/.bashrc
- RUN printf "export CONTAINER_NAME=ansibleee\n" >> /home/runner/.bashrc
- RUN for dir in /home/runner /home/runner/.ansible /home/runner/.ansible/tmp /runner /home/runner /runner/env /runner/inventory /runner/project /runner/artifacts ; do mkdir -m 0775 -p $dir ; chmod -R g+rwx $dir ; chgrp -R root $dir ; done && for file in /home/runner/.ansible/galaxy_token /etc/passwd /etc/group ; do touch $file ; chmod g+rw $file ; chgrp root $file ; done

Check failure on line 89 in roles/build_shadowmandevspaces/defaults/main.yml

View workflow job for this annotation

GitHub Actions / build

yaml[line-length]

Line too long (376 > 160 characters)
83 changes: 83 additions & 0 deletions roles/build_shadowmandevspaces/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
- name: Pull builder images
containers.podman.podman_image:
name: "{{ item }}"
username: "{{ pah_user }}"
password: "{{ pah_pass }}"
force: true
loop:
- "{{ ee_base_image }}"
# - "{{ ee_builder_image }}"
when: ee_version == 1 or ee_version == 3

- name: Login to PAH
containers.podman.podman_login:
username: "{{ pah_user }}"
password: "{{ pah_pass }}"
registry: "{{ pah_name }}"
when: ee_version == 2

- name: Delete old EE
containers.podman.podman_image:
name: "{{ pah_name }}/{{ image_name }}"
state: absent
force: true

- name: Template out builder files
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "{{ dest_dir }}{{ item }}"
owner: root
group: root
mode: '0644'
loop:
- ansible.cfg
- bindep.txt
- execution-environment.yml
- requirements.txt
- requirements.yml
- shells
- .bashrc

- name: Build new EE on version 1 or 3 without signature verification
ansible.builtin.command:
cmd: 'ansible-builder build -t {{ pah_name }}/{{ image_name }} --prune-images --galaxy-keyring={{ galaxy_keyring }}'
chdir: "{{ dest_dir }}"
changed_when: true
when: ee_version == 1 or ee_version == 3

- name: Build new EE with container signature verification on version 2
ansible.builtin.command:
cmd: 'ansible-builder build -t {{ pah_name }}/{{ image_name }} --prune-images --galaxy-keyring={{ galaxy_keyring }} --container-policy=system'
chdir: "{{ dest_dir }}"
changed_when: true
when: ee_version == 2

- name: Create new tag on EE based on date time of creation
containers.podman.podman_tag:
image: "{{ pah_name }}/{{ image_name }}"
target_names:
- "{{ pah_name }}/{{ image_name }}:{{ ansible_date_time.iso8601_basic_short }}"

- name: Push new EE
containers.podman.podman_image:
name: "{{ pah_name }}/{{ image_name }}"
tag: "{{ item }}"
push: true
username: "{{ pah_user }}"
password: "{{ pah_pass }}"
loop:
- "{{ ansible_date_time.iso8601_basic_short }}"
- latest

- name: Remove extra tag
containers.podman.podman_image:
name: "{{ pah_name }}/{{ image_name }}"
tag: "{{ ansible_date_time.iso8601_basic_short }}"
state: absent

- name: Update Execution Environment Version in Controller with new version
ansible.controller.execution_environment:
name: "Automation Hub Shadowman execution environment"
image: "{{ pah_name }}/{{ image_name }}:{{ ansible_date_time.iso8601_basic_short }}"
delegate_to: localhost
11 changes: 11 additions & 0 deletions roles/build_shadowmandevspaces/templates/.bashrc.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
PROMPT_COMMAND=__prompt_command

__prompt_command() {
local RC="$?"
RC_MSG=""
if [ "$RC" != 0 ]; then
RC_MSG="\[$(tput sgr0)\]\[\033[38;5;9m\]$RC\[$(tput sgr0)\]"
fi
PS1="\[\033[38;5;56m\]\u\[$(tput sgr0)\]\[\033[38;5;8m\]@\[$(tput sgr0)\]\[\033[38;5;130m\]${CONTAINER_NAME}\[$(tput sgr0)\]: \[$(tput sgr0)\]\[\033[38;5;25m\]\w\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;28m\]\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\[$(tput sgr0)\]$RC_MSG\n\\$ \[$(tput sgr0)\]"
}
19 changes: 19 additions & 0 deletions roles/build_shadowmandevspaces/templates/ansible.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[galaxy]
server_list = automation_hub_cert,automation_hub_pub,automation_hub_comm,automation_hub_val
ignore_certs = yes

[galaxy_server.automation_hub_cert]
url={{ lookup('env', 'AH_HOST') }}api/galaxy/content/rh-certified/
token={{ lookup('env', 'AH_API_TOKEN') }}

[galaxy_server.automation_hub_pub]
url={{ lookup('env', 'AH_HOST') }}api/galaxy/content/published/
token={{ lookup('env', 'AH_API_TOKEN') }}

[galaxy_server.automation_hub_comm]
url={{ lookup('env', 'AH_HOST') }}api/galaxy/content/community/
token={{ lookup('env', 'AH_API_TOKEN') }}

[galaxy_server.automation_hub_val]
url={{ lookup('env', 'AH_HOST') }}api/galaxy/content/validated/
token={{ lookup('env', 'AH_API_TOKEN') }}
7 changes: 7 additions & 0 deletions roles/build_shadowmandevspaces/templates/bindep.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if ee_bindep is defined %}
{% if ee_bindep|length %}
{% for item in ee_bindep %}
{{ item }}
{% endfor %}
{% endif %}
{% endif %}
Loading

0 comments on commit 0c4d2de

Please sign in to comment.