Linux/Ansible: Difference between revisions
< Linux
No edit summary |
mNo edit summary |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="wikitable" style="float:right; margin-left: 10px;" width="400px" | |||
| Other articles | |||
|- | |||
| | |||
<DynamicPageList> | |||
category = Linux/Ansible | |||
ordermethod = sortkey | |||
</DynamicPageList> | |||
|} | |||
= Install = | = Install = | ||
<pre> | <pre> | ||
sudo apt | sudo apt update | ||
sudo add | sudo apt install ansible | ||
sudo apt | </pre> | ||
or newer version: | |||
<pre> | |||
sudo apt-add-repository ppa:ansible/ansible | |||
sudo apt install ansible | |||
</pre> | </pre> | ||
* Install plugins | |||
<pre> | |||
ansible-galaxy collection install ansible.posix | |||
ansible-galaxy collection install community.general | |||
</pre> | |||
= Commands = | = Commands = | ||
Line 17: | Line 36: | ||
</pre></blockquote> | </pre></blockquote> | ||
<blockquote><pre> | <blockquote><pre> | ||
- | ansible hostname -m setup # variables for "hostname" | ||
</pre></blockquote> | </pre></blockquote> | ||
== Step-by-step == | |||
# Setup file structure | |||
# When using ssh key access | |||
#: <pre>ssh-copy-id -i ~/.ssh/id_rsa user@server</pre> | |||
# When using ssh password | |||
#: <pre>apt install sshpass</pre> | |||
#: <pre>ansible-galaxy collection install ansible.posix # when using ansible to set ssh key</pre> | |||
# Run ansible playbook | |||
#:<pre>ansible-playbook pb-hostname.yml</pre> | |||
#:options: | |||
#::-k (ssh pass) | |||
#::-K (password for sudo) | |||
= Links = | = Links = | ||
* https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html | |||
* https://medium.com/@tedchength/installing-docker-using-ansible-script-c182787f2fa1 | * https://medium.com/@tedchength/installing-docker-using-ansible-script-c182787f2fa1 | ||
[[Category:Linux/ | [[Category:Linux/Deployment]] | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 20:16, 26 November 2023
Other articles |
Install
sudo apt update sudo apt install ansible
or newer version:
sudo apt-add-repository ppa:ansible/ansible sudo apt install ansible
- Install plugins
ansible-galaxy collection install ansible.posix ansible-galaxy collection install community.general
Commands
ansible --version
ansible-playbook pb-machinex.yml
ansible hostname -m setup # variables for "hostname"
Step-by-step
- Setup file structure
- When using ssh key access
ssh-copy-id -i ~/.ssh/id_rsa user@server
- When using ssh password
apt install sshpass
ansible-galaxy collection install ansible.posix # when using ansible to set ssh key
- Run ansible playbook
ansible-playbook pb-hostname.yml
- options:
- -k (ssh pass)
- -K (password for sudo)