Make playbook more check-mode safe

This commit is contained in:
2022-12-16 19:08:57 +01:00
parent e2ae922a85
commit 2096b3234f

View File

@@ -393,6 +393,7 @@
vars: vars:
firefox_profiles: "{{ {item.key: item.value} | combine({item.key: {'preferences': firefox_preferences}}, recursive=True) }}" firefox_profiles: "{{ {item.key: item.value} | combine({item.key: {'preferences': firefox_preferences}}, recursive=True) }}"
loop: "{{ user.firefox_profiles | dict2items }}" loop: "{{ user.firefox_profiles | dict2items }}"
when: not ansible_check_mode
- name: firefox - create target directory for passff - name: firefox - create target directory for passff
file: file:
@@ -439,6 +440,7 @@
state: directory state: directory
mode: '0755' mode: '0755'
with_items: "{{ firefox_profile_names.results }}" with_items: "{{ firefox_profile_names.results }}"
when: not ansible_check_mode
- name: firefox - configure firefox custom css - name: firefox - configure firefox custom css
copy: copy:
@@ -456,7 +458,9 @@
#sidebar { #sidebar {
width: 400px !important; width: 400px !important;
} }
when: user.firefox_profiles[item.profile_name].manage_css is sameas True when:
- not ansible_check_mode
- user.firefox_profiles[item.profile_name].manage_css is sameas True
with_items: "{{ firefox_profile_names.results }}" with_items: "{{ firefox_profile_names.results }}"
tags: tags:
- firefox - firefox
@@ -556,12 +560,14 @@
file: file:
path: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }} path: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }}
mode: '0755' mode: '0755'
when: not ansible_check_mode
- name: link kubectl - name: link kubectl
file: file:
src: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }} src: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }}
dest: /home/{{ user.name }}/.optbin/kubectl dest: /home/{{ user.name }}/.optbin/kubectl
state: link state: link
when: not ansible_check_mode
tags: tags:
- kubectl - kubectl
@@ -575,42 +581,54 @@
stat: stat:
path: "/home/{{ user.name }}/.opt/terraform-v{{ tf_version }}" path: "/home/{{ user.name }}/.opt/terraform-v{{ tf_version }}"
register: terraform_binary register: terraform_binary
check_mode: false
- name: create temporary download directory for terraform - name: create temporary download directory for terraform
tempfile: tempfile:
state: directory state: directory
register: terraform_download_dir register: terraform_download_dir
when: not terraform_binary.stat.exists when:
- not ansible_check_mode
- not terraform_binary.stat.exists
- name: get terraform - name: get terraform
get_url: get_url:
url: "https://releases.hashicorp.com/terraform/{{ tf_version }}/terraform_{{ tf_version }}_linux_amd64.zip" url: "https://releases.hashicorp.com/terraform/{{ tf_version }}/terraform_{{ tf_version }}_linux_amd64.zip"
dest: "{{ terraform_download_dir.path }}/terraform.zip" dest: "{{ terraform_download_dir.path }}/terraform.zip"
force: false force: false
when: not terraform_binary.stat.exists when:
- not ansible_check_mode
- not terraform_binary.stat.exists
- name: unpack terraform zip - name: unpack terraform zip
unarchive: unarchive:
src: "{{ terraform_download_dir.path }}/terraform.zip" src: "{{ terraform_download_dir.path }}/terraform.zip"
dest: "{{ terraform_download_dir.path }}/" dest: "{{ terraform_download_dir.path }}/"
remote_src: true remote_src: true
when: not terraform_binary.stat.exists when:
- not ansible_check_mode
- not terraform_binary.stat.exists
- name: install terraform - name: install terraform
command: mv "{{ terraform_download_dir.path }}/terraform" /home/{{ user.name }}/.opt/terraform-v{{ tf_version }} command: mv "{{ terraform_download_dir.path }}/terraform" /home/{{ user.name }}/.opt/terraform-v{{ tf_version }}
when: not terraform_binary.stat.exists when:
- not ansible_check_mode
- not terraform_binary.stat.exists
- name: clean up download directory - name: clean up download directory
file: file:
path: "{{ terraform_download_dir.path }}" path: "{{ terraform_download_dir.path }}"
state: absent state: absent
when: not terraform_binary.stat.exists when:
- not ansible_check_mode
- not terraform_binary.stat.exists
- name: link terraform - name: link terraform
file: file:
src: /home/{{ user.name }}/.opt/terraform-v{{ tf_version }} src: /home/{{ user.name }}/.opt/terraform-v{{ tf_version }}
dest: /home/{{ user.name }}/.optbin/terraform dest: /home/{{ user.name }}/.optbin/terraform
state: link state: link
when: not ansible_check_mode
- block: - block:
- name: get terraform version info - name: get terraform version info