Skip to content

Commit

Permalink
version var set
Browse files Browse the repository at this point in the history
  • Loading branch information
lfkdev committed Jul 2, 2024
1 parent 1f099fc commit 37cbc7d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
- Updated gunicorn to use TCP instead of socket
- Minor fixes in README
- `/available-playbooks` can now be used to query available playbooks (inkl. subdirs)
- Added tests for `/available-playbooks`
- Added tests for `/available-playbooks`
- Install script now auto-selects port
12 changes: 12 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ check_root() {
fi
}

check_port_usage() {
local port=$ANSIBLE_LINK_PORT
while lsof -i :$port &>/dev/null; do
log "WARNING" "Port $port is already in use. Trying next port..."
port=$((port + 1))
done
ANSIBLE_LINK_PORT=$port
log "INFO" "Using port $ANSIBLE_LINK_PORT for ansible-link."
}

check_existing_installation() {
if [[ -d "$INSTALL_DIR" ]]; then
read -p "ansible-link is already installed. Do you want to reinstall? This will delete $INSTALL_DIR. (y/N) " -n 1 -r
Expand Down Expand Up @@ -127,6 +137,7 @@ update_config() {
log "INFO" "Updating configuration..."
sed -i "s|^playbook_dir:.*|playbook_dir: '$ANSIBLE_DIR'|" "$INSTALL_DIR/config.yml"
sed -i "s|^inventory_file:.*|inventory_file: '$ANSIBLE_DIR/hosts'|" "$INSTALL_DIR/config.yml"
sed -i "s|^port:.*|port: '$ANSIBLE_LINK_PORT'|" "$INSTALL_DIR/config.yml"
}

setup_service() {
Expand Down Expand Up @@ -192,6 +203,7 @@ main() {
check_root
check_existing_installation
check_systemd
check_port_usage
install_dependencies
download_ansible_link
install_ansible_link
Expand Down
4 changes: 2 additions & 2 deletions src/ansible_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
app = Flask(__name__)
prefix=f'/api/v{VERSION.split(".")[0]}'
api = Api(app,
version='0.9',
version=VERSION,
title='ANSIBLE-LINK',
description='API for executing Ansible playbooks',
external_doc={'description': 'GitHub', 'url': 'https://github.com/lfkdev/ansible-link'},
Expand Down Expand Up @@ -355,6 +355,6 @@ def main():

if __name__ == '__main__':
app = main()
app.run(debug=config.get('debug', False), host=config.get('host', '127.0.0.1'), port=config.get('port', 5000))
app.run(debug=config.get('debug', False), host=config.get('host', '127.0.0.1'), port=config.get('port', 5001))


0 comments on commit 37cbc7d

Please sign in to comment.