Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Obtener el pid de un libro de jugadas en ejecución para usar dentro del libro de jugadas

Cuando ejecutamos un libro de jugadas, con la salida detallada habilitada, en los registros de ansible podemos ver algo como esto:

2016-02-03 12:51:58,235 p=4105 u=root | PLAY RECAP

Supongo que p=4105 es el pid del libro de jugadas cuando se ejecutó.

¿Hay alguna manera de obtener este pid dentro del libro de jugadas durante su tiempo de ejecución (como una variable, por ejemplo)?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede definir el PID para localhost utilizando el módulo set_fact con un filtro de lookup .

 - hosts: localhost tasks: - set_fact: pid: "{{ lookup('pipe', 'echo $PPID') }}"

Y más adelante puede hacer referencia al PID a través del diccionario hostvars .

 - hosts: remote tasks: - debug: var=hostvars.localhost.pid
over 4 years ago · Santiago Trujillo Report

0

Esto suena un poco como un problema XY , pero una opción puede ser generar un shell con el comando shell y luego solicitar el PID principal:

 - name: get pid of playbook shell: | echo "$PPID" register: playbook_pid

Esto le dará el PID del proceso de python que está ejecutando el libro de jugadas.

over 4 years ago · Santiago Trujillo Report

0

Esto podría ser lo que está buscando, pero solo se aplica a Linux:

 - name: Get the pid of this playbook shell: pstree -spal $PPID | grep ansible-playbook | awk '{print $1;exit}' | awk -F, '{print $2}' register: ansible_pid - name: Set the ansible playbook pid variable set_fact: ansible_playbook_pid: "{{ ansible_pid.stdout|int }}"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!