Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit e731e539 authored by Freezed's avatar Freezed
Browse files

:sparkles: Add a basic tasks: host_info & whoami

parent 6d3eba74
No related branches found
No related tags found
No related merge requests found
*.retry
inventory
Makefile 0 → 100644
EDITOR = geany
clean:
# Remove files not in source control
find . -type f -name "*.retry" -delete
find . -type f -name "*.orig" -delete
open_all:
${EDITOR} .gitignore inventory Makefile host_info.yml README.md whoami.yml
inventory_generation:
cp inventory.sample inventory && ${EDITOR} inventory
forga Ansible base playbook
===========================
Setup a basic [Debian](https://www.debian.org) (and Ubuntu) config, suitable for server and workstation
💡 Idea
-------
Get info and set basic config for _Debian_ and _Ubuntu_ distrib.
Suitable for server and workstation.
✨ Features
-----------
| playbook | return |
|-----------------------------------|---------------------------------------------------|
| [`host_info.yml`](host_info.yml) | distribution full name & version |
| [`whoami.yml`](whoami.yml) | `ansible_user` & `become_user` (`sudo` method) |
🚀 Quickstart
-------------
1. Setup your `inventory` file from [`inventory.sample`](inventory.sample) :
- `make inventory_generation`
1. Run `host_info` playbook to `<group_foo>` & `<group_bar>` :
- `ansible-playbook host_info.yml -i inventory -e host_list=<group_foo>:<group_bar>`
---
- hosts: "{{ host_list }}"
remote_user: "{{ my_user }}"
tasks:
- name: Host Info
debug:
msg: "{{ ansible_hostname }} ({{ ansible_distribution }} {{ ansible_distribution_release }} v{{ ansible_distribution_version }})"
[physical]
192.168.1.1
192.168.1.11
[virtual]
192.168.1.2
192.168.1.22
[server]
192.168.1.1
192.168.1.2
[workstation]
localhost
192.168.1.11
192.168.1.22
---
- hosts: "{{ host_list }}"
become_method: su
remote_user: root
become_user: "{{ my_user }}"
tasks:
- name: Who is «remote_user»
become: no
ansible.builtin.script:
cmd: /usr/bin/whoami
register: who_is_remote_user
changed_when: 0
- name: Who is «become_user»
become: yes
ansible.builtin.script:
cmd: /usr/bin/whoami
register: who_is_become_user
changed_when: 0
- name: Who is «remote_user»?
ansible.builtin.debug:
msg: "I am «{{ who_is_remote_user.stdout_lines }}»"
- name: Who is «become_user»?
ansible.builtin.debug:
msg: "I am {{ who_is_become_user.stdout_lines | flatten | first }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment