ansible-role-security | Ansible Role - Security
kandi X-RAY | ansible-role-security Summary
kandi X-RAY | ansible-role-security Summary
Ansible Role - Security
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ansible-role-security
ansible-role-security Key Features
ansible-role-security Examples and Code Snippets
Community Discussions
Trending Discussions on ansible-role-security
QUESTION
I am writing an ansible playbook to provision a web server for me. Part of this process involves using the geerlingguy/ansible-role-security role (which I use to change the default ssh port). However, since the port changes, you cannot run the playbook over and over without changing the ansible_ssh_port variable. This seems to go against the whole point of idempotence, since you have to edit the playbook between runs. So I was wondering if there was a way to describe 2 ports for ansible to try. That way it would use port 22 the first time the script runs, but all other times it would use the other port.
I tried searching for ways to try different ports, but I couldn't find anything.
...ANSWER
Answered 2020-Jun-04 at 01:55I had the similar scenario and found an workaround using wait_for and set_fact modules.
The idea is to set ansible_port
if a port is accessible.
Below is a sample that checks and sets a port specified using port1
variable. It's not necessary to use ignore_errors
or check the result in this sample scenario but could be useful if multiple ports needed to be tested. Also, delegate_to: localhost
may be used if a play is using a remote host.
Extend the implementation further using loops, block, rescue etc. as appropriate.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ansible-role-security
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page