ä»ã®èšèªã§ããèªã¿ããã ããŸã:
English, æ¥æ¬èª.
ãã®æŒç¿ã¯ãAnsible ã Chocolatey ã䜿çšãã Windows ãœãããŠã§ã¢ã®ç®¡çã®ãã¹ãŠã®åŽé¢ãç°¡åã«å¶åŸ¡ã§ããããã«ããæ¹æ³ã玹ä»ããããšãç®çãšããŠããŸããããã±ãŒãžã®ã€ã³ã¹ããŒã«ãæŽæ°ãã¢ã³ã€ã³ã¹ããŒã«ãããŸããŸãªãœãŒã¹ã®ç®¡çãchocolatey ã¯ã©ã€ã¢ã³ãã®æ§æãããã³ã·ã¹ãã 管çè ãå®è¡ãããã®ä»ã®äžè¬çãªã¿ã¹ã¯ã«ã€ããŠèª¬æããŸãã
Chocolatey ãšã¯äœã§ãããããç°¡åã«èšãã°ãChocolatey 㯠Windows çšã®ããã±ãŒãžç®¡çã·ã¹ãã ã§ããChocolatey ã¯ããœãããŠã§ã¢ç®¡çãç°¡çŽ åããWindows ãœãããŠã§ã¢ã©ã€ããµã€ã¯ã«å šäœã®èªååã容æã«ããããšãç®çãšããŠããŸãã
ãªãŒãã³ãœãŒã¹ã® Chocolatey ã¯ã©ã€ã¢ã³ãã¯åºæ¬çãªããã±ãŒãžç®¡çæ©èœãæäŸããChocolatey For Business ã¹ã€ãŒãã¯é«åºŠãªæ©èœã»ãããæäŸããŸããããã€ãã®ãã€ã©ã€ãã次ã«ç€ºããŸãã
- Package Builder ã䜿çšãããšãEXEãMSIãzipããŸãã¯ã¹ã¯ãªãããååŸããŠãããã 5 ç§ã§èªåçã« Chocolatey ããã±ãŒãžã«å€æã§ããŸã (ã€ã³ã¹ããŒã©ãŒã®ãµã€ã¬ã³ãåŒæ°ãææ¡ã§ããŸã)ã
- Package Internalizer ã¯ãã¡ã³ããã Chocolatey Community Repository ã§æ¢ã«æ§ç¯ãã 8000 以äžã®ããã±ãŒãžãååŸããå éšã§äœ¿çšããããã®ããŒã«ã©ã€ãºããããªãã©ã€ã³ããŒãžã§ã³ãäœæããŸã (äŸåé¢ä¿ãå«ã)ã
- Package Synchronizer ã䜿çšãããšãPrograms and Features ã«ãªã¹ããããŠããã¢ããªã±ãŒã·ã§ã³çšã®Chocolatey ããã±ãŒãžãäœæããä»ã®ããã±ãŒãžãšåãããã«ç®¡çã§ããŸãã
- Chocolatey ã»ã«ããµãŒãã¹ GUI ã䜿çšãããšããšã³ããŠãŒã¶ãŒã¯ç®¡çè æš©éãææ Œãããæš©éãå¿ èŠãšããã«ããã±ãŒãžã管çã§ããŸãã
- Chocolatey Central Management ã¯ãWeb ããã·ã¥ããŒããš API (Automation Controller ã«é¡äŒŒ) ã§ããããšã³ããã€ã³ãã®è³ç£å šäœã®é«ã¬ãã«ã®æŠèŠãšã¬ããŒããæäŸããŸãã
ã¹ããã 1: ã¢ãããã¯ã³ãã³ãã䜿çšããŠããã±ãŒãžãã€ã³ã¹ããŒã«ãã
ãŸããã¢ãããã¯ã³ãã³ãã䜿çšããŠãwin_chocolatey
ã¢ãžã¥ãŒã«ã䜿çšã㊠git
ãã€ã³ã¹ããŒã«ããŸããwin_chocolatey
ã¢ãžã¥ãŒã«ã¯ãChocolatey ã䜿çšã㊠Windows ã·ã¹ãã äžã®ããã±ãŒãžã管çããããã«äœ¿çšãããŸãã
ãŸããå·ŠåŽã®ããã«ã® Inventories ãã¯ãªãã¯ããŠãããã€ã³ãã³ããªãŒ Workshop Inventory ã®ååãã¯ãªãã¯ããŸããInventory Details ããŒãžã衚瀺ãããã®ã§ããã¹ããéžæããå¿
èŠããããŸãããããã£ãŠãHOSTS ãã¯ãªãã¯ããŸãã
åãã¹ãã®æšªã«ã¯ãã§ãã¯ããã¯ã¹ããããŸããã¢ãããã¯ã³ãã³ããå®è¡ããåãã¹ãã®æšªã«ãããã§ãã¯ããã¯ã¹ããªã³ã«ããŸãã次ã«ãRUN COMMANDS ãã¿ã³ãæå¹ã«ãªããŸããä»ããã¯ãªãã¯ããŠãã ããã
ããã«ãããExecute Command ãŠã£ã³ããŠããããã¢ãã衚瀺ãããŸããããããããã¹ãã«å¯ŸããŠåäžã®ã¿ã¹ã¯ãå®è¡ã§ããŸãã
ãã®ãã©ãŒã ã«æ¬¡ã®ããã«èšå ¥ããŸãã
Key | Value | Note |
---|---|---|
MODULE | win_chocolatey |
|
ARGUMENTS | name=git state=present |
The name and state of the package |
LIMIT | This will be pre-filled out for you with the hosts you selected | |
MACHINE CREDENTIAL | Student Account |
LAUNCH ãã¯ãªãã¯ãããšããžã§ããã°ã«ãªãã€ã¬ã¯ããããŸãã
ãžã§ãã®åºåã«ã¯ã次ã®ãããªçµæã衚瀺ãããŸãã
åºåã¯ãgit
ãã€ã³ã¹ããŒã«ãããããšã瀺ã CHANGED ã¹ããŒã¿ã¹ãå ±åããŠããããšãããããŸããçµæã«ã¯ãChocolatey
ã¯ã©ã€ã¢ã³ããã·ã¹ãã ã«ãªããšããèŠåã衚瀺ãããããããã®ã¿ã¹ã¯å®è¡ã®äžéšãšããŠã€ã³ã¹ããŒã«ãããŸãããwin_chocolatey
ã¢ãžã¥ãŒã«ã䜿çšããå°æ¥ã®ã¿ã¹ã¯ã¯ãã¯ã©ã€ã¢ã³ããæ€åºããäœãã€ã³ã¹ããŒã«ããã«äœ¿çšããå¿
èŠããããŸãã確èªããã«ã¯ãDETAILS
ã»ã¯ã·ã§ã³ã®ãã±ããã¢ã€ã³ã³ãã¯ãªãã¯ããŠãžã§ããåå®è¡ããŸããåºåã«èŠåã衚瀺ããããå€æŽãå ±åãããŸããããã ããwin_chocolatey
(å€ãã® Ansible ã¢ãžã¥ãŒã«ãšåæ§) ã¢ãžã¥ãŒã«ãåªç (以åã®å®è¡ã 2
ã€ã®ããã±ãŒãžãã€ã³ã¹ããŒã«ããŸããããããã¯ãªã«ãã€ã³ã¹ããŒã«ããªããããå®è¡æéã¯çããªããŸã) ã§ããããã代ããã« SUCCESS
ã¹ããŒã¿ã¹ãå ±åãããŸãã
ãã®ããã«ããŠãgit
ãã€ã³ã¹ããŒã«ãããŠããŸãã
æåŸã®ã¹ãããã§ã¯ãã¢ãããã¯ãªæ¹æ³ã§ 1 ã€ã®ããã±ãŒãžãã€ã³ã¹ããŒã«ããŸããããã ããå®éã«ã¯ããã«ãã¹ããããã¬ã€ã® 1 ã€ã®ã¹ããããšããŠããã±ãŒãžã®ã€ã³ã¹ããŒã«ãå«ããããšããå§ãããŸãããŸããè€æ°ã®ããã±ãŒãž (å Žåã«ãã£ãŠã¯ãã®ããã±ãŒãžã®ç¹å®ã®ããŒãžã§ã³) ãã€ã³ã¹ããŒã«ããããšãèããããŸãããã®æŒç¿ã§ã¯ããããè¡ããŸãã
ãŸã㯠Visual StudioCode ã«æ»ããŸããWORKSHOP_PROJECT ã»ã¯ã·ã§ã³ã®äžã« chocolatey
ãšãããã£ã¬ã¯ããªãŒãš install_packages.yml
ãšãããã¡ã€ã«ãäœæããŸãã
ããã§ãPlaybook ã®äœæã«äœ¿çšã§ãããšãã£ã¿ãŒãå³åŽã®ãã€ã³ã§éããŠããã¯ãã§ãã
ãŸãããã¬ã€ãå®çŸ©ããŸãã
---
- name: Install Specific versions of packages using Chocolatey
hosts: all
gather_facts: false
vars:
choco_packages:
- name: nodejs
version: 13.0.0
- name: python
version: 3.6.0
Ansible ã«ãã£ãŠåéããããã¡ã¯ãã¯å¿
èŠãªãã䜿çšããªãããããªãŒããŒããããæžããããã« gather_facts: false
ãèšå®ããŠãã¡ã¯ãåéãç¡å¹ã«ããŸããããŸããChocolatey ã䜿çšããŠã€ã³ã¹ããŒã«ããããã±ãŒãžã®ååãšããŒãžã§ã³ãä¿æããããã«ãvars
ãã£ã¬ã¯ãã£ãã®äžã« choco_packages
ãšããååã®1ã€ã®èŸæžå€æ°ãå®çŸ©ããŸããã
次ã«ãã¿ã¹ã¯ãè¿œå ããŸãã
{% raw %}
tasks:
- name: Install specific versions of packages sequentially
win_chocolatey:
name: "{{ item.name }}"
version: "{{ item.version }}"
loop: "{{ choco_packages }}"
- name: Check python version
win_command: python --version
register: check_python_version
- name: Check nodejs version
win_command: node --version
register: check_node_version
- debug:
msg: Python Version is {{ check_python_version.stdout_lines[0] }} and NodeJS version is {{ check_node_version.stdout_lines[0] }}
{% endraw %}
ã¿ã¹ã¯ã»ã¯ã·ã§ã³ã« 4 ã€ã®ã¿ã¹ã¯ãè¿œå ããŸããã
- æåã®ã¿ã¹ã¯ã¯
win_chocolatey
ã¢ãžã¥ãŒã«ã䜿çšããchoco_packages
å€æ°ãã«ãŒãããŠãæå®ãããããŒãžã§ã³ã®å補åãã€ã³ã¹ããŒã«ããŸã - 2 çªç®ãš 3 çªç®ã®ã¿ã¹ã¯ã¯ã
win_command
ã¢ãžã¥ãŒã«ã䜿çšããŠã³ãã³ããå®è¡ããããããpython
ãšnode
ã®ããŒãžã§ã³ããã§ãã¯ããŠãããããã®åºåãç»é²ããŸãã - 4 çªç®ã®æåŸã®ã¿ã¹ã¯ã§ã¯ã
debug
ã¢ãžã¥ãŒã«ã䜿çšããŠãæé 2 ãš 3 ã§åéããæ å ±ãå«ãã¡ãã»ãŒãžã衚瀺ããŸããã
ãã³ã
win_chocolatey
ã¢ãžã¥ãŒã«ã®name
å±æ§ã¯ãå®éã«ã¯ã«ãŒãã®å¿ èŠæ§ãåé¿ããŠããã±ãŒãžã®ãªã¹ããååŸã§ããŸãããã«ãŒãã䜿çšãããšãåããã±ãŒãžã®ããŒãžã§ã³ãæå®ããé åºãé©åãªå Žåã¯ããããé çªã«ã€ã³ã¹ããŒã«ã§ããŸããwin_chocolatey
ã¢ãžã¥ãŒã«ã®è©³çŽ°ã¯ã[docs](https://docs.ansible.com/ansible/latest/collections/chocolatey/chocolatey/win_chocolatey_module.html ãåç §ããŠãã ããã
å®æãã Playbook install_packages.yml
ã¯æ¬¡ã®ããã«ãªããŸãã
{% raw %}
---
- name: Install Specific versions of packages using Chocolatey
hosts: all
gather_facts: false
vars:
choco_packages:
- name: nodejs
version: 13.0.0
- name: python
version: 3.6.0
tasks:
- name: Install specific versions of packages sequentially
win_chocolatey:
name: "{{ item.name }}"
version: "{{ item.version }}"
loop: "{{ choco_packages }}"
- name: Check python version
win_command: python --version
register: check_python_version
- name: Check nodejs version
win_command: node --version
register: check_node_version
- debug:
msg: Python Version is {{ check_python_version.stdout_lines[0] }} and NodeJS version is {{ check_node_version.stdout_lines[0] }}
{% endraw %}
ãã㧠Playbook ã®æºåãã§ããŸããã
- ã¡ãã¥ãŒãã
File > Save
ãã¯ãªãã¯ã㊠(ãŸã㯠Ctrl+S ã§) äœæ¥å 容ãä¿åããŸãã - å€æŽã git ã«ã³ãããããŸããAdding install_packages.yml ãªã©ã®é¢é£ããã³ãããã¡ãã»ãŒãžã䜿çšããŸãã
- å圢ã®ç¢å°ãã¯ãªãã¯ããŠãã³ããããããå€æŽããªããžããªã«ããã·ã¥ããŸãã
- (ãªãã·ã§ã³) GitLab Access ã®äžã®æ å ±ã䜿çšã㊠GitLab ã«ç§»åããã³ãŒãã git ã§ããããšã確èªããŸãã
次ã«ãAutomation Controller ã«æ»ãããããžã§ã¯ããåæããŠãController ãæ°ãã Playbook ã䜿ãããã«ããŸããProjects ãã¯ãªãã¯ããŠããããããžã§ã¯ãã®æšªã«ããåæã¢ã€ã³ã³ãã¯ãªãã¯ããŸãã
ãããå®äºããããæ°ãããžã§ããã³ãã¬ãŒããäœæããŸããTemplates ãéžæãã ã¢ã€ã³ã³ãã¯ãªãã¯ããŠããžã§ããã³ãã¬ãŒããéžæããŸããæ°ãããã³ãã¬ãŒãã«ã¯æ¬¡ã®å€ã䜿çšããŸãã
Key | Value | Note |
---|---|---|
Name | Chocolatey - Install Packages | |
Description | Template for the install_packages playbook | |
JOB TYPE | Run | |
INVENTORY | Workshop Inventory | |
PROJECT | Ansible Workshop Project | |
PLAYBOOK | chocolatey/install_packages.yml |
|
CREDENTIAL | Type: Machine. Name: Student Account | |
LIMIT | windows | |
OPTIONS |
SAVEãLAUNCH ã®é ã«ã¯ãªãã¯ããŠããžã§ããå®è¡ããŸãããžã§ãã¯æ£åžžã«å®è¡ãããå€æ°ã§æå®ãããããã±ãŒãžã® Ansible ã«ãŒããšã€ã³ã¹ããŒã«ã確èªã§ããã¯ãã§ãã
ãã³ã
ããã§ãPlaybook ã®äœæãŸãã¯ç·šéãå€æŽã®ã³ããããããã³ git ãžã®ããã·ã¥ã®ãããŒãç解ã§ãããšæããŸãããŸãããããžã§ã¯ãã®æŽæ°ãAutomation Controller ã§ã®ãžã§ããã³ãã¬ãŒãã®äœæãšå®è¡ã«ãæ £ããããšã§ããããåŸã®ã¹ãããã§ã¯ãåã¹ããããçç¥ããŸãã
win_chocolatey
ã¢ãžã¥ãŒã«ã¯ãããã±ãŒãžãã€ã³ã¹ããŒã«ããã ãã§ãªããããã±ãŒãžã®ã¢ã³ã€ã³ã¹ããŒã«ããã³æŽæ°ã«ã䜿çšãããŸããã¢ãžã¥ãŒã«ãå®è¡ããã¢ã¯ã·ã§ã³ã¯ãstate
ãã©ã¡ãŒã¿ãŒã«æž¡ãå€ã«åºã¥ããŠããŸããæž¡ãããšãã§ãããªãã·ã§ã³ã«ã¯ã次ã®ãã®ããããŸãã
present
: ããã±ãŒãžãã€ã³ã¹ããŒã«ãããŠããããšã確èªããŸããabsent
: ããã±ãŒãžãã€ã³ã¹ããŒã«ãããŠããªãããšã確èªããŸããlatest
: ããã±ãŒãžãå©çšå¯èœãªææ°ããŒãžã§ã³ã«ã€ã³ã¹ããŒã«ãããŠããããšã確èªããŸãã
ååã®ãã¬ã€ããã¯ã§ã¯ state
ã®å€ãæ瀺çã«å®çŸ©ããã³èšå®ããŠããªãã£ããããããã±ãŒãžãã€ã³ã¹ããŒã«ããããã® state
ãã©ã¡ãŒã¿ãŒã®èšå®å€ãšããŠããã©ã«ãå€ã® present
ã䜿çšãããŸããããã ããæå³çã«å€ãããŒãžã§ã³ã®ããã±ãŒãžãã€ã³ã¹ããŒã«ããããããããã®ããã±ãŒãžãæŽæ°ããå¿
èŠããããŸãã
Visual Studio Code ã§ãchocolatey
ãã©ã«ããŒã®äžã« update_packages.yml
ãšããååã®æ°ãããã¡ã€ã«ãäœæããŸãããã® Playbook ã§ã¯ãlatest
ãã©ã¡ãŒã¿ã«å€ãšããŠæž¡ããã state
ã䜿çšããŠ
win_chocolatey
ã¢ãžã¥ãŒã«ã䜿çšãããã¬ã€ãäœæããŸããChocolatey
ã«ãã£ãŠä»¥åã«ã€ã³ã¹ããŒã«ããããã¹ãŠã®ããã±ãŒãžãæŽæ°ãããããname
ãã©ã¡ãŒã¿ãŒã«ã¯ç¹å®ã®ããã±ãŒãžåãæå®ããã«ãå€ all
ã䜿çšããŸãã
ãã³ã
name
å±æ§ã«èšå®ãããå€ãšããŠall
ã䜿çšããæ¹æ³ã«é¢ããæ å ±ã¯ãwin_chocolatey
ã®ã¢ãžã¥ãŒã« docs ã«ãããŸããåããŠäœ¿çšããã¢ãžã¥ãŒã«ã®ããã¥ã¡ã³ããåžžã«ç¢ºèªããŠãã ãããå€ãã®å Žåãå€ãã®äœæ¥ãç¯çŽããã®ã«åœ¹ç«ã€æ å ±ããããŸãã
update_packages.yml
ã®å
容ã¯æ¬¡ã®ãšããã§ãã
---
- name: Update all packages using Chocolatey
hosts: all
gather_facts: false
tasks:
- name: Update all installed packages
win_chocolatey:
name: all
state: latest
- name: Check python version
win_command: python --version
register: check_python_version
- name: Check nodejs version
win_command: node --version
register: check_node_version
- debug:
msg: Python Version is {{ check_python_version.stdout_lines[0] }} and NodeJS version is {{ check_node_version.stdout_lines[0] }}
ä»ã®ã¿ã¹ã¯ã¯ãæŽæ°ã¿ã¹ã¯ã®å®è¡åŸã« nodejs
ãš python
ã®ããŒãžã§ã³ã確èªã§ããããã«ããããã«ãããŸããç°¡åã§ãã
次ã«ãæ°ãã Playbook ã Git ã«ãããAutomation Controller ããããèªèã§ããããšã確èªããŠããã次ã®å€ã䜿çšããŠæ°ãããžã§ããã³ãã¬ãŒããäœæããŠå®è¡ããŸãã
ãã³ã
ã»ãŒãã¹ãŠããããã±ãŒãžãã€ã³ã¹ããŒã«ããããã«äœæããæåã®ãžã§ããã³ãã¬ãŒããšåæ§ã§ãã
Tempates
ã«ç§»åããChocolatey - Install Packages
ãã³ãã¬ãŒãã®é£ã® ã¢ã€ã³ã³ãã¯ãªãã¯ãããšããã®ãžã§ããã³ãã¬ãŒããcopy
ã§ããŸããããã«ããããã®ãã³ãã¬ãŒãã®ã³ããŒãäœæãããŸãããã®ååãã¯ãªãã¯ããŠç·šéããå®è¡ããååã説æãããã³ Playbook ã«å€æŽãå ããããšãã§ããŸããPlaybook ã¯æåããäœæããããšãã§ããŸãã
Key | Value | Note |
---|---|---|
Name | Chocolatey - Update Packages | |
Description | Template for the update_packages playbook | |
JOB TYPE | Run | |
INVENTORY | Workshop Inventory | |
PROJECT | Ansible Workshop Project | |
PLAYBOOK | chocolatey/update_packages.yml |
|
CREDENTIAL | Type: Machine. Name: Student Account | |
LIMIT | windows | |
OPTIONS |
æ°ãããã³ãã¬ãŒããå®è¡ããåŸãdebug
ã¿ã¹ã¯ã¡ãã»ãŒãžã調ã¹ãŠãããŒãžã§ã³ã install_packages
ãžã§ãåºåããã®ãã®ãšæ¯èŒããŸãããããã®ããã±ãŒãžã¯æŽæ°ã§ãããããããŒãžã§ã³ã¯é«ããªãã¯ãã§ã (ã¢ãããã¯ã³ãã³ãã䜿çšããŠã€ã³ã¹ããŒã«ãã
git
ããã±ãŒãžãæŽæ°ããã§ãã¯ãããŸããã€ã³ã¹ããŒã«ã®æ°ååŸã«æŽæ°ãããå¯èœæ§ã¯ã»ãšãã©ãããŸãã)ã
win_chocolatey
ã¢ãžã¥ãŒã«ã¯ Chocolatey ã§ããã±ãŒãžã管çããããã«å®éã«äœ¿çšããããã®ã§ãããAnsible
ã§äœ¿çšã§ãã Chocolatey ã¢ãžã¥ãŒã«ã¯ããã ãã§ã¯ãªããWindows ã¿ãŒã²ãã㧠Chocolatey
ã管çããã³æ§æããã®ã«åœ¹ç«ã€ä»ã®ã¢ãžã¥ãŒã«ããããŸãããã®æŒç¿ã§ã¯ãwin_chocolatey_facts
ãš
win_chocolatey_config
ã® 2 ã€ãèŠãŠãããŸãã
æåã«äœ¿çšããã¢ãžã¥ãŒã«ã¯ win_chocolatey_facts
ã¢ãžã¥ãŒã«ã§ãããã®ã¢ãžã¥ãŒã«ã¯ãã€ã³ã¹ããŒã«ãããããã±ãŒãžãèšå®ãæ©èœããœãŒã¹ãªã©ã®æ
å ±ã Chocolatey
ããåéããããã«äœ¿çšãããŸããããã¯ãã¬ããŒãçæãšããŠã®ã¿ã¹ã¯ããŸãã¯ä»ã®ã¿ã¹ã¯ã§å®çŸ©ãããæ¡ä»¶ã«åœ¹ç«ã¡ãŸãã
ãã³ã >
詳现ã¯ãdocs. ã®
win_chocolatey_facts
ãåç §ããŠãã ããã
ããã§ã¯ãåéããæ å ±ãåéããŠè¡šç€ºããããã®ç°¡å㪠Playbook ãäœæããŠããã®ã¢ãžã¥ãŒã«ã«ãã£ãŠåéãããæ å ±ã詳ããèŠãŠãããŸãããã
Visual Studio Code ã® chocolatey
ãã©ã«ããŒã®äžã«ãchocolatey_configuration.yml
ãšããååã®æ°ãããã¡ã€ã«ãäœæããŸãããã®ãã¡ã€ã«ã®å
容ã¯æ¬¡ã®ããã«ãªããŸãã
---
- name: Chocolatey Facts and Configuration
hosts: all
gather_facts: false
tasks:
- name: Gather facts from Chocolatey
win_chocolatey_facts:
- name: Displays the gathered facts
debug:
var: ansible_chocolatey
æåã®ã¿ã¹ã¯ã¯ãwin_chocolatey_facts
ã䜿çšããŠã¿ãŒã²ãã Windows ãã·ã³äžã® Chocolatey
ããå©çšå¯èœãªãã¹ãŠã®æ
å ±ãåéãããã®æ
å ±ã ansible_chocolatey
ãšããååã®å€æ°ã«æ ŒçŽããŸãããã®å€æ°ã¯ãdebug
ã¢ãžã¥ãŒã«ã䜿çšããŠå
容ãåºåããŠè©³çŽ°ã調ã¹ãŸãã
æ°ãã Playbook ããœãŒã¹ç®¡çãªããžããªã«è¿œå ããAutomation Controller 㧠ãããžã§ã¯ããåæããŠããã次ã®å€ã䜿çšããŠæ°ãããžã§ããã³ãã¬ãŒããäœæããŠå®è¡ããŸãã
Key | Value | Note |
---|---|---|
Name | Chocolatey - Facts and configuration | |
Description | Template for the chocolatey_configuration playbook | |
JOB TYPE | Run | |
INVENTORY | Workshop Inventory | |
PROJECT | Ansible Workshop Project | |
PLAYBOOK | chocolatey/chocolatey_conguration.yml |
|
CREDENTIAL | Type: Machine. Name: Student Account | |
LIMIT | windows | |
OPTIONS |
ãžã§ãã®åºåã«ã¯ãæåã®ã¿ã¹ã¯ã§åéããã ansible_chocolatey
å€æ°ã®å
容ã衚瀺ãããŸãã
åºåãã¹ã¯ããŒã«ããŠå€ã確èªãããšãWindows ã¿ãŒã²ããã§ã® Chocolatey
ã¯ã©ã€ã¢ã³ãã®èšå®ãæå¹ããã³ç¡å¹ãªæ©èœãã€ã³ã¹ããŒã«ãããŠããããã±ãŒãž
(åã®æŒç¿ã§ã€ã³ã¹ããŒã«ããããã±ãŒãžã衚瀺ãããŠããã§ãããã)ãããã³ãœãŒã¹ã衚瀺ãããŸããããããããã±ãŒãžãã€ã³ã¹ããŒã«ããŸã
(ããã«ã€ããŠã¯åŸã§è©³ãã説æããŸã)ããã®æ
å ±ã¯ JSON
圢åŒã§ããããããªããžã§ã¯ãããªãŒããã©ããŒã¹ããããšã§åã
ã®å€ã«ã¢ã¯ã»ã¹ã§ããããšã«æ³šæããŠãã ãããããšãã°ãã€ã³ã¹ããŒã«ãããããã±ãŒãžã«é¢ããæ
å ±ã®ã¿ã«é¢å¿ããããããšãã°ã€ã³ã¹ããŒã«ãããããã±ãŒãžã®ã¬ããŒããçæããå Žåã¯ãansible_chocolatey.packages
ããŒã䜿çšããŠãããã®å€ã«ã¢ã¯ã»ã¹ã§ããŸãã
ãã³ã
win_chocolatey_facts
ã¢ãžã¥ãŒã«ã«ãã£ãŠåéãããæ å ±ã衚瀺ããããã ãã«debug
ã¿ã¹ã¯ã䜿çšããå¿ èŠã¯ãããŸããã§ããã代ããã«ãAnsible Tower ã®ãžã§ãåºåãã€ã³ã§ãWindows ã¿ãŒã²ããã§ã¿ã¹ã¯ãå®è¡ããçµæãã¯ãªãã¯ããŸããããã«ããããã®ç¹å®ã®ãã¹ãã®ãã¹ãã€ãã³ããã€ã¢ãã°ãéããŸããéžæããã€ãã³ãã®åœ±é¿ãåãããã¹ããšãã®ã€ãã³ãã®åºåã«é¢ããæ å ±ã衚瀺ãããŸã (ãã®å Žåãwin_chocolatey_facts
ã¢ãžã¥ãŒã«ã«ãã£ãŠè¿ããã JSON ãªããžã§ã¯ããå®è¡ãããŸã)
åã®æé ã§ãwin_chocolatey_facts
ã¢ãžã¥ãŒã«ã䜿çšã㊠Windows ã¿ãŒã²ããäžã® Chocolatey
ã¯ã©ã€ã¢ã³ãã®æ§æãåéã§ããããšã確èªããŸãããã§ã¯ããããã®æ§æãå€æŽããå Žåã¯ã©ãã§ããããããã®ããã®ã¢ãžã¥ãŒã«ãååšããŸãã
win_chocolatey_config
ã¢ãžã¥ãŒã«ã䜿çšããŠãèšå®ãªãã·ã§ã³ã®å€ãå€æŽãããããããããã¹ãŠãŸãšããŠèšå®è§£é€ããããšã«ãããChocolatey èšå®ã管çã§ããŸãã
ãã³ã >
詳现ã¯ã[docs](https://docs.ansible.com/ansible/latest/collections/chocolatey/chocolatey/win_chocolatey_config_module.html ã®
win_chocolatey_config
ãåç §ããŠãã ããã
ãã³ã
詳现ã¯ã Chocolatey ã®èšå® [ãã¡ã](https://docs.chocolatey.org/en-us/configurationãåç §ããŠãã ããã
cacheLocation
ãš commandExecutionTimeoutSeconds
ã® 2
ã€ã®èšå®ãªãã·ã§ã³ã®å€ãå€æŽããŸããåã®æé ã®åºåã§ã¯ãcacheLocation
ãèšå®ãããŠããªãããå€ãæ§æãããŠããªãããšãããããŸãããããã¯ããã©ã«ãèšå®ã§ãããcommandExecutionTimeoutSeconds
ã®å€ãããã©ã«ãå€ã® 2700 ã«èšå®ãããŠããŸãããããã®èšå®ãªãã·ã§ã³ãå€æŽããŸãã
cacheLocation
ãC:\ChocoCache
ã«èšå®ããŸããcommandExecutionTimeoutSeconds
ã 1 æéãŸãã¯3600
ç§ã«èšå®ããŸãã
Visual Studio Codeã§ãchocolatey_configuration.yml
Playbook
ãç·šéããŠã次ã®ã¿ã¹ã¯ãè¿œå ããŸãã
- name: Create a directory for the new Chocolatey caching directory
win_file:
path: C:\ChocoCache
state: directory
- name: Configure Chocolatey to use the new directory as the cache location
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\ChocoCache
- name: Change the Execution Timeout Setting
win_chocolatey_config:
name: commandExecutionTimeoutSeconds
state: present
value: 3600
- name: ReGather facts from Chocolatey after new reconfiguring
win_chocolatey_facts:
- name: Displays the gathered facts
debug:
var: ansible_chocolatey.config
ãããã®æ°ããã¿ã¹ã¯ã¯ã以äžãå®è¡ããŸãã
win_file
ã¢ãžã¥ãŒã«ã䜿çšããŠãã£ã¬ã¯ããªãŒC:\ChocoCache
ãäœæããŸããcacheLocation
ã䜿çšããŠãwin_chocolatey_config
ã®å€ãæ°ãã«äœæããããã£ã¬ã¯ããªãŒã«å€æŽããŸããcommandExecutionTimeoutSeconds
ã®å€ã3600
ã«å€æŽããŸãã- èšå®å€ãå€æŽããåŸãChocolatey ãã¡ã¯ããååéããŸãã
- ãããŠæåŸã«ãå·æ°ããã Chocolatey ãã¡ã¯ãã®
config
ã®éšåãåºåããŸãã
chocolatey_configuration.yml
Playbook ã®å
容ã¯ä»¥äžã®ããã«ãªããŸãã
---
- name: Chocolatey Facts and Configuration
hosts: all
gather_facts: false
tasks:
- name: Gather facts from Chocolatey
win_chocolatey_facts:
- name: Displays the gathered facts
debug:
var: ansible_chocolatey
- name: Create a directory for the new Chocolatey caching directory
win_file:
path: C:\ChocoCache
state: directory
- name: Configure Chocolatey to use the new directory as the cache location
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\ChocoCache
- name: Change the Execution Timeout Setting
win_chocolatey_config:
name: commandExecutionTimeoutSeconds
state: present
value: 3600
- name: ReGather facts from Chocolatey after new reconfiguring
win_chocolatey_facts:
- name: Displays the gathered facts
debug:
var: ansible_chocolatey.config
å€æŽãã³ãããããŠãœãŒã¹ç®¡çã«ããã·ã¥ããAutomation Controller ã§ãããžã§ã¯ããåæããŠãChocolatey - Facts and Configuration
ãžã§ããã³ãã¬ãŒããå®è¡ããŸãã
ãã³ã
æŒç¿ 1 㧠Automation Controller ã§ãããžã§ã¯ããäœæãããšãã«ã
UPDATE REVISION ON LAUNCH
ã®ãªãã·ã§ã³ããã§ãã¯ããã®ã§ãController ã§ãããžã§ã¯ããæŽæ°ããå¿ èŠã¯ãããŸããã§ããããããããã®ãªãã·ã§ã³ããã§ãã¯ããŠããªãå Žåãæ³å®ããŠããŸãã
Playbook ãå®è¡ããŠèšå®ãå€æŽããansible_chocolatey.config
ã»ã¯ã·ã§ã³ã®å€ã瀺ãæåŸã® debug
ã¿ã¹ã¯ããã®åºåã«ãããã®å€æŽãåæ ããcacheLocation
ãš commandExecutionTimeoutSeconds
ã®æ°ããå€ã衚瀺ããå¿
èŠããããŸãã
ããã§çµããã§ããä»åã®æŒç¿ã§ã¯ãChocolatey ã«é¢é£ãã Ansible ã¢ãžã¥ãŒã«ã®å€ããã«ããŒããŸãã
(ãã ããwin_chocolatey_source
ãšwin_chocolatey_feature
ã«ã€ããŠã¯
[ãã¡ã](https://docs.ansible.com/ansible/latest/collections/chocolatey/chocolatey/win_chocolatey_feature_module.htmlãš
ãã¡ã
ãåç
§ããŠãã ãã) é¡ããã°ãAnsible ãš Chocolatey ãçµã¿åãã㊠Windows
ããã±ãŒãžã管çããããšã§ããã®å¯èœæ§ãå³ãã£ãŠããã ããããšæããŸãã