[AIAnsible]در عصر AIOps، یاد بگیرید که وظایف Ansible را با AIAnsbile تنها در 10 دقیقه اشکال زدایی کنید.
![[AIAnsible]در عصر AIOps، یاد بگیرید که وظایف Ansible را با AIAnsbile تنها در 10 دقیقه اشکال زدایی کنید. [AIAnsible]در عصر AIOps، یاد بگیرید که وظایف Ansible را با AIAnsbile تنها در 10 دقیقه اشکال زدایی کنید.](https://i2.wp.com/media.dev.to/cdn-cgi/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhn5tww6ao9j1vazehm8x.png?w=780&resize=780,470&ssl=1)
اشکال زدایی Ansible با هوش مصنوعی برای اظهار نظر خودکار، تجزیه و تحلیل خطا و ارائه پیشنهادات برای بهبود.
استفاده اولیه:
:cn Set the language to Chinese
:en Set the language to English
i Annotate the code of the currently executing task
ir Annotate the code of the currently executing task, analyze the results, and provide suggestions for improvement
ask Please answer questions based on the current Ansible task
n next Run the next task
m Do not stay at the same task again immediately
c continue Continue running until the next breakpoint
b Create a breakpoint
p View created breakpoints
d delete Delete a breakpoint
bt View which tasks have been run
code View the code of the currently running task
v Open the corresponding file with VSCode
a arg View all arguments, or a single argument (assuming the task has not been skipped)
? help View the usage instructions
exit Exit
نتیجه کار قابل انجام فعلی را بررسی کنید:
Aiansible(CN) => result._result
{'msg': 'Check roles/kubespray-defaults/defaults/main.yml', '_ansible_verbose_always': True, '_ansible_no_log': False, 'changed': False}
نمونه سریع ai:
اگر می خواهید از انگلیسی استفاده کنید:
export AIANSIBLE_LANG=EN
یا از “:cn”and”:en” برای تغییر زبان استفاده کنید:
نصب و شروع به استفاده از aiansible:
git clone https://github.com/sunnycloudy/aiansible.git
cd aiansible
pip install . #=> will generate dir: ~/.aiansible_plugin
pip install -r requirements.txt
[defaults]
callback_plugins = ~/.aiansible_plugin
callbacks_enabled = aiansible.py
- (4) پیکربندی پارامترهای هوش مصنوعی:
اگر تنظیم نشود، ویژگی درخواست هوش مصنوعی در دسترس نخواهد بود، اما بر اشکال زدایی معمولی تأثیر نخواهد گذاشت.
استفاده از فایل پیکربندی (توصیه می شود)
ایجاد config.yml: ~/.aiansible_plugin/config.yml
openai:
api_key: https://api.moonshot.cn/v1 #or any other compatible OpenAI API address
api_url: your_openai_api_url_here #or any other compatible OpenAI key
model: moonshot-v1-8k #or any other compatible OpenAI model name
یا از متغیرهای محیطی برای پیکربندی هوش مصنوعی استفاده کنید
export OPENAI_API_URL=https://api.moonshot.cn/v1 #or any other compatible OpenAI API address
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx #or any other compatible OpenAI key
export OPENAI_MODEL=moonshot-v1-8k #or any other compatible OpenAI model name
# Configure the plugin in debug.cfg
export ANSIBLE_CONFIG=./debug.cfg
ansible-playbook xxx_playbook.yml
اشکال زدایی Kubespray:
# find
kubespray/ansible.cfg
ansible.cfg پیش فرض kubespray را ویرایش کنید:
[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
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 #<= comment it (・ω・)ノ
callback_plugins = ~/.aiansible_plugin #<= new line (。・ω・。)ノ
callbacks_enabled = aiansible.py #<= new line ( ・ω・ )ノ
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
اجرای دستور:
اگر تنظیم نشود، ویژگی درخواست هوش مصنوعی در دسترس نخواهد بود، اما بر اشکال زدایی معمولی تأثیر نخواهد گذاشت.
پیکربندی پارامترهای هوش مصنوعی:
ایجاد config.yml: ~/.aiansible_plugin/config.yml
استفاده از فایل پیکربندی (توصیه می شود)
openai:
api_key: https://api.moonshot.cn/v1 #or any other compatible OpenAI API address
api_url: your_openai_api_url_here #or any other compatible OpenAI key
model: moonshot-v1-8k #or any other compatible OpenAI model name
یا از متغیرهای محیطی برای پیکربندی هوش مصنوعی استفاده کنید
export OPENAI_API_URL=https://api.moonshot.cn/v1 #or any other compatible OpenAI API address
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx #or any other compatible OpenAI key
export OPENAI_MODEL=moonshot-v1-8k #or any other compatible OpenAI model name
حالت ویرایش: حالت emacs-mode یا vim-mode را پشتیبانی می کند، پیش فرض emacs-mode است
export AIANSIBLE_EDITMODE=vi
#或
export AIANSIBLE_EDITMODE=emacs