Unknown model· unknown
Capybara — Synthetic multi-turn
Can you write me an ansible playbook that distributes a given ssh key to all servers in…
- User
Can you write me an ansible playbook that distributes a given ssh key to all servers in a cluster?
- Assistant
Certainly! Here's an example of an Ansible playbook that distributes a given SSH key to all servers in a cluster:
yaml--- - name: Distribute SSH Key to All Servers in the Cluster hosts: all become: yes gather_facts: yes tasks: - name: Ensure the .ssh directory exists ansible.builtin.file: path: "/home/{{ ansible_user }}/.ssh" state: directory owner: "{{ ansible_user }}" group: "{{ ansible_user }}" mode: 0700 - name: Copy the given SSH key to authorized_keys ansible.builtin.copy: src: /path/to/your/public_ssh_key/id_rsa.pub dest: "/home/{{ ansible_user }}/.ssh/authorized_keys" owner: "{{ ansible_user }}" group: "{{ ansible_user }}" mode: 0600 backup: yes - name: Reload SSH service ansible.builtin.systemd: name: ssh state: reloaded
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.