bootstrap and ping playbooks for new ansible

This commit is contained in:
2021-12-22 10:09:00 -05:00
parent d8ed170ecc
commit ebae058a0b
9 changed files with 89 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
---
- name: bootstrap
hosts: all
remote_user: richard
gather_facts: false
# become: true
pre_tasks:
# - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
- setup: # aka gather_facts
- name: Creates .ssh directory
file: path=~/.ssh state=directory mode=700
# - name: remove ubuntu user if it exists
# command: userdel -rf ubuntu
# args:
# removes: /home/ubuntu/.bashrc
- debug: var=ansible_os_family
run_once: true
- debug: var=ansible_architecture
run_once: true
tasks:
- name: ping
ansible.builtin.ping:
- name: Add the user 'ansible'
become: true
ansible.builtin.user:
name: ansible
state: present
shell: /bin/bash
create_home: yes
password: "$6$7z7PfYwduXom0o73$DEiy3K15URNNjmKkOQIwx8/mFKArUNYkFn8D/4q6t/eP9hf1X9jnG4YuSjI7q1Dnp1HwukZUxZY7cF2JK5DO/."
uid: "1001"
groups:
- sudo
# generate_ssh_key: yes
# ssh_keys:
# - "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAmJSdmj03d4fnZUuRByevPDNiReEk1fRL+7F9WPCo5zn+r5Oj84HXxd4P03DNXeGSBYmUAnsTqYEGdkjkpSrKfMm9bv8amL7hUC+Mzb+wOmXmyX1cw/SearYCBQRCz1s5p7I9+PO7XWaC0VJ99LUm1Bp4JM149U5X0Y3M2j2XV+0= RSA-1024"
- name: Add the authorized key for 'ansible'
become: true
ansible.posix.authorized_key:
user: ansible
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAmJSdmj03d4fnZUuRByevPDNiReEk1fRL+7F9WPCo5zn+r5Oj84HXxd4P03DNXeGSBYmUAnsTqYEGdkjkpSrKfMm9bv8amL7hUC+Mzb+wOmXmyX1cw/SearYCBQRCz1s5p7I9+PO7XWaC0VJ99LUm1Bp4JM149U5X0Y3M2j2XV+0= RSA-1024"
# key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"

View File

@@ -0,0 +1,8 @@
---
- name: ping
hosts: all
gather_facts: false
tasks:
- name: ping
ansible.builtin.ping: