From 55237f8a58e91556381099df4406477b4188025d Mon Sep 17 00:00:00 2001 From: Tunui Franken Date: Fri, 25 Feb 2022 09:24:25 +0100 Subject: [PATCH] toansible: Use lineinfile for bash rc files --- .../files/{bash_profile => bash_profile.ansible} | 0 roles/bash/files/{bashrc => bashrc.ansible} | 0 roles/bash/tasks/main.yml | 12 +++++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) rename roles/bash/files/{bash_profile => bash_profile.ansible} (100%) rename roles/bash/files/{bashrc => bashrc.ansible} (100%) diff --git a/roles/bash/files/bash_profile b/roles/bash/files/bash_profile.ansible similarity index 100% rename from roles/bash/files/bash_profile rename to roles/bash/files/bash_profile.ansible diff --git a/roles/bash/files/bashrc b/roles/bash/files/bashrc.ansible similarity index 100% rename from roles/bash/files/bashrc rename to roles/bash/files/bashrc.ansible diff --git a/roles/bash/tasks/main.yml b/roles/bash/tasks/main.yml index 47c5eb2..30f2731 100644 --- a/roles/bash/tasks/main.yml +++ b/roles/bash/tasks/main.yml @@ -13,12 +13,18 @@ - bash-completion when: ansible_distribution == 'Debian' -- name: Copy files +- name: Copy rc files copy: src={{ item.src }} dest={{ item.dest }} backup=true with_items: - { src: 'inputrc', dest: '~/.inputrc' } - - { src: 'bash_profile', dest: '~/.bash_profile' } - - { src: 'bashrc', dest: '~/.bashrc' } + - { src: 'bash_profile.ansible', dest: '~/.bash_profile.ansible' } + - { src: 'bashrc.ansible', dest: '~/.bashrc.ansible' } + +- name: Source rc.ansible files + lineinfile: path={{ item.path }} line={{ item.line }} create=true insertbefore=BOF + with_items: + - { path: '~/.bashrc', line: '. "$HOME"/.bashrc.ansible' } + - { path: '~/.bash_profile', line: '. "$HOME"/.bash_profile.ansible' } - name: Clone bash-git-prompt git: