Hi,
I need help,
I’m having problems to call functions defined in the pipeline.
Names of function : ansib_ssh_config, ansib_launch.
This is log from the cicd job which run the pipeline :
$ mkdir -p ~/.ssh
30$ export PATH=$PATH:${InstallUpdateVtom}:${InstallUpdateVtom}/cicd
31$ ansib_ssh_config ${InstallUpdateVtom}/hosts.yml
32/scripts-4420-2091604/step_script: line 166: ansib_ssh_config: command not found
33Cleaning up project directory and file based variables
GITLAB version :
GitLab Enterprise Edition 14.9.2-ee
.gitlab-ci.yml file :
variables:
GIT_SSL_NO_VERIFY: “true”
DOCKER_HOST: tcp://localhost:2375
DIND_IMAGE_VERSION: “0.0.3”
stages:
- package_VTOM
- rece
- pack
- prod
include:
- ‘/UpgradeAgentVtom/cicd/InstallVtomAgents.yml’
- ‘/UpgradeAgentVtom/cicd/IntegrationNexusPkg.yml’
InstallVtomAgents.yml file called by .gitlab-ci.yml
Client Rece:
stage: rece
image: $CI_REGISTRY_VTOM_DEPLOIEMENT:10.9.5
script:
- ansib_ssh_config ${InstallUpdateVtom}/hosts.yml
- ansib_launch
tags:
- valentine-ipp1
when: manual
only:
variables:
- $envi == “rece”
Client Pack:
stage: pack
image: $CI_REGISTRY_VTOM_DEPLOIEMENT:10.9.5
script:
- export PATH=$PATH:${InstallUpdateVtom}:${InstallUpdateVtom}/cicd
- ansib_ssh_config ${InstallUpdateVtom}/hosts.yml
- cat ${InstallUpdateVtom}/cicd/InstallVtomAgents.yml
- ansib_launch
tags:
- valentine-ipp1
when: manual
only:
variables:
- $envi == “pack”
Client Prod:
stage: prod
image: $CI_REGISTRY_VTOM_DEPLOIEMENT:10.9.5
script:
- ansib_ssh_config ${InstallUpdateVtom}/hosts.yml
- ansib_launch
tags:
- valentine-sgp
when: manual
only:
variables:
- $envi == “prod”
.function: &function |
function ansib_ssh_config() {
echo “BUG 1”
hosts=$1
echo “BUG 2”
eval $(ssh-agent -s)
echo “BUG 3”
#SSH_PRIVATE_OPERATION=echo "$SSH_PRIVATE_OPERATION" | tr -d '\r'
#ssh-add <(echo “$SSH_PRIVATE_OPERATION”)
echo “$SSH_PRIVATE_OPERATION” | tr -d ‘\r’ | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo “ENV - $envi”
echo “PRESENCE HOSTS YML :”
echo “CI_PROJECT_DIR - $CI_PROJECT_DIR”
ls -lrt $hosts
grep “.phys.[r,p]” $hosts > ${InstallUpdateVtom}/agents.txt
sed -e ‘s/ //g’ -e “s/.$//” ${InstallUpdateVtom}/agents.txt > ${InstallUpdateVtom}/agents.tmp
mv ${InstallUpdateVtom}/agents.tmp ${InstallUpdateVtom}/agents.txt
for serveur in cat ${InstallUpdateVtom}/agents.txt
do
ssh-keyscan $serveur >> ~/.ssh/known_hosts
done
chmod 644 ~/.ssh/known_hosts
}
I tried integrating directly commands without functions and this works !
Thank you
regards