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