Writing
Rubys String#split-Methode in Ansible Playbooks
Dateinamen ohne Pfad in Ansible Playbooks mit String#split extrahieren.
Table of Contents
Heute gelernt:
Rubys String#split-Methode in Ansible Playbooks
In Ansible Playbooks kann man Rubys String#split-Methode verwenden, um Dateinamen ohne Dateipfad zu extrahieren:
---
- hosts: DEVSRV
become: yes
tasks:
- name: symlink deploy_config scripts
file:
src: "{{ item }}"
dest: "/usr/local/bin/{{ item.split('/') | last }}"
state: link
loop:
- "/home/foo/bar/deploy/config/dev_deploy_config.sh"
- "/home/foo/bar/deploy/config/int_deploy_config.sh"
- "/home/foo/bar/deploy/config/prod_deploy_config.sh"