Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: Playbook run in ansible core but not semaphore #2721

Open
tuanama00 opened this issue Jan 29, 2025 · 1 comment
Open

Problem: Playbook run in ansible core but not semaphore #2721

tuanama00 opened this issue Jan 29, 2025 · 1 comment
Assignees
Milestone

Comments

@tuanama00
Copy link

Issue

I have playbook run with no problem in ansible-core, remote server which is applied playbook no have python ,

Playbook run ansible-core server .... Ok
Playbook run semaphore docker ..... fail

both use same playbook

remote server no have python installed

Impact

Ansible (task execution)

Installation method

Docker

Database

Postgres

Browser

Safari

Semaphore Version

v2.11.3-e67b00f-1737964259

Ansible Version

ansible [core 2.18.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/semaphore/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/semaphore/apps/ansible/11.1.0/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/semaphore/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/semaphore/apps/ansible/11.1.0/venv/bin/ansible
  python version = 3.11.11 (main, Dec  6 2024, 11:15:21) [GCC 13.2.1 20231014] (/opt/semaphore/apps/ansible/11.1.0/venv/bin/python3)
  jinja version = 3.1.5
  libyaml = True

Logs & errors

ansible.log

here find ansible-core log and semaphore log for same playbook

Manual installation - system information

No response

Configuration

services:
semaphore_db:
image: postgres
container_name: semaphore_postgresl
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: semaphore
volumes:
- postgresql:/var/lib/postgresql/data
networks:
- semaphore_network
semaphore:
container_name: semaphore_pro
ports:
- 3000:3000
image: public.ecr.aws/semaphore/pro/server:v2.11.3
environment:
SEMAPHORE_DB_DIALECT: postgres
SEMAPHORE_DB_HOST: semaphore_db
SEMAPHORE_DB_NAME: semaphore
SEMAPHORE_DB_USER: root
SEMAPHORE_DB_PASS: root
SEMAPHORE_ADMIN: jaraujo
SEMAPHORE_ADMIN_PASSWORD: 2328Ef-547
SEMAPHORE_ADMIN_NAME: admin
SEMAPHORE_ADMIN_EMAIL: [email protected]
# SEMAPHORE_PORT: 3000
SEMAPHORE_GIT_CLIENT: cmd_git
# SEMAPHORE_COOKIE_HASH: xn_CzqGCLa_vFoYX
# SEMAPHORE_COOKIE_ENCRYPTION: gtTHfuVuaQ5tErLR
# SEMAPHORE_ACCESS_KEY_ENCRYPTION: AMY30foZNbgSIfT3
volumes:
- data:/var/lib/semaphore
- config:/etc/semaphore
- temp:/tmp/semaphore
networks:
- semaphore_network
volumes:
data:
config:
temp:
postgresql:
networks:
semaphore_network: {driver: "bridge"}

Additional information

playbook:

  • name: Upgrade kernel on remote hosts
    hosts: all
    vars:
    kernel_version: "4.18.0-553.34.1.el8_10.x86_64"
    kernel_path: "/home/jaraujo/Ansible/files/kernel"
    kernel_files:
    - "kernel-core-4.18.0-553.34.1.el8_10.x86_64.rpm"
    - "kernel-modules-4.18.0-553.34.1.el8_10.x86_64.rpm"

    tasks:

    • name: Gather facts
      ansible.builtin.setup:

    • name: Check current kernel version
      command: uname -r
      register: current_kernel

    • name: Show current kernel version
      debug:
      msg: "Current kernel version: {{ current_kernel.stdout }}"

    • name: Skip kernel update if the kernel is already updated
      debug:
      msg: "Kernel is already updated to version {{ kernel_version }}. Skipping tasks."
      when: current_kernel.stdout == kernel_version

    • name: Verify kernel RPM files exist on the local machine
      stat:
      path: "{{ kernel_path }}/{{ item }}"
      with_items: "{{ kernel_files }}"
      register: kernel_files_status
      when: current_kernel.stdout != kernel_version

    • name: Transfer kernel RPM files to remote hosts
      copy:
      src: "{{ kernel_path }}/{{ item }}"
      dest: "/tmp/{{ item }}"
      mode: '0644'
      loop: "{{ kernel_files }}"
      when: current_kernel.stdout != kernel_version

    • name: Install the new kernel RPMs
      command: yum localinstall -y /tmp/{{ item }}
      loop: "{{ kernel_files }}"
      when: current_kernel.stdout != kernel_version

    • name: Verify kernel-core package installation
      command: rpm -q kernel-core
      register: kernel_core_installed
      failed_when: "'kernel-core' not in kernel_core_installed.stdout"
      when: current_kernel.stdout != kernel_version

    • name: Regenerate initramfs for the new kernel
      command: dracut --force /boot/initramfs-{{ kernel_version }}.img {{ kernel_version }}
      when: current_kernel.stdout != kernel_version

    • name: Set the new kernel as the default
      command: grubby --set-default=/boot/vmlinuz-{{ kernel_version }}
      when: current_kernel.stdout != kernel_version

    • name: Reboot the system to apply the kernel update
      reboot:
      reboot_timeout: 720
      test_command: uname -r
      when: current_kernel.stdout != kernel_version

    • name: Confirm that the kernel has been updated
      command: uname -r
      register: updated_kernel
      changed_when: false
      when: current_kernel.stdout != kernel_version

    • name: Show updated kernel version
      debug:
      msg: "Updated kernel version: {{ updated_kernel.stdout }}"

@fiftin
Copy link
Collaborator

fiftin commented Feb 3, 2025

Hi @tuanama00 did you try to disable gathering facts?

- hosts: sites
  gather_facts: no

https://forum.ansible.com/t/can-i-gather-facts-without-python-on-remote-systems/18051

@fiftin fiftin added this to the 2.12 milestone Feb 3, 2025
@fiftin fiftin self-assigned this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants