Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/examples 0.3.0 #419

Merged
merged 3 commits into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions examples/docker-swarm-mode/converge/awscli.hcl
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
task "epel-install" {
check = "test -f /etc/yum.repos.d/epel.repo"
apply = "yum makecache; yum install -y epel-release"
package.rpm "epel-install" {
name = "epel-release"
state = "present"
}

task "pip-install" {
check = "yum list installed python-pip"
apply = "yum makecache; yum install -y python-pip"
depends = ["task.epel-install"]
package.rpm "pip-install" {
name = "python-pip"
state = "present"

depends = ["package.rpm.epel-install"]
}

task "awscli-install" {
check = "which aws"
apply = "pip install awscli"
depends = ["task.pip-install"]
check = "which aws"
apply = "pip install awscli"

depends = ["package.rpm.pip-install"]
}
33 changes: 17 additions & 16 deletions examples/docker-swarm-mode/converge/docker.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,17 @@ param "docker-group" {

param "user-name" {}

file.content "docker-repo" {
destination = "/etc/yum.repos.d/docker.repo"
package.rpm "docker-install" {
name = "{{param `docker-package`}}"
state = "present"

content = <<EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
}

task "docker-install" {
check = "yum list installed {{param `docker-package`}}"
apply = "yum makecache; yum install -y {{param `docker-package`}}"
depends = ["file.content.docker-repo"]
}

task "docker-user-group" {
check = "groups {{param `user-name`}} | grep -i {{param `docker-group`}}"
apply = "usermod -aG {{param `docker-group`}} {{param `user-name`}}"
depends = ["task.docker-install"]
depends = ["package.rpm.docker-install"]
}

task "docker-enable" {
Expand All @@ -48,3 +36,16 @@ task "docker-start" {
apply = "systemctl start {{param `docker-service`}}"
depends = ["task.docker-enable"]
}

file.content "docker-repo" {
destination = "/etc/yum.repos.d/docker.repo"

content = <<EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
}
Binary file modified examples/docker-swarm-mode/graphs/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 20 additions & 18 deletions examples/elk/converge/docker.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,18 @@ EOF
depends = ["file.directory.service-directory"]
}

file.content "docker-repo" {
destination = "/etc/yum.repos.d/docker.repo"
package.rpm "docker-install" {
name = "{{param `docker-package`}}"
state = "present"

content = <<EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
}

task "docker-install" {
check = "yum list installed {{param `docker-package`}}"
apply = "yum makecache; yum install -y {{param `docker-package`}}"
depends = ["file.content.docker-repo"]
}

task "docker-user-group" {
check = "groups {{param `user-name`}} | grep -i {{param `docker-group`}}"
apply = "usermod -aG {{param `docker-group`}} {{param `user-name`}}"
depends = ["task.docker-install"]
check = "groups {{param `user-name`}} | grep -i {{param `docker-group`}}"
apply = "usermod -aG {{param `docker-group`}} {{param `user-name`}}"

depends = ["package.rpm.docker-install"]
}

task "docker-enable" {
Expand All @@ -78,3 +67,16 @@ task "docker-start" {
apply = "systemctl daemon-reload; systemctl start {{param `docker-service`}}"
depends = ["task.docker-enable"]
}

file.content "docker-repo" {
destination = "/etc/yum.repos.d/docker.repo"

content = <<EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
}
47 changes: 3 additions & 44 deletions examples/elk/converge/elk.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,14 @@ module "docker.hcl" "docker" {
params = {
user-name = "{{param `user-name`}}"
}

depends = ["module.packages"]
}

module "filebeat.hcl" "filebeat" {}

param "elasticsearch-data-directory" {
default = "/data/elasticsearch"
}

param "filebeat-service" {
default = "filebeat"
}

task "filebeat-install" {
check = "yum list installed filebeat"
apply = "rpm -ivh https://download.elastic.co/beats/filebeat/filebeat-1.3.0-x86_64.rpm"
depends = ["module.docker"]
}

file.content "filebeat-yml" {
destination = "/etc/filebeat/filebeat.yml"

content = <<EOF
filebeat:
prospectors:
- paths:
- /var/log/*.log
- /var/log/messages
input_type: log
registry_file: /var/lib/filebeat/registry
output:
elasticsearch:
hosts: ["localhost:9200"]
EOF

depends = ["task.filebeat-install"]
}

task "filebeat-enable" {
check = "systemctl is-enabled {{param `filebeat-service`}}"
apply = "systemctl enable {{param `filebeat-service`}}"
depends = ["file.content.filebeat-yml"]
}

wait.query "elasticsearch-wait" {
check = <<EOF
status=$(curl -s 'http://localhost:9200/_cluster/health' 2>/dev/null | jq -r .status)
Expand All @@ -66,13 +31,7 @@ EOF
task "filebeat-elasticsearch-template" {
check = "[[ \"$(curl 'http://localhost:9200/_template/filebeat' 2>/dev/null)\" != \"{}\" ]] || exit 1"
apply = "curl -XPUT 'http://localhost:9200/_template/filebeat' -d@/etc/filebeat/filebeat.template.json 2>/dev/null"
depends = ["task.filebeat-enable", "docker.container.elasticsearch-container", "wait.query.elasticsearch-wait"]
}

task "filebeat-start" {
check = "systemctl is-active {{param `filebeat-service`}}"
apply = "systemctl start {{param `filebeat-service`}}"
depends = ["task.filebeat-enable", "docker.container.elasticsearch-container"]
depends = ["module.filebeat", "docker.container.elasticsearch-container", "wait.query.elasticsearch-wait"]
}

file.directory "elasticsearch-data-directory" {
Expand Down
60 changes: 60 additions & 0 deletions examples/elk/converge/filebeat.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
param "filebeat-service" {
default = "filebeat"
}

task.query "beats-repo-key" {
query = "rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch"
}

file.content "beats-repo" {
destination = "/etc/yum.repos.d/beats.repo"

content = <<EOF
[beats]
name=Elastic Beats Repository
baseurl=https://packages.elastic.co/beats/yum/el/$basearch
enabled=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
gpgcheck=1
EOF

depends = ["task.query.beats-repo-key"]
}

package.rpm "filebeat-install" {
name = "filebeat"
state = "present"

depends = ["file.content.beats-repo"]
}

file.content "filebeat-yml" {
destination = "/etc/filebeat/filebeat.yml"

content = <<EOF
filebeat:
prospectors:
- paths:
- /var/log/*.log
- /var/log/messages
input_type: log
registry_file: /var/lib/filebeat/registry
output:
elasticsearch:
hosts: ["localhost:9200"]
EOF

depends = ["package.rpm.filebeat-install"]
}

task "filebeat-enable" {
check = "systemctl is-enabled {{param `filebeat-service`}}"
apply = "systemctl enable {{param `filebeat-service`}}"
depends = ["file.content.filebeat-yml"]
}

task "filebeat-start" {
check = "systemctl is-active {{param `filebeat-service`}}"
apply = "systemctl start {{param `filebeat-service`}}"
depends = ["task.filebeat-enable"]
}
15 changes: 8 additions & 7 deletions examples/elk/converge/packages.hcl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
task "epel-install" {
check = "test -f /etc/yum.repos.d/epel.repo"
apply = "yum makecache; yum install -y epel-release"
package.rpm "epel-install" {
name = "epel-release"
state = "present"
}

task "jq-install" {
check = "yum list installed jq"
apply = "yum makecache; yum install -y jq"
depends = ["task.epel-install"]
package.rpm "jq-install" {
name = "jq"
state = "present"

depends = ["package.rpm.epel-install"]
}
Binary file modified examples/elk/graphs/elk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.