So Now lets start with building the required execution environment to use the collections which we need to execute our play we will required below collections
1. community.general --> To Generate the Random Password
2. community.hashi_vault --> To interact with the HashiCorp vault
So lets get into the action lets Install the ansible builder don't go for the latest one as you may encounter some issues lets go for the one stable release as of writing the blog the the release version i know id 3.0.1 so i am installing the same
We are installing pip if already not present and then using pip we are installing the ansible builder
# dnf install python3-pip
# pip install ansible-builder==3.0.1
Once the ansible builder is installed lets create some files like
Note: EE stands for execution environment
Create a directory call EE and go to that directory
# mkdir EE and cd EE
create a first file execution-environment.yml and add following content:
cat <<EOT >> execution-environment.yml
---
version: 1
dependencies:
galaxy: requirements.yml
python: requirements.txt
system: bindep.txt
additional_build_steps:
prepend: |
RUN whoami
RUN cat /etc/os-release
append:
- RUN echo This is a post-install command!
- RUN ls -la /etc
EOT
Now lets start create the dependencies which we have specified
cat <<EOT >> requirements.yml
---
collections:
- name: community.general
- name: community.hashi_vault
EOT
We have some dependencies for the collections which will specify in the requirements.txt
cat <<EOT >> requirements.txt
gcp-cli
ncclient
netaddr
paramiko
hvac
EOT
If We have some binary dependencies then specify it bindep.txt
cat <<EOT >> bindep.txt
findutils [compile platform:centos-8 platform:rhel-8]
gcc [compile platform:centos-8 platform:rhel-8]
make [compile platform:centos-8 platform:rhel-8]
python39-devel [compile platform:centos-8 platform:rhel-8]
python39-cffi [platform:centos-8 platform:rhel-8]
python39-cryptography [platform:centos-8 platform:rhel-8]
python39-pycparser [platform:centos-8 platform:rhel-8]
EOT
One we have added everything we will start building the image using command
ansible-builder build -v3 -t custom-ee
Once the image is build we can tag the image
podman tag custom-ee aap2.example.com/custom-ee
podman push aap2.example.com/custom-ee
Once we have done with this
Once we are done with this We can start with the building playbook
No comments:
Post a Comment