digital_ocean_inventory 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 611b2b70cd34ba50a0ace0402f45605c766665c448d5be96384ea0561974d71f
4
- data.tar.gz: e22b96a6616a01b1ab9938cebd2a046482629cf66e356bcfe00fdd5936e2ba38
3
+ metadata.gz: 49db0ef1f05794822bf84ae4c53c758f0850893b75d2532d89a4b8ded7473989
4
+ data.tar.gz: 9e1437fd9c2e26f89cd63d111b497445012bfaa7a55d3055f3132804400ee66c
5
5
  SHA512:
6
- metadata.gz: a256abc0d6eab4cefea9af3281a17591004f8ba5f7cc9340d314e99a6503bbc0305273052b2ace8740004f42820283d0a1daf7ab2b9bf804142a17ff2da7a0f8
7
- data.tar.gz: f3988e39f4f240dfbf42e65172a6fc16e608294a0a8bcfec00c29fef1f7a47559e62d1f60674e01a0956ae711662fcefb0c0db32b9d8e31424ce501f0c800556
6
+ metadata.gz: 1fe746fd14107495635530b15d74995dcf8454e4adebade5d792bea4666983adbd9853ab73cdc8e71ba6a0c7943ac4f7da5437ad4c802acd2b6fde3a136594f5
7
+ data.tar.gz: 6a113ae4b7f19e8994619563077dc7b3b687d8007c05e3e55275aad672420c31e2f0a1bba0558469b64526ce120a28751fab96a6b372fc94c3b99e2bca9814eb
@@ -50,10 +50,8 @@ module DigitalOceanInventory
50
50
  end
51
51
 
52
52
  def select_droplet?(droplet)
53
- return true if config.select_tags.empty?
54
-
55
53
  tags = droplet.tags || []
56
- config.select_tags.any? { |t| tags&.include? t }
54
+ tags.any? { _1 == "ansible:enable" }
57
55
  end
58
56
 
59
57
  def ignore_droplet?(droplet)
@@ -71,10 +69,16 @@ module DigitalOceanInventory
71
69
  end
72
70
 
73
71
  def droplet_groups(droplet)
74
- groups = []
72
+ groups = %w[digitalocean]
75
73
  groups << droplet.region.slug if config.group_by_region
76
74
  groups << droplet_vpc(droplet)
77
- droplet.tags&.each { |t| groups << t } if config.group_by_tag
75
+
76
+ droplet.tags
77
+ &.uniq
78
+ &.select { |t| t.match? /^ansible:g:/ }
79
+ &.map { |t| t.gsub "ansible:g:", "" }
80
+ &.each { |t| groups << t }
81
+
78
82
  groups.uniq.map { |g| g.gsub('-', '_') }
79
83
  end
80
84
 
@@ -83,39 +87,5 @@ module DigitalOceanInventory
83
87
  vpc = config.client.vpcs.find id: id
84
88
  vpc.name
85
89
  end
86
- # def add_droplets
87
- # project_droplets.each do |droplet|
88
- # name = droplet.name
89
- # groups = ["digitalocean"]
90
-
91
- # if droplet.region.name.include? "nyc"
92
- # groups << "usa"
93
- # groups << "nyc"
94
- # elsif droplet.region.name.include? "sfo"
95
- # groups << "usa"
96
- # groups << "sfo"
97
- # end
98
-
99
- # tags = droplet.tags || []
100
- # groups = groups.concat tags
101
-
102
- # groups << droplet.image.distribution.downcase
103
- # # groups << droplet.image.name
104
-
105
- # public_net = droplet.networks.v4.find { |n| n.type == "public" }
106
- # private_net = droplet.networks.v4.find { |n| n.type == "private" }
107
-
108
- # inventory.host name, groups: groups, vars: dns_results[:vars].merge({
109
- # public_ip: public_net.ip_address,
110
- # private_ip: private_net.ip_address,
111
- # droplet_id: droplet.id,
112
- # vpc_uuid: droplet.vpc_uuid,
113
- # digitalocean_tags: tags,
114
- # internal_dns_records: dns_results[:dns]
115
- # })
116
- # end
117
- # end
118
-
119
-
120
90
  end
121
91
  end
@@ -1,3 +1,3 @@
1
1
  module DigitalOceanInventory
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digital_ocean_inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Hurst
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: droplet_kit