This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from radekg/ansible-galaxy
Implement ansible-galaxy install for local and remote provisioner.
- Loading branch information
Showing
21 changed files
with
581 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
5 changes: 5 additions & 0 deletions
5
examples/sshagent-galaxy-local/ansible-data/playbooks/install-ntp.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- geerlingguy.ntp |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# from galaxy | ||
- src: geerlingguy.ntp |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
provider "aws" { | ||
region = "eu-central-1" | ||
profile = "terraform-provisioner-ansible" | ||
} | ||
|
||
variable "ami_id" {} | ||
variable "insecure_no_strict_host_key_checking" { | ||
default = false | ||
} | ||
|
||
## -- security groups: | ||
|
||
resource "aws_security_group" "ssh_box" { | ||
name = "ssh_box" | ||
description = "SSH" | ||
|
||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
self = true | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
## -- machine: | ||
|
||
resource "aws_instance" "test_box" { | ||
ami = "${var.ami_id}" | ||
count = "1" | ||
instance_type = "m3.medium" | ||
|
||
security_groups = ["${aws_security_group.ssh_box.name}"] | ||
|
||
connection { | ||
host = "${self.public_ip}" | ||
user = "centos" | ||
} | ||
|
||
provisioner "ansible" { | ||
plays { | ||
galaxy_install { | ||
role_file = "${path.module}/ansible-data/requirements.yml" | ||
roles_path = "${path.module}/ansible-data/roles/" | ||
verbose = true | ||
} | ||
} | ||
plays { | ||
playbook { | ||
file_path = "${path.module}/ansible-data/playbooks/install-ntp.yml" | ||
roles_path = [ | ||
"${path.module}/ansible-data/roles/" | ||
] | ||
} | ||
hosts = ["testBoxToBootstrap"] | ||
} | ||
ansible_ssh_settings { | ||
insecure_no_strict_host_key_checking = "${var.insecure_no_strict_host_key_checking}" | ||
} | ||
} | ||
|
||
root_block_device { | ||
delete_on_termination = true | ||
volume_size = 8 | ||
volume_type = "gp2" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/sshagent-galaxy-remote/ansible-data/playbooks/install-ntp.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- geerlingguy.ntp |
2 changes: 2 additions & 0 deletions
2
examples/sshagent-galaxy-remote/ansible-data/requirements.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# from galaxy | ||
- src: geerlingguy.ntp |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
provider "aws" { | ||
region = "eu-central-1" | ||
profile = "terraform-provisioner-ansible" | ||
} | ||
|
||
variable "ami_id" {} | ||
|
||
|
||
## -- security groups: | ||
|
||
resource "aws_security_group" "ssh_box" { | ||
name = "ssh_box" | ||
description = "SSH" | ||
|
||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
self = true | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
## -- machine: | ||
|
||
resource "aws_instance" "test_box" { | ||
ami = "${var.ami_id}" | ||
count = "1" | ||
instance_type = "m3.medium" | ||
|
||
security_groups = ["${aws_security_group.ssh_box.name}"] | ||
|
||
connection { | ||
host = "${self.public_ip}" | ||
user = "centos" | ||
} | ||
|
||
provisioner "ansible" { | ||
plays { | ||
galaxy_install { | ||
role_file = "${path.module}/ansible-data/requirements.yml" | ||
verbose = true | ||
} | ||
} | ||
plays { | ||
playbook { | ||
file_path = "${path.module}/ansible-data/playbooks/install-ntp.yml" | ||
roles_path = [ | ||
# our galaxy_install does not deine roles_path, default values are being used: | ||
"galaxy_install:/tmp/tf-ansible-bootstrap/galaxy-roles" | ||
] | ||
} | ||
hosts = ["testBoxToBootstrap"] | ||
} | ||
remote {} | ||
} | ||
|
||
root_block_device { | ||
delete_on_termination = true | ||
volume_size = 8 | ||
volume_type = "gp2" | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.