Skip to content

Instantly share code, notes, and snippets.

View duffney's full-sized avatar
⌨️
Coding

Josh Duffney duffney

⌨️
Coding
View GitHub Profile
#!/bin/bash
sudo apt-get install python -y
useradd -m -d /home/ansible -s /bin/bash ansible
echo 'ansible:P@ssw0rd'|chpasswd
echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
sudo sed -n 'H;${x;s/\PasswordAuthentication no/PasswordAuthentication yes/;p;}' /etc/ssh/sshd_config > tmp_sshd_config
sudo cat tmp_sshd_config > /etc/ssh/sshd_config
rm -f tmp_sshd_config
sudo service sshd restart
TASK [run ping] ****************************************************************************
task path: /ansible/ping.yaml:20
<34.202.122.113> ESTABLISH SSH CONNECTION FOR USER: ansible
<34.202.122.113> SSH: EXEC sshpass -d9 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="ansible"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/root/.ansible/cp/65b11a12a7 34.202.122.113 '/bin/sh -c '"'"'echo ~ansible && sleep 0'"'"''
<34.202.122.113> (3, '', 'sshpass: Failed to run command: No such file or directory\n')
<34.202.122.113> Failed to connect to the host via ssh: sshpass: Failed to run command: No such file or directory
<34.202.122.113> ESTABLISH SSH CONNECTION FOR USER: ansible
<34.202.122.113> SSH: EXEC sshpass -d9 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="ansible"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/root/.ansible/cp/65b11a12a7 34.202.122.113 '/bin/sh -c '"'"'echo "`pwd`" && sleep 0'"'"''
<34.202.122.113> (3, '', 'sshpass:
@duffney
duffney / ansible-directory-layouts.md
Last active June 17, 2020 11:24
Ansible Directory Layouts

Basic

|-- dev
|-- production

|-- group_vars/
|   |-- all.yml
|   |-- linux.yml
| |-- windows.yml
@duffney
duffney / becomeAnsible_create_service_principal.ps1
Created July 20, 2020 13:55
Code Snippet for become Ansible Chapter 2 pg 18
$credentials = New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property @{ StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password='<Password>'};
$spSplat = @{ DisplayName = 'ansible' ; PasswordCredential = $credentials} ;
$sp = New-AzAdServicePrincipal @spSplat
@duffney
duffney / entrypoint.sh
Created July 26, 2020 10:10
Ansible entrypoint.sh using if statement to throw on failure
if ! ansible-playbook -i hosts_azure_rm.yml site.yml --vault-password-file .vault; then
echo "Ansible failed!"
rm .vault
exit 1
else
rm .vault
fi
$keyName = '{keyName}'
ssh-keygen -f $keyName -t rsa -N '""' -b 4096 -C '{email}'
$publicKey = (Get-Content "$keyName.pub" -Raw).ToString()
gh auth login
gh api "repos/{userName}/{repo}/keys" -f "key=$publicKey" -f "title=ROkey" -F read_only="true"
@duffney
duffney / becomeansible-2-10-dockerfile.md
Last active October 23, 2020 02:30
Dockerfile and supporting links for Ansible 2.10 for become Ansible

Dockerfile

FROM centos:centos7
COPY requirements-azure /tmp
RUN yum check-update; \
yum install -y gcc libffi-devel python3 epel-release; \
yum install -y openssh-clients; \
curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo; \
yum install -y powershell; \
@duffney
duffney / configure-ansible-centos.sh
Created February 24, 2021 18:44
configure-ansible-centos.sh
#!/bin/bash
# Update all packages that have available updates.
sudo yum update -y
# Install Python 3 and pip.
sudo yum install -y python3-pip
# Upgrade pip3.
sudo pip3 install --upgrade pip
@duffney
duffney / Dockerfile
Created September 12, 2021 14:57
become ansible pip issue temp fix
FROM centos:centos7
RUN yum check-update; \
yum install -y gcc libffi-devel python3 epel-release; \
yum install -y openssh-clients; \
yum clean all; \
yum install ansible -y;
@duffney
duffney / logseqTimeBlockerTemplate.md
Last active April 18, 2022 20:19
logseqTimeBlockerTemplate.md
  • Time-blocker

    template:: time-blocker template-including-parent:: false
    • Daily Metrics

        - TODO Write: 1 hour
        - TODO Learn to Code: 30 minutes
        - TODO Read: 25 pages
      
    • Engineer's Daybook

      • Notes: