TechFanDan
TechFanDan

Reputation: 3502

Converting shell script to Ansible play

I am trying to translate a shell script into Ansible.

Snippet of code that is confusing me:

sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools 
sudo apt-get install unixodbc-dev

What I have so far:

- name: Install SQL Server prerequisites
  apt: name={{item}} state=present
  update_cache: yes
  with_items:
  - msodbcsql
  - mssql-tools
  - unixodbc-dev

No idea where to tie in ACCEPT_EULA=Y.

Upvotes: 1

Views: 2347

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68289

This is an environment variable, so:

- name: Install SQL Server prerequisites
  apt:
    name: "{{item}}"
    state: present
    update_cache: yes
  with_items:
    - msodbcsql
    - mssql-tools
    - unixodbc-dev
  environment:
    ACCEPT_EULA: Y

And mind the indentation. It's really important in YAML.

Upvotes: 3

Related Questions