The VSCode ansible extension is designed to increase developer productivity authoring, testing and using Ansible with Azure. The extension provides cool features around playbook authoring and execution. It supports running playbook from various places e.g. Docker, local installation, remote machines via ssh and Cloud Shell.
Jeff Geerling (geerlingguy) maintains a large variety of open source Ansible content. This website catalogs it all. About Jeff Geerling (geerlingguy) Jeff Geerling is an author and software developer from St. He started using Ansible in 2013 and maintains numerous Ansible works. Mac Development Playbook. Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. ansible/ansible. Here is a description what to do after installing Ansible on Mac, it worked for me: ansible-tips-and-tricks.readthedocs.io. I downloaded the ansible.cfg file to /Users/'yourUser'/.ansible and afterwards you can edit the ansible.cfg file by uncommenting the. Inventory = /Users/'yourUser'/.ansible.
Table of Content
- Usage
- Yaml validation
- Run Ansible playbook
Features
- Auto completion. Auto completion Ansible directives, modules and plugins from Ansible doc, Auto completion for variables. Disable auto completion by setting
ansible.autocompletion
tofalse
. - Code snippets. Press
Ctrl + Space
, Ansible playbook code snippets will show up. - Syntax highlighting. Enable syntax highlighting by setting
files.associations
toansible
insettings.json
. - Yaml validation. Yaml validation by leverage Yaml language server.
- Code navigation by Symbols, press
Ctrl + Shift + O
. - Hover over module names, to show module documentation. Disable hovering over by setting
ansible.hover
tofalse
. - Run playbook from Docker.
- Run playbook from local Ansible installation.
- Run playbook from Cloud Shell.
- Run playbook remotely via ssh.
- Auto File Copy to remote host on saving.
Configuration
This extension provides below configurations in settings.json.
Config Name | Default Value | Description |
---|---|---|
ansible.autocompletion | true | Enable/Disable ansible autocompletion(including code snippets) functionality. To enable ansible autocompletion only in specific yaml files, set ansible.autocompletion = false , then add # ansible-configured header in first line of yaml file. |
ansible.hover | true | Enable/Disable hover over module name functionality. |
ansible.reuseSSHTerminal | true | Enable/Disable SSH terminal reusing. |
ansible.credentialsFile | $HOME/.vscode/ansible-credentials.yml | Specify ansible credentials file path, used when run playbook in Docker/Local Ansible. |
ansible.termininalInitCommand | Default is docker run command for Docker. | Specify customized terminal init command when run playbook in Docker. |
ansible.dockerImage | microsoft/ansible:latest | Docker image name when running playbook in Docker. |
ansible.customOptions | null | Customize run playbook options. eg. -i xxxx -vvv . |
ansible.fileCopyConfig | null | File copying configuration when running playbook remotely via SSH. It's array of configuration. Please see detail at here |
Prerequisites
platform | prerequisite |
---|---|
Run Playbook in Cloud Shell/Remotely via ssh | nodejs >= 6.0 |
Run Playbook in Docker | Docker |
Run Playbook in Local Ansible | Ansible |
Usage
Associate your Yaml files with
ansible
language in VSCode settings.json
:Code snippets
Code snippets will be in auto-completed list with suffix
_snippet
. Press tab
to move inside snippet parameters.Syntax highlighting
Enable syntax highlighting by adding
files.associations
in settings.json
, to associate your paths with ansible
language, please see sample.Run Ansible playbook
Run Playbook in Docker
- Make sure Docker is installed and running. For non-Windows platform, please configure Docker run without sudo.
- Default docker image is microsoft/ansible:latest, which is latest Ansible version. Customizing your own docker image by configuration item
ansible.dockerImage
, customizing docker init command by configurationansible.termininalInitCommand
, eg.docker run -i -t microsoft/ansible:ansible2.5.5 /bin/bash
. Detail please see configuration. - For Windows user, please share your Windows driver where vscode workspace sits on with docker. This is because the extension will map your workspace containing playbook with docker.
- This step is optional. If you want to run cloud provider specific Ansible modules, you need set cloud credentials in credential yaml file, default path is
$HOME/.vscode/ansible-credentials.yml
, or change credential file path by settings itemansible.credentialsFile
. Credential file template is at here. - Press
F1
, type:Ansible
, chooseRun Ansible Playbook in Docker
. Or right click playbook yaml file, chooseRun Ansible Playbook in Docker
.NOTE- Docker on Windows is not as stable as on other platforms, please try to restart Docker in case of any issue.
- Downloading Docker image first time usage may be time consuming in case of slow network connection.
Run Playbook in Local Ansible
- Make sure Ansible is installed.
- This step is optional. If you want to run cloud provider specific Ansible modules, please setup cloud credentials by following Ansible instruction. Or you can set cloud credentials in credential file, default path is
$HOME/.vscode/ansible-credentials.yml
, change credential file path by settings itemansible.credentialsFile
. Credential file template is at here. - Press
F1
, type:Ansible
, chooseRun Ansible Playbook in Local Ansible
. Or right click playbook yaml file, chooseRun Ansible Playbook in Local Ansible
.
Run Playbook in Cloud Shell
- Important Please setup Cloud Shell for first time usage in Azure Portal by following this instruction. After setup, input cmd
az account show
to learn your current subscription setting. - Install Azure Account VSCode extension, which is used for Azure login.
- Press
F1
, type:Azure: Sign In
, do Azure login. - Press
F1
, type:Ansible
, chooseRun Ansible Playbook in Cloud Shell
. Or right click playbook yaml file, chooseRun Ansible Playbook in Cloud Shell
. - Confirm awareness on Azure usage fee. Please refer to this document to learn more about Azure Cloud Shell pricing.
- Known issue due to adal issue, introduced in azure account extension, user might see
Entry not found
error when connect to cloud shell. Please retry open cloud shell.
Run Playbook Remotely via ssh
- Press
F1
, chooseRun Ansible Playbook Remotely via ssh
, follow wizard to pick up/add remote host. Or configure your remote server in$HOME/.ssh/servers.json
like below.
Files copy to remote on saving
- Configure file copying to remote host on saving as below in
settings.json
.sourcePath
will be copied to remoteserver
astargetPath
when configuration added/updated.copyOnSave
will copy local saved files to remote host.
There's notification message at right side of status bar.
Samples for azure_rm_resource (Preview)
This command provides sample code snippets for azure_rm_resource module, those samples are from Azure Rest API spec.
To use, press F1 and then select Ansible: Samples for azure_rm_resource (PREVIEW) command.You will be first asked for API group, then required operation. After selecting operation a pickup list will be displayed where you can select particular API version and sample. Extension will create appropriate playbook based on azure_rm_resource or azure_rm_resource_facts module.
Note that all the samples generated by the extension are based on REST API samples from this repository:
Please also refer to Azure REST API reference here:
In case of any bugs encountered in samples please fill an issue here:
Note 1: This feature requires Ansible >= 2.7.
Note 2: When using for the first time it may take a few minutes to retrieve REST API specifications.
Feedback and Questions
You can submit bug or feature suggestion via issues.
License
MIT license.
Telemetry
This extension collects telemetry data to help improve our products. Please read Microsoft privacy statement to learn more. If you opt out to send telemetry data to Microsoft, please set below configuration in settings.json:
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
This project has adopted the Microsoft Open Source Code of Conduct.For more information see the Code of Conduct FAQ orcontact [email protected] with any additional questions or comments.
Please see below documents to learn how to contribute:
Release Notes and Thank you
Please see our releases to see detail in each release, and
Thank you
. Or check CHANGELOG.This extension includes a build/release task to integrate with Ansible. The task executes a given Ansible playbook on a specified list of inventory nodes via command line interface.Ansible is an open-source IT automation engine that can configure systems, deploy software and orchestrate application deployments.Ansible uses Playbooks which express configurations, deployment, and orchestration steps in YAML format. Each Playbook maps a group of hosts to a set of roles. Each role is represented by calls to Ansible tasks.Inventory file is a description of the nodes that can be accessed by Ansible.
This task requires that the Playbook and Inventory files be located either on a private Linux agent or on a remote machine where Ansible automation engine has been installed. Additionally Inventory can also be specified inline or as a Host list.
Prerequisites
Install Ansible automation engine
Follow the installation guidance to install Ansible on a private Linux agent or on a remote machine. Currently Ansible can be run from any machine with Python 2.6 or 2.7 installed (Windows isn’t supported for the control machine).
Create an SSH endpoint
If Ansible is installed on a remote machine, you would need to set up an SSH endpoint in the administration section of your VSTS project.
- The hostname or IP address of the remote machine, the port number, and the user name are required
- The private key and the passphrase must be specified for authentication.
- A password can be used to authenticate to remote Linux machines, but this is not supported for Mac or OSX systems.
- The public key must be pre-installed or copied to the remote machine.
Task
Installing the extension adds the following Ansible task which runs a given Playbook:
When Ansible automation engine is located on an Agent machine:
When Ansible automation engine is located on a remote machine:
Task arguments
- Ansible location: Location where Ansible automation engine is installed. Can be either a private agent machine or a remote machine. Ansible communicates with remote machines over SSH and would require the SSH endpoint details.
- SSH endpoint*: Name of the SSH service endpoint containing connection details for the remote machine where Ansible automation engine has been installed.
- Playbook Source: Choose agent machine if playbook is part of a linked artifact and should be copied to the remote Ansible machine. Otherwise, select Ansible machine.
- Playbook root*: Specify the working directory path where playbook and associated files are located on the agent machine. All the files in this folder will be copied to Ansible machine.
- Playbook file path*: Specify the path to the playbook file to be executed on the Ansible machine. Playbooks declare Ansible’s configuration, deployment, and orchestration steps in YAML format.
- Inventory location: By default, Ansible Inventory is described by a configuration file, in INI format, whose default location is in /etc/ansible/hosts. Inventory can also be specified as a separate configuration file which lists either the IP address or hostname of each node that is accessible by Ansible. Or can be specified as a Host list of comma separated hosts. Example - foo.example.com, bar.example.com.
Alternatively Inventory can be specified inline.
- Inventory file path*: Specify the path to inventory host file on Ansible/Agent machine
- Dynamic Inventory: Ansible can also use a custom Dynamic Inventory script, which can dynamically pull data from a different system. Check this box if dynamic inventory is used.
- Advanced - Sudo: Run operations with sudo. It works only when the Ansible user is sudoer with nopasswd option.This also requires desired sudo user name. 'root' is used when this field is empty.
- Additional arguments: The arguments to pass to Ansible command line. Refer to documentation on Ansible Commands Modules and Ad-Hoc Commands
- Advanced - Fail on STDERR: If this option is selected (the default), the build will fail if the remote commands or script write to STDERR.
- Control options: See Control options
Ansible Download Mac Os
Contact Information
Mac Install Ansible
For further information or to resolve issues, contact Developer Community Forum.