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

5
ansible-5/ansible.cfg Normal file
View File

@@ -0,0 +1,5 @@
# local ansible config file
[defaults]
inventory = ./inventory.ini
remote_user = ansible
roles_path = ./roles

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
venvironment='venv'
sudo apt install -y python-is-python3 python3-pip python3-argcomplete
sudo apt install -y python-is-python3 python3-pip python3-argcomplete sshpass
python -m pip install --user virtualenv
python -m virtualenv ${venvironment}

1
ansible-5/cli/play/.help Normal file
View File

@@ -0,0 +1 @@
TODO: Add help for this directory

3
ansible-5/cli/play/bootstrap Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
ansible-playbook playbooks/bootstrap.yaml -i inventory.ini --ask-pass --ask-become-pass

View File

@@ -0,0 +1,3 @@
ARGS - The arguments you wish to provide to this command
TODO: Fill out the help information for this command.

View File

@@ -0,0 +1 @@
ARGS...

17
ansible-5/inventory.ini Normal file
View File

@@ -0,0 +1,17 @@
localhost ansible_connection=local
[managed]
home ansible_ssh_host=192.168.4.11
cubox-i ansible_ssh_host=192.168.4.12
[ns]
home ansible_ssh_host=192.168.4.22
cubox-i ansible_ssh_host=192.168.4.12
[gfs]
home ansible_ssh_host=192.168.4.11
cubox-i ansible_ssh_host=192.168.4.12
;[desktop]
;richard-desktop ansible_connection=local

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: