Code Monkey home page Code Monkey logo

ansible-playbooks's Introduction

About me

Role: Systems Administrator

Experience
  • support: troubleshooting, training, documentation
  • proxies & web servers: Squid, Apache, Nginx, HAProxy, IIS
  • mail servers: Postfix, Dovecot, Roundcube, DKIM, Postgrey
  • config/change management: Subversion, Git, Ansible
  • containers: Docker, LXD
  • virtualization: VMware, Hyper-V, VirtualBox
  • databases: MySQL/MariaDB, PostgreSQL, Microsoft SQL Server
  • monitoring: Nagios, custom tooling, Microsoft Teams, fail2ban
  • logging: rsyslog (local, central receivers), Graylog
  • ticketing: Redmine, GitHub, GitLab, Service Now

Role: Intermediate developer

Experience
  • current:
    • Go, Python, PowerShell, shell scripting
    • MySQL/MariaDB, SQLite
    • Docker, LXD
    • Markdown, Textile, MediaWiki, reStructuredText, HTML, CSS
    • Redmine, GitHub (including GitHub Actions), Gitea, GitLab
  • past: batch files (don't laugh, it gets the job done), Perl
  • academic: C, C++

ansible-playbooks's People

Contributors

atc0005 avatar

Watchers

 avatar  avatar

ansible-playbooks's Issues

FAILED | link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists

Relevant bits

TASK [Remove container hostkeys from known_hosts file on LXD host via IP Address] **************************************************************************************************************************
fatal: [ansible-ubuntu-12 -> localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/ssh-keygen -R 10.245.28.137 -f /home/ubuntu/.ssh/known_hosts", "msg": "link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists", "rc": 255, "stderr": "link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists\r\n", "stderr_lines": ["link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists"], "stdout": "", "stdout_lines": []}

Command

ubuntu@ansiblecontrol:~/Desktop/ansible-playbooks-public/lxd-testenv$ ansible-playbook -i hosts lxd-remove.yml -K

Complete output

SUDO password: 

PLAY [Login to all hosts (in inventory) in order to collect Ansible Facts] *********************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************************************
ok: [ansible-centos-2]                                                                                                                                                     
ok: [ansible-centos-3]                                                                                                                                                      
ok: [ansible-centos-4]
ok: [ansible-centos-5]
ok: [ansible-centos-1]
ok: [ansible-centos-6]                                                                                                                                                      
ok: [ansible-centos-7]                                                                                                                                                   
ok: [ansible-centos-8]
ok: [ansible-ubuntu-10]                                                                                                                                                    
ok: [ansible-ubuntu-12]
ok: [ansible-ubuntu-9]
ok: [ansible-ubuntu-11]
ok: [ansible-ubuntu-13]

TASK [Create dynamic host groups based on their OS distribution] *******************************************************************************************************************************************
ok: [ansible-centos-1]
ok: [ansible-centos-2]
ok: [ansible-centos-3]
ok: [ansible-centos-4]
ok: [ansible-centos-5]
ok: [ansible-centos-6]
ok: [ansible-centos-7]
ok: [ansible-centos-8]
ok: [ansible-ubuntu-10]
ok: [ansible-ubuntu-12]
ok: [ansible-ubuntu-9]
ok: [ansible-ubuntu-11]
ok: [ansible-ubuntu-13]

PLAY [Prune SSH host key entries] **************************************************************************************************************************************************************************

TASK [Remove container hostkeys from known_hosts file on LXD host via IP Address] **************************************************************************************************************************
fatal: [ansible-ubuntu-12 -> localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/ssh-keygen -R 10.245.28.137 -f /home/ubuntu/.ssh/known_hosts", "msg": "link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists", "rc": 255, "stderr": "link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists\r\n", "stderr_lines": ["link /home/ubuntu/.ssh/known_hosts to /home/ubuntu/.ssh/known_hosts.old: File exists"], "stdout": "", "stdout_lines": []}
changed: [ansible-ubuntu-11 -> localhost]
changed: [ansible-ubuntu-9 -> localhost]
changed: [ansible-ubuntu-10 -> localhost]
changed: [ansible-ubuntu-13 -> localhost]
changed: [ansible-centos-1 -> localhost]
changed: [ansible-centos-2 -> localhost]
changed: [ansible-centos-3 -> localhost]
changed: [ansible-centos-4 -> localhost]
changed: [ansible-centos-5 -> localhost]
changed: [ansible-centos-6 -> localhost]
changed: [ansible-centos-7 -> localhost]
changed: [ansible-centos-8 -> localhost]

TASK [Remove container hostkeys from known_hosts file on LXD host via hostname] ****************************************************************************************************************************
ok: [ansible-ubuntu-10 -> localhost]
ok: [ansible-ubuntu-9 -> localhost]
ok: [ansible-ubuntu-11 -> localhost]
ok: [ansible-ubuntu-13 -> localhost]
ok: [ansible-centos-1 -> localhost]
ok: [ansible-centos-2 -> localhost]
ok: [ansible-centos-3 -> localhost]
ok: [ansible-centos-4 -> localhost]
ok: [ansible-centos-5 -> localhost]
ok: [ansible-centos-6 -> localhost]
ok: [ansible-centos-7 -> localhost]
ok: [ansible-centos-8 -> localhost]

PLAY [Remove our LXD containers] ***************************************************************************************************************************************************************************

TASK [Stop containers] *************************************************************************************************************************************************************************************
changed: [localhost] => (item=ansible-centos-1)
changed: [localhost] => (item=ansible-centos-2)
changed: [localhost] => (item=ansible-centos-3)
changed: [localhost] => (item=ansible-centos-4)
changed: [localhost] => (item=ansible-centos-5)
changed: [localhost] => (item=ansible-centos-6)
changed: [localhost] => (item=ansible-centos-7)
changed: [localhost] => (item=ansible-centos-8)
changed: [localhost] => (item=ansible-ubuntu-9)
changed: [localhost] => (item=ansible-ubuntu-10)
changed: [localhost] => (item=ansible-ubuntu-11)
changed: [localhost] => (item=ansible-ubuntu-12)
changed: [localhost] => (item=ansible-ubuntu-13)

TASK [Delete containers] ***********************************************************************************************************************************************************************************
changed: [localhost] => (item=ansible-centos-1)
changed: [localhost] => (item=ansible-centos-2)
changed: [localhost] => (item=ansible-centos-3)
changed: [localhost] => (item=ansible-centos-4)
changed: [localhost] => (item=ansible-centos-5)
changed: [localhost] => (item=ansible-centos-6)
changed: [localhost] => (item=ansible-centos-7)
changed: [localhost] => (item=ansible-centos-8)
changed: [localhost] => (item=ansible-ubuntu-9)
changed: [localhost] => (item=ansible-ubuntu-10)
changed: [localhost] => (item=ansible-ubuntu-11)
changed: [localhost] => (item=ansible-ubuntu-12)
changed: [localhost] => (item=ansible-ubuntu-13)

TASK [Remove container entries from hosts file on LXD host] ************************************************************************************************************************************************
changed: [localhost] => (item=ansible-ubuntu-10)
changed: [localhost] => (item=ansible-ubuntu-12)
changed: [localhost] => (item=ansible-ubuntu-9)
changed: [localhost] => (item=ansible-ubuntu-11)
changed: [localhost] => (item=ansible-ubuntu-13)
changed: [localhost] => (item=ansible-centos-1)
changed: [localhost] => (item=ansible-centos-2)
changed: [localhost] => (item=ansible-centos-3)
changed: [localhost] => (item=ansible-centos-4)
changed: [localhost] => (item=ansible-centos-5)
changed: [localhost] => (item=ansible-centos-6)
changed: [localhost] => (item=ansible-centos-7)
changed: [localhost] => (item=ansible-centos-8)
	to retry, use: --limit @/home/ubuntu/Desktop/ansible-playbooks-public/lxd-testenv/lxd-remove.retry

PLAY RECAP *************************************************************************************************************************************************************************************************
ansible-centos-1           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-2           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-3           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-4           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-5           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-6           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-7           : ok=4    changed=1    unreachable=0    failed=0   
ansible-centos-8           : ok=4    changed=1    unreachable=0    failed=0   
ansible-ubuntu-10          : ok=4    changed=1    unreachable=0    failed=0   
ansible-ubuntu-11          : ok=4    changed=1    unreachable=0    failed=0   
ansible-ubuntu-12          : ok=2    changed=0    unreachable=0    failed=1   
ansible-ubuntu-13          : ok=4    changed=1    unreachable=0    failed=0   
ansible-ubuntu-9           : ok=4    changed=1    unreachable=0    failed=0   
localhost                  : ok=3    changed=3    unreachable=0    failed=0   

'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_default_ipv4'

This occurs with commit 774c474.

The creation of the LXD containers seems to work well enough, but attempting to mass-remove them doesn't:

TASK [Remove container entries from hosts file on LXD host] ************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'hostvars[item].ansible_default_ipv4.address is defined' failed. The error was: error while evaluating conditional (hostvars[item].ansible_default_ipv4.address is defined): 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_default_ipv4'\n\nThe error appears to have been in '/home/ubuntu/Desktop/ansible-testing/ansible-lxd.yml': line 226, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: \"Remove container entries from hosts file on LXD host\"\n      ^ here\n"}
	to retry, use: --limit @/home/ubuntu/Desktop/ansible-testing/ansible-lxd.retry

Steps to reproduce:

  1. ansible-playbook -i hosts ansible-lxd.yml -K
  2. ansible-playbook -i hosts ansible-lxd.yml -K --start-at-task="Stop containers" --tags remove

Presumably we're relying on facts that are not cached and not available when jumping directly to the specified task. Probably need to check and see what we're matching on when cleaning up the host's /etc/hosts file: match on FQDN instead of IPv4 address.

Update lxd-testenv playbooks to automatically generate SSH public key

https://docs.ansible.com/ansible/latest/modules/user_module.html

Example:

- name: Create a 2048-bit SSH key for user jsmith in ~jsmith/.ssh/id_rsa
  user:
    name: jsmith
    generate_ssh_key: yes
    ssh_key_bits: 2048
    ssh_key_file: .ssh/id_rsa

Should be easy enough to perform a look against the user running the playbook and use that info to generate a key specific to this set of playbooks (intended for testing purposes). This should reduce the chance that the wrong key is inserted into newly created containers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.