zengxyz / rpms / anaconda

Forked from rpms/anaconda 4 months ago
Clone
Radek Vykydal 147131
---
Radek Vykydal 147131
# Check if remote_user is reachable by ansible and set ansible.cfg
Radek Vykydal 147131
# if so.
Radek Vykydal 147131
Radek Vykydal 147131
- hosts: gating_test_runner
Radek Vykydal 147131
  become: True
Radek Vykydal 147131
  gather_facts: False
Radek Vykydal 147131
  remote_user: "{{ remote_user }}"
Radek Vykydal 147131
Radek Vykydal 147131
  tasks:
Radek Vykydal 147131
  - name: Try a raw command as a check
Radek Vykydal 147131
    raw: echo "CHECK OK"
Radek Vykydal 147131
    register: result
Radek Vykydal 147131
Radek Vykydal 147131
  - debug:
Radek Vykydal 147131
      msg: "{{ result }}"
Radek Vykydal 147131
Radek Vykydal 147131
  - name: Set ansible.cfg remote user to "{{ remote_user }}"
Radek Vykydal 147131
    become: no
Radek Vykydal 147131
    local_action:
Radek Vykydal 147131
      module: lineinfile
Radek Vykydal 147131
      path: ./remote_config/ansible.cfg
Radek Vykydal 147131
      regexp: ^remote_user
Radek Vykydal 147131
      line: "remote_user = {{ remote_user }}"
Radek Vykydal 147131
    when: result.stdout_lines[0] == "CHECK OK"