Writing

앤서블 플레이북에서 루비의 String#split 메서드 사용하기

앤서블 플레이북에서 파일 경로 없이 파일 이름만 추출하기.

Table of Contents
  1. 앤서블 플레이북에서 루비의 String#split 메서드 활용

오늘 배운 내용:

앤서블 플레이북에서 루비의 String#split 메서드 활용

앤서블(Ansible) 플레이북에서는 루비의 String#split 메서드를 사용하여 전체 경로 없이 파일 이름만 추출할 수 있습니다:

---
- 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"

Related Posts