From 25afb47edce429925a635cb31af83d44a872377d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Tue, 29 Oct 2024 10:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20playbook.yml=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=AF=B9=20~/.bash=5Faliases=20=E7=9A=84?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=80=A7=E6=A3=80=E6=9F=A5=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20dps=20=E5=88=AB=E5=90=8D=E7=9A=84=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playbook.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/playbook.yml b/playbook.yml index 1bcb49b..9d032d9 100644 --- a/playbook.yml +++ b/playbook.yml @@ -12,19 +12,15 @@ autoremove: true # 这会删除不再需要的软件包,相当于运行 sudo apt-get autoremove。 autoclean: true # 这会删除所有已下载的软件包,但仍保留软件包的索引文件,相当于运行 sudo apt-get autoclean。 - - name: Ensure ~/.bash_aliases exists - file: - path: ~/.bash_aliases - state: touch - - - name: Check if alias dps is defined - shell: grep 'alias dps=' ~/.bash_aliases - register: alias_check - ignore_errors: true # 忽略错误,以便在未找到时继续执行 + # - name: Check if alias dps is defined + # shell: grep 'alias dps=' ~/.bash_aliases + # register: alias_check + # ignore_errors: true # 忽略错误,以便在未找到时继续执行 - name: Add alias dps to ~/.bash_aliases if not defined - lineinfile: + lineinfile: # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html path: ~/.bash_aliases - line: "alias dps=\"docker ps --format 'table {{.ID}}\\t{{.Names}}'\"" + line: "alias dps=\"docker ps --format 'table {{ '{{' }}.ID{{ '}}' }}\\t{{ '{{' }}.Names{{ '}}' }}'\"" state: present - when: alias_check.rc != 0 # 只有在未找到时执行 (checks if the alias is not already defined) \ No newline at end of file + create: true + # when: alias_check.rc != 0 # 只有在未找到时执行 (checks if the alias is not already defined) \ No newline at end of file