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

204
Views
cómo leer todas las líneas de un archivo en ansible playbook

Tengo un archivo llamado packages.txt que contiene una lista de paquetes. Tengo que leer cada línea de ese paquete.txt a través de mi archivo ansible rpm.yml. Aquí está mi código

 - hosts: myhost tasks: - name: RPM Filter theforeman.foreman.content_view_filter: username: "admin" password: "admin" server_url: "myhost" name: "rpm filter" organization: "myorg" content_view: "My content view" filter_type: "rpm" package_name: "{{ item }}" inclusion: True loop: - packages.txt

Mi paquete.txt contiene estos

 open-ssh nginx grafana vim

Cualquier ayuda sería apreciada

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

consulta el complemento de líneas . Por ejemplo

 - debug: var: item loop: "{{ query('lines', 'cat packages.txt') }}"

da (resumido)

 item: open-ssh item: nginx item: grafana item: vim

Ver los detalles sobre el plugin

 shell> ansible-doc -t lookup lines
over 4 years ago · Santiago Trujillo Report

0

Necesitará una tarea adicional para leer el archivo. La forma más sencilla sería cat el archivo y register en una variable. Entonces esta variable se puede utilizar para la siguiente tarea.

Algo como:

 - name: get contents of package.txt command: "cat packages.txt" register: _packages - name: RPM Filter theforeman.foreman.content_view_filter: username: "admin" password: "admin" server_url: "myhost" name: "rpm filter" organization: "myorg" content_view: "My content view" filter_type: "rpm" package_name: "{{ item }}" inclusion: True loop: "{{ _packages.stdout_lines }}"
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!