26 lines
790 B
YAML
26 lines
790 B
YAML
---
|
|
- name: Simple Non-Root Playbook
|
|
hosts: localhost
|
|
gather_facts: false
|
|
tasks:
|
|
- name: 1. Check who is running the playbook
|
|
ansible.builtin.command: whoami
|
|
register: user_check
|
|
|
|
- name: 2. Print the username to the console
|
|
ansible.builtin.debug:
|
|
msg: "This playbook is running as user {{ user_check.stdout }}"
|
|
|
|
- name: 3. Create a test file in the home directory
|
|
ansible.builtin.copy:
|
|
content: "Hello, this file was created using Ansible without sudo!"
|
|
dest: "~/ansible_test_file.txt"
|
|
|
|
- name: 4. Verify the file contents
|
|
ansible.builtin.command: cat ~/ansible_test_file.txt
|
|
register: file_output
|
|
|
|
- name: 5. Display the file output
|
|
ansible.builtin.debug:
|
|
msg: "{{ file_output.stdout }}"
|