Last active
April 1, 2024 07:29
-
-
Save Nurlan199206/23083e6dcd7b7bbbb8e380a4d0c094c0 to your computer and use it in GitHub Desktop.
Ansible example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ansible-galaxy init yourrole | |
sudo ansible all -m shell -a 'shutdown -h now' -u nurlan -bkK --become-user=root | |
=========================================================================================== | |
ansible [core 2.12.5] | |
если ансибл устанавливался через pip3 install то конфиги должны быть тут: | |
ANSIBLE_CONFIG (environment variable if set) | |
ansible.cfg (in the current directory) | |
~/.ansible.cfg (in the home directory) | |
/etc/ansible/ansible.cfg | |
====================================.ansible.cfg============================================== | |
[ssh_connection] | |
pipelining=True | |
ansible_ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ConnectionAttempts=100 -o UserKnownHostsFile=/dev/null | |
#control_path = ~/.ssh/ansible-%%r@%%h:%%p | |
[defaults] | |
# https://github.com/ansible/ansible/issues/56930 (to ignore group names with - and .) | |
force_valid_group_names = ignore | |
inventory = /home/nurlan/hosts | |
host_key_checking=False | |
gathering = smart | |
fact_caching = jsonfile | |
fact_caching_connection = /tmp | |
fact_caching_timeout = 86400 | |
stdout_callback = default | |
display_skipped_hosts = no | |
library = ./library | |
callbacks_enabled = profile_tasks,ara_default | |
roles_path = roles:$VIRTUAL_ENV/usr/local/share/kubespray/roles:$VIRTUAL_ENV/usr/local/share/ansible/roles:/usr/share/kubespray/roles | |
deprecation_warnings=False | |
inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo, .creds, .gpg | |
[inventory] | |
ignore_patterns = artifacts, credentials | |
=========================================================================================================== | |
==============================================hosts================================== | |
[kube_control_plane] | |
k8s-master01 ansible_host=192.168.1.161 | |
k8s-master02 ansible_host=192.168.1.162 | |
k8s-master03 ansible_host=192.168.1.163 | |
[etcd] | |
k8s-master01 ansible_host=192.168.1.161 | |
k8s-master02 ansible_host=192.168.1.162 | |
k8s-master03 ansible_host=192.168.1.163 | |
[kube_node] | |
k8s-node01 ansible_host=192.168.1.164 | |
===================================================================================== | |
sudo ansible all -m shell -a 'uptime -p' -u nurlan | |
sudo ansible all -m shell -a 'shutdown -h now' -u nurlan -bkK --become-user=root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment