Skip to content

Add Jenkins pipeline for builder reimage#2602

Open
jitendrasahu1803 wants to merge 9 commits into
mainfrom
builder-reimage-final
Open

Add Jenkins pipeline for builder reimage#2602
jitendrasahu1803 wants to merge 9 commits into
mainfrom
builder-reimage-final

Conversation

@jitendrasahu1803
Copy link
Copy Markdown
Contributor

Introduces Jenkins pipeline for builder reimage and post-reimage configuration.

  • Uses inventory-driven OS detection from jenkins_builders.yml
  • Integrates MaaS reimage workflow
  • Runs Ansible playbooks for node setup
  • Supports multiple nodes with parallel execution

Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Comment thread builder-reimage/build/ansible_runner.sh Outdated
Comment on lines +21 to +22
ANSIBLE_DIR="${WORK_DIR}/repos/ansible"
MAIN_DIR="${WORK_DIR}/repos/main"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment above each of these saying what they're for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

SSH_USER="cloud-user"
else
SSH_USER="ubuntu"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why this is necessary. MaaS is supposed to take care of creating the cm user (https://github.com/ceph/ceph-cm-ansible/blob/main/roles/maas/tasks/config_maas.yml#L90) with these keys: https://github.com/ceph/ceph-sepia-secrets/blob/main/ansible/inventory/group_vars/all.yml#L40. And I see jenkins-build@soko04 has a pubkey in there.

We should be SSHing as the cm user.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was informed that this should be the first command executed after reimage:

ansible-playbook ansible_managed.yml --limit="<all builders>" -e "ansible_ssh_user=ubuntu/cloud-user"

However, when I try running it using the 'cm' user (instead of 'ubuntu/cloud-user') immediately after the MaaS reimage, I encounter the following error:

❯ ansible-playbook ansible_managed.yml --limit="braggi16.front.sepia.ceph.com" -e "ansible_ssh_user=cm"

PLAY [all] **************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************************************************************************************************
[WARNING]: Host 'braggi16.front.sepia.ceph.com' is using the discovered Python interpreter at '/usr/bin/python3.12', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.20/reference_appendices/interpreter_discovery.html for more information.
ok: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Create the sudo group.] *************************************************************************************************************************************************************************************************
ok: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Create the ansible user.] ***********************************************************************************************************************************************************************************************
[ERROR]: Task failed: Module failed: usermod: user cm is currently used by process 2279

Origin: /Users/jitendra/git/ceph/ceph-cm-ansible/roles/ansible-managed/tasks/main.yml:9:3

7    - user
8
9 - name: Create the ansible user.
    ^ column 3

fatal: [braggi16.front.sepia.ceph.com]: FAILED! => {"changed": false, "msg": "usermod: user cm is currently used by process 2279\n", "name": "cm", "rc": 8}

PLAY RECAP **************************************************************************************************************************************************************************************************************************************
braggi16.front.sepia.ceph.com : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

On the other hand, the same playbook works successfully when executed with the 'ubuntu' user:

❯ ansible-playbook ansible_managed.yml --limit="braggi16.front.sepia.ceph.com" -e "ansible_ssh_user=ubuntu"

PLAY [all] **************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************************************************************************************************
[WARNING]: Host 'braggi16.front.sepia.ceph.com' is using the discovered Python interpreter at '/usr/bin/python3.12', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.20/reference_appendices/interpreter_discovery.html for more information.
ok: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Create the sudo group.] *************************************************************************************************************************************************************************************************
ok: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Create the ansible user.] ***********************************************************************************************************************************************************************************************
changed: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Delete the ansible users password.] *************************************************************************************************************************************************************************************
changed: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Ensure includedir is present in sudoers.] *******************************************************************************************************************************************************************************
changed: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Create the cephlab_sudo sudoers.d file.] ********************************************************************************************************************************************************************************
changed: [braggi16.front.sepia.ceph.com]

TASK [ansible-managed : Add authorized keys for the ansible user.] ******************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Importing 'to_native' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.
changed: [braggi16.front.sepia.ceph.com]

PLAY RECAP **************************************************************************************************************************************************************************************************************************************
braggi16.front.sepia.ceph.com : ok=7    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit takes care of that. What branch of ceph-cm-ansible is being used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, Thank you for pointing this out. It uses main branch only, but the snippet I shared was tested from my old local branch. If needed, I'm happy to update my script to explicitly use the cm user. Please let me know how you would like it configured, and I will make the changes accordingly.

Comment on lines +70 to +87
# Admin user JSON builder
ADMIN_USERS=(
"akraitma"
"dgalloway"
"dmick"
"falcocer"
"jitendra"
"zack"
)

build_admin_users_json() {
local json='{"managed_admin_users":['
for u in "${ADMIN_USERS[@]}"; do
json+="{\"name\":\"${u}\"},"
done
json="${json%,}]}"
echo "${json}"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +4 to +11
# -----------------------------------------------------------------------------
# Script Name: bootstrap_env.sh
# Description:
# Bootstraps the local Python environment for running the MAAS reimage script.
# - Installs MAAS CLI (Linux/macOS)
# - Creates Python virtual environment
# - Installs dependencies
# -----------------------------------------------------------------------------
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great

Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
@@ -0,0 +1,27 @@
import yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a shebang. If that's important. Please add a comment at the top showing usage and input/output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

sync_labels.py: file is removed as it's not being used

Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Signed-off-by: jitendrasahu1803 <jitendra.sahu1803@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants