Hy i am using ansible with AWX on a K3S cluster and i have some issues, when creating the .ssh directory. Gives me evrythime the error that access is denied or that it cant write to it.
i have tried with privilege access but that does not seems to work either.
What i want to become is that an ssh key that is present in the awx that this is passed to the execution node, so i can backup my swithc config using git.
this should be posible i have seen this here , but i seem to miss somthing …
I have create the custom ssh credential type and linked it to the playbook with the switch credentials
does anyone have some ideas ?
- name: Create .ssh folder
become: true
run_once: true
delegate_to: localhost
ansible.builtin.file:
path: /root/.ssh
state: directory
mode: '0777'
register: create_result
- name: create the ssh key file based on the supplied cred
become: true
run_once: true
delegate_to: localhost
ansible.builtin.copy:
dest: ~/.ssh/id_rsa
content: "{{ cert_key }}"
mode: '0600'
{
"module_stdout": "",
"module_stderr": "Traceback (most recent call last):\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 107, in <module>\n _ansiballz_main()\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible.modules.file', init_globals=dict(_module_fqn='ansible.modules.file', _modlib_path=modlib_path),\n File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 987, in <module>\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 973, in main\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 680, in ensure_directory\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 1181, in set_fs_attributes_if_different\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 941, in set_mode_if_different\nPermissionError: [Errno 1] Operation not permitted: b'/root/.ssh'\n",
"exception": "Traceback (most recent call last):\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 107, in <module>\n _ansiballz_main()\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/runner/.ansible/tmp/ansible-tmp-1724254291.0380187-30-217917007745715/AnsiballZ_file.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible.modules.file', init_globals=dict(_module_fqn='ansible.modules.file', _modlib_path=modlib_path),\n File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 987, in <module>\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 973, in main\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 680, in ensure_directory\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 1181, in set_fs_attributes_if_different\n File \"/tmp/ansible_ansible.builtin.file_payload_8vcma2lk/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 941, in set_mode_if_different\nPermissionError: [Errno 1] Operation not permitted: b'/root/.ssh'\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1,
"_ansible_no_log": false,
"changed": false,
"_ansible_delegated_vars": {
"ansible_host": "localhost",
"ansible_port": null,
"ansible_user": "root",
"ansible_connection": "local"
}
}