doc/researchAnsible: added section to clone a git repository

AWX uses separate ssh keys to access the host. The host itself uses
its own ssh keys to access bitbucket. The added section shows a way
how to handle such a condition.

Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmüller 2023-06-13 11:52:58 +02:00
parent 262c560f38
commit 1960187318
1 changed files with 72 additions and 3 deletions

View File

@ -833,13 +833,81 @@ For the moment there are some points to not doing this with ansible:
Thus I added the public key manually to my user for further tests.
Job to Clone a Git Repository (e.g. NWL CI repo)
***************************************************
The job template is named ``Clone CI Repo`` and added similar as the other templates.
.. note::
Unfortunately there is an issue with the network configuration and routing of the virtual machine. Thus, I switch
the host to the server that HAC created once for the CoreOS CI work. The server holds the IP *10.115.101.101*.
This server has docker already configured as required. Hence, I just copied manually the created SSH keypairs from
the virtual machine to this server. With those SSH keypairs the AWX instance is able to connect to the server over
SSH and the playbook is able to clone the intended git repository residing on Bitbucket.
As we use a different SSH key for the git repository access, we use the AWX vault and ssh-agent to satisfy our needs.
Accordingly we load the SSH key and clone the repository as follows:
.. code-block:: bash
# preparation of the SSH_ASKPASS script:
echo '#!/bin/bash' > {{ ssh_auto_sshadd_file }}
echo 'echo $SSH_PASS' >> {{ ssh_auto_sshadd_file }}
chmod +x {{ ssh_auto_sshadd_file }}
# then the load command using the vault to decrypt the ssh_passphrase variable:
SSH_PASS={{ssh_passphrase}} DISPLAY=1 SSH_ASKPASS="{{ssh_auto_sshadd_file}}" ssh-add {{ssh_keyfile}} < /dev/null
# finally the git clone, checkout and update commands:
git clone ssh://git@bitbucket.gad.local:7999/nm-nsp/nwl-ci.git {{git_repo_path}}
cd {{git_repo_path}}
git checkout develop
git fetch -ap
git pull
Launching this playbook we get the following output on the AWX instance:
.. code-block:: bash
Enter passphrase for /runner/artifacts/233/ssh_key_data:
Identity added: /runner/artifacts/233/ssh_key_data (awxclient@testenv)
Vault password (nwl-vault):
PLAY [Clone a Git Repository] **************************************************
TASK [Check if auto-sshadd file exists] ****************************************
ok: [10.115.101.101]
TASK [Prepare auto ssh-add file] ***********************************************
changed: [10.115.101.101]
TASK [Clone and Update Repository] *********************************************
changed: [10.115.101.101]
PLAY RECAP *********************************************************************
10.115.101.101 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
A check on the server shows that the repository is cloned correctly. **Hooray**
Now we have the base where we can build a docker image on a host, so let's move to the next section...
Job to Build a Docker Image
***************************
text comes here ;-P
Local Setup of Marc (look-ups)
Look-ups for Marc
##############################
Network with VM and my personal Gateway
***************************************
This is a `link to keep in mind <https://community.ibm.com/community/user/ibmz-and-linuxone/blogs/asif-mahmud1/2020/03/15/cloning-private-git-repository-using-ansible>`_
Local Network with VM and my personal Gateway
*********************************************
My gateway changes the address range from time to time. But for my getting started work I want a setup with static IPs.
Thus, I created a bridge over a virtual interface:
@ -874,6 +942,7 @@ Thus, I created a bridge over a virtual interface:
section
########
subsection