We use AAP to deploy roles. The roles are in Git. I now have 2 roles that need to deploy the same files and templates, and of course I don’t want to keep 2 versions in Git. How could I solve that?

  • @vegetaaaaaaa
    link
    English
    1
    edit-2
    1 year ago

    Symlinks are the simplest solution (just checked, it works)

    $ tree test-role*
    test-role1
    ├── tasks
    │  └── main.yml
    └── templates
        └── template1.j2
    test-role2
    ├── tasks
    │ └── main.yml
    └── templates
        └── template1.j2 -> ../../test-role1/templates/template1.j2
    
    $  cat test-role1/tasks/main.yml 
    - name: copy template
      tags: test-role1
      become: yes
      template:
        src: template1.j2
        dest: /root/template1
    
    $ cat test-role2/tasks/main.yml 
    - name: copy template
      tags: test-role2
      become: yes
      template:
        src: template1.j2
        dest: /root/template1
    
    $ ansible-playbook playbook.yml --diff --check --tags test-role2
    ...
    TASK [test-role2 : copy template] *****************
    --- before
    +++ after: /home/deploy/.ansible/tmp/ansible-local-143602q8imzfz/tmp8g6dn_h1/template1.j2
    @@ -0,0 +1 @@
    +this is a template