#1 Add them directly to you code
import pdb; pdb.set_trace()
# or
import ipdb; ipdb.set_trace()#2: Set them interactively
python -m pdb hello.py| Question: | |
| . How to run Ansible without specifying the inventory but the host directly? | |
| . Run a playbook or command with arbitrary host not in the inventory hosts list? | |
| . run ansible with arbitrary host/ip without inventory? | |
| Answer: | |
| Surprisingly, the trick is to append a , | |
| The host parameter preceding the , can be either a hostname or an IPv4/v6 address. | |
| ansible all -i example.com, |
| # -*- mode: ruby -*- 2 # vi: set ft = ruby : 3 4 VAGRANTFILE_API_VERSION = "2" 5 6 Vagrant.configure( VAGRANTFILE_API_VERSION) do | config | 7 # General Vagrant VM configuration. 8 config.vm.box = "geerlingguy/ centos7" 9 config.ssh.insert_key = false 10 config.vm.synced_folder ".", "/vagrant", disabled: true 11 config.vm.provider :virtualbox do | v | 12 v.memory = 256 13 v.linked_clone = true 14 end 15 16 # Application server 1. 17 config.vm.define "app1" do | app | 18 app.vm.hostname = "orc-app1. test" 19 app.vm.network :private_network, ip: "192.168.60.4" 20 end 21 22 # Application server 2. 23 config.vm.define "app2" do | app | 24 app.vm.hostname = "orc-app2. test" 25 app.vm.network :private_network, ip: "192.168.60.5" 26 end 27 28 # Database server. 29 config.vm.define "db" do | db | |
| db.vm.hostname = "orc-db.test" 31 db.vm.network :private_network, ip: "192.168.60.6" 32 end 33 end This Vagrantfile |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import socket | |
| import re | |
| import sys | |
| def check_server(address, port): | |
| # Create a TCP socket | |
| s = socket.socket() | |
| print "Attempting to connect to %s on port %s" % (address, port) |
| import socket | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| sock.settimeout(2) #2 Second Timeout | |
| result = sock.connect_ex(('127.0.0.1',80)) | |
| if result == 0: | |
| print 'port OPEN' | |
| else: | |
| print 'port CLOSED, connect_ex returned: '+str(result) |
| for i in `python -m pip list -o | cut -d ' ' -f 1` | |
| do | |
| python -m pip install -U $i | |
| done |
| // To view the default settings, hold "alt" while clicking on the "Settings" button. | |
| // For documentation on these settings, see: https://aka.ms/terminal-documentation | |
| { | |
| "$schema": "https://aka.ms/terminal-profiles-schema", | |
| "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
| "profiles": [ | |
| { | |
| "guid": "{8a993db9-7368-4f5a-8af5-b3cdf876bf34}", | |
| "hidden": false, | |
| "name": "PowerShell 7 Preview", |
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| NAME = "zabbix-5-lts" | |
| # All Vagrant configuration is done below. The "2" in Vagrant.configure | |
| # configures the configuration version (we support older styles for | |
| # backwards compatibility). Please don't change it unless you know what | |
| # you're doing. | |
| Vagrant.configure("2") do |config| | |
| # The most common configuration options are documented and commented below. |
| # DOCKER | |
| alias dstopcont='sudo docker stop $(docker ps -a -q)' | |
| alias dstopall='sudo docker stop $(sudo docker ps -aq)' | |
| alias drmcont='sudo docker rm $(docker ps -a -q)' | |
| alias dvolprune='sudo docker volume prune' | |
| alias dsysprune='sudo docker system prune -a' | |
| alias ddelimages='sudo docker rmi $(docker images -q)' | |
| alias docerase='dstopcont ; drmcont ; ddelimages ; dvolprune ; dsysprune' | |
| alias docprune='ddelimages ; dvolprune ; dsysprune' | |
| alias dexec='sudo docker exec -ti' |
#1 Add them directly to you code
import pdb; pdb.set_trace()
# or
import ipdb; ipdb.set_trace()#2: Set them interactively
python -m pdb hello.py