| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | ---- name: pre tasks# ===============  when: "anaconda_state == 'present'"  block:  - name: pre - ensure folders exist    file:      dest: "{{ item }}"      state: directory    with_items:      - "{{ anaconda_installer_dir }}"      - "{{ anaconda_home_dir }}"  - name: pre - ensure installer file exists    get_url:      url: "{{ anaconda_installer_uri }}"      dest: "{{ anaconda_installer_file }}"      force: False      checksum: "md5:{{ anaconda_installer_md5 }}"    register: installer_file  - name: pre - write warning into Anaconda installer dir    copy:      dest: "{{ anaconda_installer_file }}.WARNING.txt"      content: |        Do not touch the file because ansible        may use it to decide if a reinstallation         (uninstall/install) is necessary.  - name: pre - remove installation for a new install    # if the installer file changes, we assume a new version should be installed    # (the Anaconda way recommend a 'conda update' or similar instead of a new    # installation but we won't to that here to keep it simple stupid)    when: installer_file|changed    file:      dest: "{{ anaconda_install_dir }}"      state: absent  rescue:    - fail:        msg: "failed to prepare installation. installer file may be changed. a pre-installed anaconda may be removed."- name: install# =============  when: "anaconda_state == 'present' and (installer_file|changed or anaconda_force_install)"  block:  - name: install - run installer    command: "bash {{ anaconda_installer_file }} -b -p {{ anaconda_install_dir }} {{ anaconda_force_install|ternary('-f', '') }}"    failed_when: false    register: installer_out  - name: install - fail if installer finished unsuccessfully    fail:      msg: "{{ installer_out.stderr }}"    when: "not (('ERROR: File or directory already exists' in installer_out.stderr) or ('installation finished.' in installer_out.stdout))"  rescue:    - fail:        msg: "Installation failed!"- name: post task - set path to anaconda# ===============  when: "anaconda_state == 'present' and anaconda_set_path|bool"  lineinfile:    dest: "{{ item }}"    create: true    state: present    insertafter: EOF    line: 'export PATH="{{ anaconda_install_dir }}/bin:$PATH"'  with_items:    - /etc/bash.bashrc.local    - /etc/ksh.kshrc.local    - /etc/zsh.zshrc.local    - /etc/ash.ashrc.local- name: uninstall# ===============  when: anaconda_state == 'absent'  block:  - name: uninstall - remove Anaconda home dir    file:      dest: "{{ anaconda_home_dir }}"      state: absent  - name: uninstall - remove path to anaconda    lineinfile:      dest: "{{ item }}"      create: true      state: absent      line: 'export PATH="{{ anaconda_install_dir }}/bin:$PATH"'    with_items:      - /etc/bash.bashrc.local      - /etc/ksh.kshrc.local      - /etc/zsh.zshrc.local      - /etc/ash.ashrc.local
 |