code-dumps/rs/ansible-create-home.sh

36 lines
811 B
Bash
Raw Normal View History

2024-10-24 23:09:21 +08:00
#!/bin/bash
mkdir -p ~/rs-ansible-home/keys
cd ~/rs-ansible-home
cat <<EOF > ansible.cfg
[defaults]
inventory=dyn-inventory.sh
gathering = smart
fact_caching = jsonfile
fact_caching_connection = facts-cache.json
fact_caching_timeout = 3600
host_key_checking = False
become = true
log_path = ansible.log
stdout_callback = full_skip
forks=10
retry_files_enabled = False
command_warnings = False
pipelining = True
interpreter_python = auto_silent
vault_password_file = keys/.vault-pass
EOF
cat <<EOF > dyn-inventory.sh
#!/bin/bash
/opt/usefulscripts/ht/bin/ht-6.6.0 --core-account \$COREACCOUNT --quiet ansible
EOF
chmod 755 dyn-inventory.sh
openssl rand -base64 32 > ~/rs-ansible-home/keys/.vault-pass
cat <<EOF > example-usage.md
# Run ansible through hammertime
COREACCOUNT=123456 ansible -m ping linux
EOF